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 Jun 21, 2017
1 parent fd18007 commit ab6500e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ footnotereturnlinkcontents = "↩"

[params]
description = "A website built through Hugo and blogdown."
GithubEdit = "https://github.com/yihui/hugo-xmin/edit/feature/github-edit/exampleSite/content/"
footer = "© [Yihui Xie](https://yihui.name) 2017 | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)"
10 changes: 10 additions & 0 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
<hr/>
{{ . | markdownify }}
{{ end }}
{{ if .File.Path }}
{{ if (where (readDir (print "content/" .File.Dir)) "Name" (print .File.BaseFileName ".Rmd")) }}
{{ $.Scratch.Set "FilePath" (print .File.Dir .File.BaseFileName ".Rmd") }}
{{ 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 ab6500e

Please sign in to comment.