From 15e14d207e5d374af6978d8137fa640119bb99b6 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/config.toml | 1 + layouts/partials/footer.html | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index f025105..947ad9d 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -34,4 +34,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 -- 2018 | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)" diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 3f46ea5..6a6687c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -4,6 +4,17 @@
{{ . | 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 }}