refactor: restructure config and front matter parameters

- contact widget: support custom contact links with `contact_links`
- talks: add `all_day`
- custom_css/js -> plugins_css/js
- load custom css/js from `assets/` dir instead of `static/`
- minify custom css/js
- convert publication types from config params to i18n translations
- projects: always list child items (config option deprecated)

BREAKING CHANGES: Refer to issue below.

See #867
This commit is contained in:
George Cushen committed 2019-01-26 20:36:15 +00:00
1 parent 8a7c4eb2aa
commit e913aacb34
15 files changed
+190 -181

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ draft = false
# End time can optionally be hidden by prefixing the line with `#`.
time_start = {{ .Date }}
time_end = {{ .Date }}
all_day = false
# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`.
authors = []
+83 -91
View File
@@ -24,123 +24,115 @@ twitter = ""
# To enable, place an image in `static/img/` and reference its filename below. To disable, set the value to "".
logo = ""
# 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"
# Examples: "3:04 pm" or "15:04"
time_format = "3:04 PM"
# Show estimated reading time for posts?
reading_time = true
# Display comment count? Requires commenting to be enabled.
comment_count = true
# Display next/previous section pager?
section_pager = false
# Enable global LaTeX math rendering?
# If false, you can enable it locally on a per page basis.
math = false
# Enable global source code highlighting? true/false
# Documentation: https://sourcethemes.com/academic/docs/writing-markdown-latex/#highlighting-options
highlight = true
# highlight_languages = ["r"] # Add support for highlighting additional languages
# highlight_style = "github" # For supported styles, see https://cdnjs.com/libraries/highlight.js/
# Enable in-built social sharing buttons?
sharing = true
# Enable global LaTeX math rendering?
# If false, you can enable it locally on a per page basis.
math = false
# Privacy pack
# Show a cookie consent message to visitors
# Anonymize IP in Google Analytics (if enabled)
privacy_pack = false
# 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"
# Examples: "3:04 pm" or "15:04"
time_format = "3:04 PM"
############################
## Contact Widget setup ##
############################
# Enter contact details (optional). To hide a field, clear it to "".
email = "test@example.org"
phone = "888 888 88 88"
address = "Building 1 Room 1, Stanford University, California, 90210, USA"
# Office hours: use `<br>` to insert a line break, or set to "" to remove office hours
office_hours = """Monday 10:00 to 13:00<br>
Wednesday 09:00 to 10:00<br>
Otherwise email to book an appointment"""
# Enter an optional link for booking appointments (e.g. calendly.com).
appointment_url = ""
# Contact links
# Set to `[]` to disable, or comment out unwanted lines with a hash `#`.
contact_links = [
{icon = "twitter", icon_pack = "fab", name = "DM Me", link = "https://twitter.com/Twitter"},
{icon = "skype", icon_pack = "fab", name = "Skype Me", link = "skype:echo123?call"},
{icon = "keybase", icon_pack = "fab", name = "Chat on Keybase", link = "https://keybase.io/"},
{icon = "comments", icon_pack = "fas", name = "Discuss on Forum", link = "https://discourse.gohugo.io"},
# {icon = "telegram", icon_pack = "fab", name = "Telegram Me", link = "https://telegram.me/@Telegram"},
]
# Display a map.
# To show your address on a map in the contact widget, you need to enter your latitude, longitude and choose
# a map provider below.
# To use Google Maps, set `map = 1` and enter your API key that can be obtained here:
# https://developers.google.com/maps/documentation/javascript/get-api-key
# To use OpenStreetMap tiles, set `map = 2`.
# To use OpenStreetMap on a high traffic site, set `map = 3` and enter your API key that can be obtained here:
# https://www.mapbox.com/studio/account/tokens
# To get your coordinates, right-click on Google Maps and choose "What's here?". The coords will show up at the bottom.
#
# Map provider:
# 0: No map
# 1: Google Maps
# 2: OpenStreetMap (Mapnik)
# 3: OpenStreetMap (Mapbox)
map = 0
map_api_key = ""
latitude = "37.4275"
longitude = "-122.1697"
zoom = 15
############################
## Plugins ##
############################
# Load CSS and JS plugins
# E.g. To load `/assets/css/custom.css`, set `plugins_css = ["custom"]`.
# E.g. To load `/assets/js/custom.js`, set `plugins_js = ["custom"]`.
plugins_css = []
plugins_js = []
############################
## Advanced options ##
############################
# Get user avatars from Gravatar.com? (true/false)
gravatar = false
# Contact Widget setup
email = "test@example.org"
address = "Building 1 Room 1, Stanford University, California, 90210, USA"
# Office hours: use `<br>` to insert a line break, or set to "" to remove office hours
office_hours = """Monday 10:00 to 13:00<br>
Wednesday 09:00 to 10:00<br>
Otherwise email to book an appointment"""
phone = "888 888 88 88"
skype = "echo123"
telegram = ""
keybase = "" # Your keybase.io username.
# Enter an optional link for booking appointments (e.g. calendly.com).
appointment_url = ""
# Discussion link (e.g. link to a forum, mailing list, or chat).
# Uncomment line below to use.
# discussion = { name = "Discuss", url = "https://discourse.gohugo.io" }
# Enable/disable map in Contact widget.
# To show your address on a map in the contact widget, you need to enter your latitude, longitude and choose
# a map provider below.
# To use Google Maps, set `map = 1` and enter your API key that can be obtained here:
# https://developers.google.com/maps/documentation/javascript/get-api-key
# To use OpenStreetMap tiles, set `map = 2`.
# To use OpenStreetMap on a high traffic site, set `map = 3` and enter your API key that can be obtained here:
# https://www.mapbox.com/studio/account/tokens
# To get your coordinates, right-click on Google Maps and choose "What's here?". The coords will show up at the bottom.
#
# Map provider:
# 0: No map
# 1: Google Maps
# 2: OpenStreetMap (Mapnik)
# 3: OpenStreetMap (Mapbox)
map = 0
map_api_key = ""
latitude = "37.4275"
longitude = "-122.1697"
zoom = 15
# Publication types.
# Used to categorize publications.
# The index of the publication type in the list is used as its unique numerical identifier.
# The numeric ID is used in a publication's frontmatter to categorize it.
# The language can be edited below.
# For multilingual sites, `publication_types` can be copied to each language section at the end of this file and
# translated.
publication_types = [
'Uncategorized', # 0
'Conference paper', # 1
'Journal article', # 2
'Manuscript', # 3
'Report', # 4
'Book', # 5
'Book section' # 6
]
# Align the main menu to the right of the page? (true/false)
menu_align_right = false
# Link custom CSS and JS assets
# (relative to /static/css and /static/js respectively)
custom_css = []
custom_js = []
# Show estimated reading time for posts? (true/false)
reading_time = true
# Configuration of talk pages.
[talks]
# Show talk time?
time = true
# Display comment count (if commenting enabled in config.toml)? (true/false)
comment_count = true
# Display next/previous section pager? (true/false)
section_pager = false
# Enable in-built social sharing buttons? (true/false)
sharing = true
# Configuration of publication pages.
[publications]
# Date format (refer to https://sourcethemes.com/academic/docs/customization/#date-format )
# Examples: "Mon, Jan 2, 2006" or "2006-01-02"
date_format = "January, 2006"
date_format = "January 2006"
# Configuration of project pages.
[projects]
# List publications and talks related to the project?
list_children = true
# Post list format.
# 0 = Simple
# 1 = Detailed
@@ -165,7 +157,7 @@ custom_js = []
[search]
# Search provider:
# 0: No search engine
# 1: Built-in (Fuse)
# 1: Academic (built-in)
# 2: Algolia (https://www.algolia.com)
engine = 1
@@ -7,6 +7,7 @@ draft = false
# End time can optionally be hidden by prefixing the line with `#`.
time_start = 2030-06-01T13:00:00
time_end = 2030-06-01T15:00:00
all_day = false
# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`.
authors = []
+21
View File
@@ -143,6 +143,27 @@
- id: location
translation: Location
- id: pub_uncat
translation: Uncategorized
- id: pub_conf
translation: Conference paper
- id: pub_journal
translation: Journal article
- id: pub_manuscript
translation: Manuscript
- id: pub_report
translation: Report
- id: pub_book
translation: Book
- id: pub_book_section
translation: Book section
# Filtering
- id: filter_by_type
+3 -4
View File
@@ -140,13 +140,12 @@
{{ else }}
{{ $js_bundle = slice $js_academic }}
{{ end }}
{{ range .Site.Params.plugins_js }}
{{ $js_bundle = $js_bundle | append (resources.Get (printf "js/%s.js" .)) }}
{{ end }}
{{ $js_bundle := $js_bundle | resources.Concat "js/academic-bundle-pre.js" | minify }}
{{ $js_bundle := slice $js_bundle_head $js_bundle | resources.Concat "js/academic.min.js" | fingerprint "md5" }}
<script src="{{ $js_bundle.RelPermalink }}"></script>
{{ range .Site.Params.custom_js }}
<script src="{{ "/js/" | relURL }}{{ . }}"></script>
{{ end }}
</body>
</html>
+10 -2
View File
@@ -101,8 +101,16 @@
{{ end }}
<link rel="stylesheet" href="{{ "styles.css" | relLangURL }}">
{{ range .Site.Params.custom_css }}
<link rel="stylesheet" href="{{ "/css/" | relURL }}{{ . }}">
{{ if .Site.Params.plugins_css }}
{{ $css_comment := printf "/* Source Themes Academic v%s | https://sourcethemes.com/academic/ */\n" .Site.Data.academic.version }}
{{ $css_bundle_head := $css_comment | resources.FromString "css/bundle-head.css" }}
{{ $css_bundle := slice }}
{{ range .Site.Params.plugins_css }}
{{ $css_bundle = $css_bundle | append (resources.Get (printf "css/%s.css" .)) }}
{{ end }}
{{ $css_bundle := $css_bundle | resources.Concat "css/academic-bundle-pre.css" | minify }}
{{ $css_bundle := slice $css_bundle_head $css_bundle | resources.Concat "css/academic.css" | fingerprint "md5" }}
<link rel="stylesheet" href="{{ $css_bundle.RelPermalink }}">
{{ end }}
{{ if not .Site.IsServer }}
+1
View File
@@ -0,0 +1 @@
{{ $.Scratch.Set "pub_types" (slice (i18n "pub_uncat" | default "Uncategorized") (i18n "pub_conf" | default "Conference paper") (i18n "pub_journal" | default "Journal article") (i18n "pub_manuscript" | default "Manuscript") (i18n "pub_report" | default "Report") (i18n "pub_book" | default "Book") (i18n "pub_book_section" | default "Book section") ) }}
+1 -1
View File
@@ -18,7 +18,7 @@
<div class="talk-metadata" itemprop="startDate">
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
{{ if $.Site.Params.talks.time }}
{{ if not .Params.all_day }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ with .Params.time_end }}
&mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
+1 -1
View File
@@ -4,7 +4,7 @@
<div itemprop="startDate">
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
{{ if $.Site.Params.talks.time }}
{{ if not .Params.all_day }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ end }}
</div>
+1 -1
View File
@@ -23,7 +23,7 @@
<div>
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
{{ if $.Site.Params.talks.time }}
{{ if not .Params.all_day }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ with .Params.time_end }}
&mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
+21 -36
View File
@@ -53,24 +53,6 @@
</li>
{{ end }}
{{ with $.Site.Params.discussion }}
<li>
<i class="fa-li fas fa-comments fa-2x" aria-hidden="true"></i>
<span>
<a href="{{ .url }}" target="_blank" rel="noopener">{{ .name }}</a>
</span>
</li>
{{ end }}
{{ with $.Site.Params.keybase }}
<li>
<i class="fa-li fab fa-keybase fa-2x" aria-hidden="true"></i>
<span>
<a href="https://keybase.io/{{ . }}" target="_blank" rel="noopener">@{{ . }}</a> on Keybase.
</span>
</li>
{{ end }}
{{ with $.Site.Params.phone }}
<li>
<i class="fa-li fas fa-phone fa-2x" aria-hidden="true"></i>
@@ -80,24 +62,6 @@
</li>
{{ end }}
{{ with $.Site.Params.skype }}
<li>
<i class="fa-li fab fa-skype fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="skype:{{ . }}?call">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.telegram }}
<li>
<i class="fa-li fab fa-telegram fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="https://telegram.me/{{ . }}" target="_blank" rel="noopener">@{{ . }}</a>{{ else }}@{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.address }}
<li>
<i class="fa-li fas fa-map-marker fa-2x" aria-hidden="true"></i>
@@ -119,6 +83,27 @@
</li>
{{ end }}
{{/* Contact links. */}}
{{ range $.Site.Params.contact_links }}
{{ $pack := or .icon_pack "fas" }}
{{ $pack_prefix := $pack }}
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
{{ $pack_prefix = "fa" }}
{{ end }}
{{ $link := .link }}
{{ $scheme := (urls.Parse $link).Scheme }}
{{ $target := "" }}
{{ if not $scheme }}
{{ $link = .link | relLangURL }}
{{ else if in (slice "http" "https") $scheme }}
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
<li>
<i class="fa-li {{ $pack }} {{ $pack_prefix }}-{{ .icon }} fa-2x" aria-hidden="true"></i>
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>{{.name|markdownify|emojify|safeHTML}}</a>
</li>
{{ end }}
</ul>
{{ if $.Site.Params.map }}
+39 -42
View File
@@ -17,54 +17,51 @@
{{ $page := . }}
{{ $project := .File.ContentBaseName }}
{{ if (.Site.Params.projects.list_children | default true) }}
{{ $items := where (where .Site.RegularPages "Type" "post") ".Params.projects" "intersect" (slice $project) }}
{{ $count := len $items }}
{{ if ge $count 1 }}
<h2>{{ (i18n "posts") }}</h2>
{{ range $items }}
{{ if eq $page.Site.Params.projects.post_format 0 }}
{{ partial "post_li_simple" . }}
{{ else if eq $page.Site.Params.projects.post_format 1 }}
{{ partial "post_li_detailed" . }}
{{ else }}
{{ partial "post_li_stream" . }}
{{ end }}
{{ $items := where (where .Site.RegularPages "Type" "post") ".Params.projects" "intersect" (slice $project) }}
{{ $count := len $items }}
{{ if ge $count 1 }}
<h2>{{ (i18n "posts") }}</h2>
{{ range $items }}
{{ if eq $page.Site.Params.projects.post_format 0 }}
{{ partial "post_li_simple" . }}
{{ else if eq $page.Site.Params.projects.post_format 1 }}
{{ partial "post_li_detailed" . }}
{{ else }}
{{ partial "post_li_stream" . }}
{{ end }}
{{ end }}
{{ end }}
{{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
{{ $pubs_len := len $items }}
{{ if ge $pubs_len 1 }}
<h2>{{ (i18n "publications") }}</h2>
{{ range $items }}
{{ if eq $page.Site.Params.projects.publication_format 1 }}
{{ partial "publication_li_detailed" . }}
{{ else if eq $page.Site.Params.projects.publication_format 2 }}
{{ partial "publication_li_apa" . }}
{{ else if eq $page.Site.Params.projects.publication_format 3 }}
{{ partial "publication_li_mla" . }}
{{ else if eq $page.Site.Params.projects.publication_format 4 }}
{{ partial "publication_li_stream" . }}
{{ else }}
{{ partial "publication_li_simple" . }}
{{ end }}
{{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
{{ $pubs_len := len $items }}
{{ if ge $pubs_len 1 }}
<h2>{{ (i18n "publications") }}</h2>
{{ range $items }}
{{ if eq $page.Site.Params.projects.publication_format 1 }}
{{ partial "publication_li_detailed" . }}
{{ else if eq $page.Site.Params.projects.publication_format 2 }}
{{ partial "publication_li_apa" . }}
{{ else if eq $page.Site.Params.projects.publication_format 3 }}
{{ partial "publication_li_mla" . }}
{{ else if eq $page.Site.Params.projects.publication_format 4 }}
{{ partial "publication_li_stream" . }}
{{ else }}
{{ partial "publication_li_simple" . }}
{{ end }}
{{ end }}
{{ end }}
{{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }}
{{ $talks_len := len $items }}
{{ if ge $talks_len 1 }}
<h2>{{ (i18n "talks") }}</h2>
{{ range sort $items ".Params.time_start" "desc" }}
{{ if eq $page.Site.Params.projects.talk_format 1 }}
{{ partial "talk_li_detailed" . }}
{{ else if eq $page.Site.Params.projects.talk_format 2 }}
{{ partial "talk_li_stream" . }}
{{ else }}
{{ partial "talk_li_simple" . }}
{{ end }}
{{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }}
{{ $talks_len := len $items }}
{{ if ge $talks_len 1 }}
<h2>{{ (i18n "talks") }}</h2>
{{ range sort $items ".Params.time_start" "desc" }}
{{ if eq $page.Site.Params.projects.talk_format 1 }}
{{ partial "talk_li_detailed" . }}
{{ else if eq $page.Site.Params.projects.talk_format 2 }}
{{ partial "talk_li_stream" . }}
{{ else }}
{{ partial "talk_li_simple" . }}
{{ end }}
{{ end }}
{{ end }}
+3 -1
View File
@@ -18,9 +18,11 @@
<div class="row">
<div class="col-12 col-md-3 pub-row-heading">{{ i18n "publication_type" }}</div>
<div class="col-12 col-md-9">
{{ partial "pub_types.html" $ }}
{{ $pub_types := $.Scratch.Get "pub_types" }}
{{ range $index, $pubtype := .Params.publication_types }}
<a href="{{ ($.Site.GetPage "section" "publication").RelPermalink }}#{{ . | urlize }}">
{{ index $.Site.Params.publication_types (int .) }}
{{ index $pub_types (int .) }}
</a>
{{ end }}
</div>
+3 -1
View File
@@ -24,9 +24,11 @@
<div class="col-auto">
<select class="pub-filters pubtype-select form-control form-control-sm" data-filter-group="pubtype">
<option value="*">{{ i18n "filter_all" }}</option>
{{ partial "pub_types.html" $ }}
{{ range $index, $taxonomy := .Site.Taxonomies.publication_types }}
<option value=".pubtype-{{ (int $index) }}">
{{ index $.Site.Params.publication_types (int $index) }}
{{ $pub_types := $.Scratch.Get "pub_types" }}
{{ index $pub_types (int $index) }}
</option>
{{ end }}
</select>
+1 -1
View File
@@ -22,7 +22,7 @@
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
<div class="talk-time">
{{ if $.Site.Params.talks.time }}
{{ if not .Params.all_day }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ with .Params.time_end }}
&mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}