Skip to content

Commit

Permalink
Source and report links (#396)
Browse files Browse the repository at this point in the history
* add report issue link

* improve code

* remove useless line

* change translations
  • Loading branch information
eyllanesc authored Dec 17, 2021
1 parent 3817a60 commit 111a01b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
2 changes: 1 addition & 1 deletion exampleSite/assets/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"baseUrl": ".",
"paths": {
"*": [
"..\\..\\assets\\*"
"../../assets/*"
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,18 @@ enableEmoji = true
# whether to show link to Raw Markdown content of the content
# 是否显示原始 Markdown 文档内容的链接
linkToMarkdown = true
# configure the link to view source the post
linkToSource = "https://github.com/HEIGE-PCloud/DoIt/blob/main/exampleSite/content/{path}"
# configure the link to edit the post
# 配置编辑文章的链接
linkToEdit = "https://github.com/HEIGE-PCloud/DoIt/edit/main/exampleSite/content/{path}"
# https://github.com/user/repo/edit/main/{path}
# https://gitlab.com/user/repo/-/edit/main/{path}
# https://bitbucket.org/user/repo/src/main/{path}?mode=edit
# configure the link to report issue the post
linkToReport = "https://github.com/HEIGE-PCloud/DoIt/issues/new?title=[bug]%20{title}&body=|Field|Value|%0A|-|-|%0A|Title|{title}|%0A|Url|{url}|%0A|Filename|https://github.com/HEIGE-PCloud/DoIt/blob/main/exampleSite/content/{path}|"
# https://github.com/user/repo/issues/new?title=[bug]%20{title}&body=|Field|Value|%0A|-|-|%0A|Title|{title}|%0A|Url|{url}|%0A|Filename|https://github.com/user/repo/blob/main/{path}|"
# https://gitlab.com/user/repo/-/issues/new?issue[title]=[bug]%20{title}&issue[description]=|Field|Value|%0A|-|-|%0A|Title|{title}|%0A|Url|{url}|%0A|Filename|https://gitlab.com/user/repo/-/edit/main/{path}|
# whether to show the full text content in RSS
# 是否在 RSS 中显示全文内容
rssFullText = false
Expand Down
8 changes: 7 additions & 1 deletion i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,17 @@ other = "Author"
other = "Updated on {{ .Date }}"

[readMarkdown]
other = "Read Markdown"
other = "Read markdown"

[viewSource]
other = "View source"

[editThisPage]
other = "Edit this page"

[reportThisPage]
other = "Report issue"

[back]
other = "Back"

Expand Down
6 changes: 6 additions & 0 deletions i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ other = "更新于 {{ .Date }}"
[readMarkdown]
other = "阅读原始文档"

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

[editThisPage]
other = "编辑此页"

[reportThisPage]
other = "报告问题"

[back]
other = "返回"

Expand Down
50 changes: 32 additions & 18 deletions layouts/partials/single/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,40 @@
</div>
<div class="post-info-line">
<div class="post-info-md">
{{- if $params.linktomarkdown -}}
{{- with .OutputFormats.Get "markdown" -}}
<span>
<a class="link-to-markdown" href="{{ .RelPermalink }}" target="_blank" rel="noopener noreferrer">
{{- T "readMarkdown" -}}
</a>
</span>
{{- if .IsPage -}}
{{- $post_info := slice -}}
{{- if $params.linktomarkdown -}}
{{- with .OutputFormats.Get "markdown" -}}
{{- $d := dict "class" "link-to-mardown" "link" .RelPermalink "text" "readMarkdown" -}}
{{- $post_info = $post_info | append $d -}}
{{- end -}}
{{- end -}}
{{- with $params.linktosource -}}
{{- $link := replace . "{path}" $.File.Path -}}
{{- $d := dict "class" "link-to-source" "link" $link "text" "viewSource" -}}
{{- $post_info = $post_info | append $d -}}
{{- end -}}
{{- end -}}
{{- if $params.linktomarkdown | and (.OutputFormats.Get "markdown") | and .IsPage | and $params.linktoedit -}}
|&nbsp;
{{- end -}}
{{- if .IsPage -}}
{{- with $params.linktoedit -}}
<span>
{{- $link := replace . "{path}" $.File.Path -}}
<a class="link-to-edit" {{ printf "href=%v" $link | safeHTMLAttr }} target="_blank" rel="noopener noreferrer">
{{- T "editThisPage" -}}
</a>
</span>
{{- $link := replace . "{path}" $.File.Path -}}
{{- $d := dict "class" "link-to-edit" "link" $link "text" "editThisPage" -}}
{{- $post_info = $post_info | append $d -}}
{{- end -}}
{{- with $params.linktoreport -}}
{{- $link := replace . "{title}" ($.Title | urlquery) -}}
{{- $link := replace $link "{url}" $.Permalink -}}
{{- $link := replace $link "{path}" $.File.Path -}}
{{- $d := dict "class" "link-to-report" "link" $link "text" "reportThisPage" -}}
{{- $post_info = $post_info | append $d -}}
{{- end -}}
{{- range $index, $value := $post_info -}}
<span>
{{- if gt $index 0 -}}
|&nbsp;
{{- end -}}
<a class="{{ $value.class }}" {{ printf "href=%v" $value.link | safeHTMLAttr }} target="_blank" rel="noopener noreferrer">
{{- T $value.text -}}
</a>
</span>
{{- end -}}
{{- end -}}
</div>
Expand Down

1 comment on commit 111a01b

@vercel
Copy link

@vercel vercel bot commented on 111a01b Dec 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.