Skip to content

Commit 8ace9bb

Browse files
committed
implement the Github edit link
1 parent fd18007 commit 8ace9bb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

exampleSite/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ footnotereturnlinkcontents = "↩"
3333

3434
[params]
3535
description = "A website built through Hugo and blogdown."
36+
GithubEdit = "https://github.com/yihui/hugo-xmin/edit/feature/github-edit/exampleSite/content/"
3637
footer = "© [Yihui Xie](https://yihui.name) 2017 | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)"

layouts/partials/footer.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
<hr/>
55
{{ . | markdownify }}
66
{{ end }}
7+
{{ if .File.Path }}
8+
{{ $RmdFile := (print .File.BaseFileName ".Rmd") }}
9+
{{ if (where (readDir (print "content/" .File.Dir)) "Name" $RmdFile) }}
10+
{{ $.Scratch.Set "FilePath" (print .File.Dir $RmdFile) }}
11+
{{ else }}
12+
{{ $.Scratch.Set "FilePath" .File.Path }}
13+
{{ end }}
14+
{{ with .Site.Params.GithubEdit}}
15+
| <a href="{{ . }}{{ $.Scratch.Get "FilePath" }}">Edit this page</a>
16+
{{ end }}
17+
{{ end }}
718
</footer>
819
</body>
920
</html>

0 commit comments

Comments
 (0)