From 9ca7243b8e1e14eb0cb5599fd391ca2afb0ea730 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Wed, 21 Jun 2017 13:43:23 -0500 Subject: [PATCH] implement the Github edit link --- exampleSite/hugo.yaml | 1 + layouts/partials/footer.html | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index b933d55..cdb1ba0 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -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: diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f603e17..fbef91c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -4,6 +4,17 @@
{{ 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}} + | Edit this page + {{ end }} + {{ end }}