Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the docs/repo widget #465

Merged
merged 2 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
faAdjust, faArrowsAltV, faBars, faBuilding, faCheckCircle, faChevronCircleDown,
faCode, faCoffee, faComments, faColumns, faCopy, faCopyright, faEdit, faEllipsisV,
faEnvelope, faExclamationTriangle, faExpandAlt, faEyeDropper, faFont, faFileAlt, faFileArchive,
faFolder, faHome, faInfoCircle, faLanguage, faLink, faList, faListAlt, faMapMarkerAlt, faPalette,
faFolder, faHistory, faHome, faInfoCircle, faLanguage, faLink, faList, faListAlt, faMapMarkerAlt, faPalette,
faQuestion, faQuestionCircle, faRedoAlt, faRss, faSearch, faShareAlt, faSkullCrossbones,
faSpinner, faTags, faThumbtack, faTimes, faTv, faUndo, faUser, faExternalLinkAlt,
} from '@fortawesome/free-solid-svg-icons';
Expand All @@ -24,7 +24,7 @@ let icons = [
faAdjust, faArrowsAltV, faBars, faBuilding, faCheckCircle, faChevronCircleDown,
faCode, faCoffee, faComments, faColumns, faCopy, faCopyright, faEdit, faEllipsisV,
faEnvelope, faExclamationTriangle, faExpandAlt, faEyeDropper, faFont, faFileAlt, faFileArchive,
faFolder, faHome, faInfoCircle, faLanguage, faLink, faList, faListAlt, faMapMarkerAlt, faPalette,
faFolder, faHistory, faHome, faInfoCircle, faLanguage, faLink, faList, faListAlt, faMapMarkerAlt, faPalette,
faQuestion, faQuestionCircle, faRedoAlt, faRss, faSearch, faShareAlt, faSkullCrossbones,
faSpinner, faTags, faThumbtack, faTimes, faTv, faUndo, faUser, faExternalLinkAlt,

Expand Down
6 changes: 6 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,9 @@ viewer = true # Image Viewer
endpoint = "https://getform.io/f/56041c81-9e03-4c24-b9c5-61238854d4cd" # Backend endpoint, remove this line if you're using Netlify.
# file = true # Enable file upload
# fileField = "image" # The name of file field.

[repo]
url = "https://github.com/razonyang/hugo-theme-bootstrap"
# branch = "main"
subPath = "exampleSite"
# dateFormat = "02/01/2006, 15:04:05 PM"
1 change: 1 addition & 0 deletions exampleSite/layouts/partials/hooks/docs/sidebar-end.html
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{{ partial "docs/repo" . }}
{{ partial "sidebar/recent-posts" . }}
9 changes: 9 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ other = "Recent Posts"
[related_posts]
other = "Related Posts"

[repo_action_edit]
other = "Edit this page"

[repo_action_view]
other = "View page source"

[repo_title]
other = "Repository"

[search]
other = "Search"

Expand Down
9 changes: 9 additions & 0 deletions i18n/zh-cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ other = "最近文章"
[related_posts]
other = "相关文章"

[repo_action_edit]
other = "编辑当前页"

[repo_action_view]
other = "查看源代码"

[repo_title]
other = "仓库"

[search]
other = "搜索"

Expand Down
9 changes: 9 additions & 0 deletions i18n/zh-hk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ other = "最近文章"
[related_posts]
other = "相關文章"

[repo_action_edit]
other = "編輯當前頁"

[repo_action_view]
other = "查看源代碼"

[repo_title]
other = "倉庫"

[search]
other = "搜索"

Expand Down
9 changes: 9 additions & 0 deletions i18n/zh-tw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ other = "最近文章"
[related_posts]
other = "相關文章"

[repo_action_edit]
other = "編輯當前頁"

[repo_action_view]
other = "查看源代碼"

[repo_title]
other = "倉庫"

[search]
other = "搜尋"

Expand Down
37 changes: 37 additions & 0 deletions layouts/partials/docs/repo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- with $.Site.Params.repo -}}
{{- $url := .url -}}
{{- $branch := default "master" .branch -}}
{{- $dateFormat := default "02/01/2006, 15:04:05 PM" .dateFormat -}}
{{- $subPath := default "" .subPath -}}
{{- if $subPath -}}{{ $subPath = printf "/%s" $subPath }}{{- end -}}
<div class="docs-repo row card component">
<div class="card-header">
<h2 class="card-title">{{ i18n "repo_title" }}</h2>
</div>
<div class="card-body">
<ul class="list-unstyled">
{{- if $.File -}}
{{- $filePath := printf "%s%s/content/%s" $branch $subPath $.File.Path -}}
<li>
<a href="{{ printf "%s/blob/%s" $url $filePath }}" target="_blank" rel="noopener noreferrer">
<i class="fas fa-fw fa-file-archive"></i> {{ i18n "repo_action_view" }}
</a>
</li>
<li>
<a href="{{ printf "%s/edit/%s" $url $filePath }}" target="_blank" rel="noopener noreferrer">
<i class="fas fa-fw fa-edit"></i> {{ i18n "repo_action_edit" }}
</a>
</li>
{{- end -}}
{{- with $.GitInfo -}}
<li>
<i class="fas fa-fw fa-code"></i> <a href="{{ printf "%s/commit/%s" $url .Hash }}" target="_blank" rel="noopener noreferrer">{{ .AbbreviatedHash }}</a>
</li>
<li>
<i class="fas fa-fw fa-history"></i> {{ .AuthorDate.Format $dateFormat }}
</li>
{{- end -}}
</ul>
</div>
</div>
{{- end -}}