Skip to content

Commit

Permalink
implement the Github edit link
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Mar 4, 2024
1 parent b76b60e commit 9ca7243
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions exampleSite/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ menu:
params:
description: "A website built through Hugo and blogdown."
footer: "© [Yihui Xie](https://yihui.org) 2017 -- {Year} | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)"
GithubEdit: "https://github.com/yihui/hugo-xmin/edit/feature/github-edit/exampleSite/content/"

markup:
highlight:
Expand Down
11 changes: 11 additions & 0 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
<hr/>
{{ replace . "{Year}" now.Year | markdownify}}
{{ end }}
{{ if .File.Path }}
{{ $RmdFile := (print .File.BaseFileName ".Rmd") }}
{{ if (where (readDir (print "content/" .File.Dir)) "Name" $RmdFile) }}
{{ $.Scratch.Set "FilePath" (print .File.Dir $RmdFile) }}
{{ else }}
{{ $.Scratch.Set "FilePath" .File.Path }}
{{ end }}
{{ with .Site.Params.GithubEdit}}
| <a href="{{ . }}{{ $.Scratch.Get "FilePath" }}">Edit this page</a>
{{ end }}
{{ end }}
</footer>
</body>
</html>

0 comments on commit 9ca7243

Please sign in to comment.