feat: enable pages to be edited on GitHub

`edit_page` option can be added to `params.toml`. For example,
`edit_page = {repo_url = "https://github.com/gcushen/hugo-academic", editable = {docs = true}}`

Currently works for GitHub repos and pages using the `docs` layout.
This commit is contained in:
George Cushen committed 2019-07-08 13:13:32 +01:00
1 parent 8ddf0ca406
commit 0810ee024f
4 files changed
+20 -5

No files matched your search

+7 -3
View File
@@ -2,13 +2,13 @@
# Documentation: https://sourcethemes.com/academic/
# Color theme.
# Choose from `default`, `ocean`, `forest`, `dark`, `apogee`, `1950s`, `coffee`, `cupcake`, `strawberry`.
# Choose from `default`, `ocean`, `forest`, `dark`, `apogee`, `1950s`, `coffee`, `rose`, `strawberry`, `mr_robot`.
color_theme = "default"
# Enable users to switch between day and night mode?
day_night = true
# Font style.
# Choose from `default`, `classic`, or `playfair`.
# Choose from `default`, `classic`, `rose`, or `mr_robot`.
font = "default"
# Description for social sharing and search engines. If undefined, superuser role is used in place.
@@ -39,6 +39,10 @@ math = false
# Anonymize IP in Google Analytics (if enabled)
privacy_pack = false
# Enable visitors to edit pages?
# `repo` defines the repository URL. `editable` defines which page types can be edited.
edit_page = {repo_url = "https://github.com/gcushen/hugo-academic", editable = {docs = true}}
# Date and time format (refer to https://sourcethemes.com/academic/docs/customization/#date-format )
# Examples: "Mon, Jan 2, 2006" or "2006-01-02"
date_format = "Jan 2, 2006"
@@ -86,7 +90,7 @@ contact_links = [
# 1: Google Maps
# 2: OpenStreetMap (Mapnik)
# 3: OpenStreetMap (Mapbox)
map = 0
map = 2
map_api_key = ""
latitude = "37.4275"
longitude = "-122.1697"
+3
View File
@@ -29,6 +29,9 @@
- id: figure
translation: "Figure %d:"
- id: edit_page
translation: Edit this page
# Buttons
- id: btn_preprint
+1 -1
View File
@@ -3,7 +3,7 @@
{{ partial "site_head.html" . }}
<body id="top" data-spy="scroll" data-target="{{ if or .IsHome (eq .Type "widget_page") }}#navbar-main{{else}}#TableOfContents{{end}}" data-offset="71" {{ if not (.Scratch.Get "light") }}class="dark"{{end}}>
<body id="top" data-spy="scroll" data-target="{{ if or .IsHome (eq .Type "widget_page") }}#navbar-main{{else}}#TableOfContents{{end}}" data-offset="70" {{ if not (.Scratch.Get "light") }}class="dark"{{end}}>
{{ partial "search" . }}
+9 -1
View File
@@ -39,7 +39,15 @@
</div>
<div class="body-footer">
{{ i18n "last_updated" }} {{ $.Lastmod.Format site.Params.date_format }}
<p>{{ i18n "last_updated" }} {{ $.Lastmod.Format site.Params.date_format }}</p>
{{ if site.Params.edit_page.repo_url | and site.Params.edit_page.editable.docs | and (ne .Params.editable false) | or .Params.editable }}
<p class="edit-page">
<a href="{{site.Params.edit_page.repo_url}}/blob/master/content/{{.File.Path}}">
<i class="fas fa-pen pr-2"></i>{{ i18n "edit_page" | default "Edit this page" }}
</a>
</p>
{{ end }}
</div>
</article>