refactor: homepage sections as headless leaf nodes

See #970
This commit is contained in:
George Cushen committed 2019-03-17 20:31:20 +00:00
1 parent 839e198c7f
commit ea4621aedb
26 files changed
+80 -59

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
+++ +++
# About/Biography widget. # About widget.
widget = "about" # Do not modify this line! widget = "about" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 20 # Order that this section will appear in. weight = 20 # Order that this section will appear in.
+2 -1
View File
@@ -1,6 +1,7 @@
+++ +++
# Accomplishments widget. # Accomplishments widget.
widget = "accomplishments" # Do not modify this line! widget = "accomplishments" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 50 # Order that this section will appear. weight = 50 # Order that this section will appear.
+3 -4
View File
@@ -1,14 +1,13 @@
+++ +++
# Contact widget. # Contact widget.
widget = "contact" # Do not modify this line! widget = "contact" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 130 # Order that this section will appear.
title = "Contact" title = "Contact"
subtitle = "" subtitle = ""
# Order that this section will appear in.
weight = 130
# Automatically link email and phone? # Automatically link email and phone?
autolink = true autolink = true
+2 -2
View File
@@ -3,11 +3,11 @@
# Any elements can be added in the body: https://sourcethemes.com/academic/docs/writing-markdown-latex/ # Any elements can be added in the body: https://sourcethemes.com/academic/docs/writing-markdown-latex/
# Add more sections by duplicating this file and customizing to your requirements. # Add more sections by duplicating this file and customizing to your requirements.
widget = "blank" # Do not modify this line! widget = "blank" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 15 # Order that this section will appear. weight = 15 # Order that this section will appear.
# Note: a full width section format can be enabled by commenting out the `title` and `subtitle` with a `#`.
title = "Demos" title = "Demos"
subtitle = "" subtitle = ""
+2 -1
View File
@@ -1,6 +1,7 @@
+++ +++
# Experience widget. # Experience widget.
widget = "experience" # Do not modify this line! widget = "experience" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 40 # Order that this section will appear. weight = 40 # Order that this section will appear.
+2 -1
View File
@@ -3,7 +3,8 @@
# This section displays publications from `content/publication/` which have # This section displays publications from `content/publication/` which have
# `featured = true` in their front matter. # `featured = true` in their front matter.
widget = "featured" # Do not modify this line! widget = "featured" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 80 # Order that this section will appear. weight = 80 # Order that this section will appear.
+4 -6
View File
@@ -1,14 +1,12 @@
+++ +++
# Custom widget. # Gallery section using the Blank widget and Gallery element (shortcode).
widget = "custom" # Do not modify this line! widget = "blank" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 66 # Order that this section will appear.
# Note: a full width section format can be enabled by commenting out the `title` and `subtitle` with a `#`.
title = "Gallery" title = "Gallery"
subtitle = "" subtitle = ""
# Order that this section will appear in.
weight = 66
+++ +++
{{< gallery >}} {{< gallery >}}
+2 -1
View File
@@ -1,6 +1,7 @@
+++ +++
# Hero widget. # Hero widget.
widget = "hero" # Do not modify this line! widget = "hero" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 10 # Order that this section will appear. weight = 10 # Order that this section will appear.
+5
View File
@@ -0,0 +1,5 @@
+++
# Homepage
type = "widget_page"
headless = true # Homepage is headless, other widget pages are not.
+++
+3 -4
View File
@@ -1,14 +1,13 @@
+++ +++
# People widget. # People widget.
widget = "people" # Do not modify this line! widget = "people" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = false # Activate this widget? true/false active = false # Activate this widget? true/false
weight = 68 # Order that this section will appear.
title = "People" title = "People"
subtitle = "" subtitle = ""
# Order that this section will appear in.
weight = 68
# List user groups to display. # List user groups to display.
# Edit each user's `user_groups` to add them to one or more of these groups. # Edit each user's `user_groups` to add them to one or more of these groups.
user_groups = ["Principal Investigators", user_groups = ["Principal Investigators",
+2 -1
View File
@@ -2,7 +2,8 @@
# A Recent Blog Posts section created with the Pages widget. # A Recent Blog Posts section created with the Pages widget.
# This section displays recent blog posts from `content/post/`. # This section displays recent blog posts from `content/post/`.
widget = "pages" # Do not modify this line! widget = "pages" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 60 # Order that this section will appear. weight = 60 # Order that this section will appear.
+3 -2
View File
@@ -1,6 +1,7 @@
+++ +++
# Portfolio widget. # A Projects section created with the Portfolio widget.
widget = "portfolio" # Do not modify this line! widget = "portfolio" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 65 # Order that this section will appear. weight = 65 # Order that this section will appear.
+2 -1
View File
@@ -2,7 +2,8 @@
# A Recent Publications section created with the Pages widget. # A Recent Publications section created with the Pages widget.
# This section displays recent blog posts from `content/publication/`. # This section displays recent blog posts from `content/publication/`.
widget = "pages" # Do not modify this line! widget = "pages" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 90 # Order that this section will appear. weight = 90 # Order that this section will appear.
+4 -5
View File
@@ -1,14 +1,13 @@
+++ +++
# Feature/Skill widget. # A Skills section created with the Featurette widget.
widget = "featurette" # Do not modify this line! widget = "featurette" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 30 # Order that this section will appear.
title = "Skills" title = "Skills"
subtitle = "" subtitle = ""
# Order that this section will appear in.
weight = 30
# Showcase personal skills or business features. # Showcase personal skills or business features.
# #
# Add/remove as many `[[feature]]` blocks below as you like. # Add/remove as many `[[feature]]` blocks below as you like.
+3 -4
View File
@@ -1,10 +1,9 @@
+++ +++
# Slider widget. # Slider widget.
widget = "slider" # Do not modify this line! widget = "slider" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = false # Activate this widget? true/false active = false # Activate this widget? true/false
weight = 1 # Order that this section will appear.
# Order that this section will appear in.
weight = 1
# Slide interval. # Slide interval.
# Use `false` to disable animation or enter a time in ms, e.g. `5000` (5s). # Use `false` to disable animation or enter a time in ms, e.g. `5000` (5s).
+3 -4
View File
@@ -1,11 +1,10 @@
+++ +++
# Tag Cloud widget. # Tag Cloud widget.
widget = "tag_cloud" # Do not modify this line! widget = "tag_cloud" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 120 # Order that this section will appear.
title = "Popular Topics" title = "Popular Topics"
subtitle = "" subtitle = ""
# Order that this section will appear in.
weight = 120
+++ +++
+2 -1
View File
@@ -2,7 +2,8 @@
# A Recent and Upcoming Talks section created with the Pages widget. # A Recent and Upcoming Talks section created with the Pages widget.
# This section displays recent talks from `content/talk/`. # This section displays recent talks from `content/talk/`.
widget = "pages" # Do not modify this line! widget = "pages" # See https://sourcethemes.com/academic/docs/page-builder/
headless = true # This file represents a page section.
active = true # Activate this widget? true/false active = true # Activate this widget? true/false
weight = 70 # Order that this section will appear. weight = 70 # Order that this section will appear.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+1 -1
View File
@@ -1,6 +1,6 @@
{{- /* Generate the search index. */ -}} {{- /* Generate the search index. */ -}}
{{- $index := slice -}} {{- $index := slice -}}
{{- $pages := where .Site.RegularPages "Section" "!=" "home" -}} {{- $pages := .Site.RegularPages -}}
{{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}} {{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}}
{{- $pages := $pages | union (where (where .Site.Pages "Kind" "section") "Type" "docs") -}} {{- $pages := $pages | union (where (where .Site.Pages "Kind" "section") "Type" "docs") -}}
{{- /* Add author pages to index so their bios can be searched. Hide empty `/author/` node. */ -}} {{- /* Add author pages to index so their bios can be searched. Hide empty `/author/` node. */ -}}
+11 -7
View File
@@ -4,15 +4,17 @@
<!-- Flag for jQuery --> <!-- Flag for jQuery -->
<span id="homepage" class="d-none"></span> <span id="homepage" class="d-none"></span>
{{ $section := "" }} {{/* Get widget page path */}}
{{ $page := "" }}
{{ if .IsHome }} {{ if .IsHome }}
{{ $section = "home" }} {{ $page = "/home" }}
{{ else }} {{ else }}
{{ $section = .Section }} {{ $page = .File.Path }}
{{ end }} {{ end }}
<!-- Widgets --> {{/* Load page sections */}}
{{ range $index, $st := where (where .Data.Pages "Section" $section) ".Params.active" "!=" false }} {{ $headless_bundle := .Site.GetPage $page }}
{{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
{{/* Begin widget styling */}} {{/* Begin widget styling */}}
{{ $bg := $st.Params.design.background }} {{ $bg := $st.Params.design.background }}
{{ $style := "" }} {{ $style := "" }}
@@ -39,14 +41,17 @@
{{ end }} {{ end }}
{{ $params := dict "root" $ "page" $st }} {{ $params := dict "root" $ "page" $st }}
{{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
{{ $widget := or $st.Params.widget "blank" }} {{ $widget := or $st.Params.widget "blank" }}
{{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}} {{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
{{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}} {{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
{{ $widget_path := printf "widgets/%s.html" $widget }} {{ $widget_path := printf "widgets/%s.html" $widget }}
{{ if in (slice "slider") $widget }} {{ if in (slice "slider") $widget }}
{{ partial $widget_path $params }} {{ partial $widget_path $params }}
{{ else }} {{ else }}
<section id="{{ $st.File.TranslationBaseName }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $st.Params.advanced.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}> <section id="{{ $hash_id }}" class="home-section {{ printf "wg-%s" (replace $widget "_" "-") }} {{if $bg.text_color_light}}dark{{end}} {{if $bg.image}}parallax{{end}} {{ with $st.Params.advanced.css_class }}{{ . }}{{ end }}" {{with $style}}style="{{. | safeCSS}}"{{end}}>
<div class="container"> <div class="container">
{{ partial $widget_path $params }} {{ partial $widget_path $params }}
</div> </div>
@@ -54,6 +59,5 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
<!-- Page Footer -->
{{ partial "footer_container.html" . }} {{ partial "footer_container.html" . }}
{{ partial "footer.html" . }} {{ partial "footer.html" . }}
+2 -2
View File
@@ -3,14 +3,14 @@
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title> <title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description> <description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} <generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }} <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<atom:link href="{{.URL}}" rel="self" type="application/rss+xml" /> <atom:link href="{{.URL}}" rel="self" type="application/rss+xml" />
{{ range first 15 (where .Data.Pages "Type" "!=" "home") }} {{ range first 15 .Data.Pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
View File
Whitespace-only changes.
+17 -6
View File
@@ -1,11 +1,22 @@
{{ $album := "gallery" }} {{/* Get album folder or default to `gallery/`. */}}
{{ with .Get "album" }}{{ $album = . }}{{ end }} {{ $album := "" }}
{{ $album_path := printf "%s/*" $album }} {{ with .Get "album" }}{{ $album = . }}{{else}}{{ $album = "gallery" }}{{end}}
{{/* if eq .Page.Type "home" */}}{{/* $album_path = "*" */}}{{/* end */}}
{{/* Set image path and page bundle that images are associated with. */}}
{{ $album_path := "" }}
{{ $resource_page := "" }}
{{ if eq .Page.Parent.Type "widget_page" }}
{{ $album_path = printf "%s/%s/*" (path.Base (path.Split .Page.Path).Dir) $album }}
{{ $resource_page = $.Page.Parent }}
{{ else }}
{{ $album_path = printf "%s/*" $album }}
{{ $resource_page = $.Page }}
{{ end }}
<div class="gallery"> <div class="gallery">
{{/* Attempt to automatically load gallery images from page bundle */}} {{/* Attempt to automatically load gallery images from page bundle */}}
{{ $images := ($.Page.Resources.ByType "image").Match $album_path }} {{ $images := ($resource_page.Resources.ByType "image").Match $album_path }}
{{ with $images }} {{ with $images }}
{{ range $images }} {{ range $images }}
{{ $image := .Resize "x190" }} {{ $image := .Resize "x190" }}
@@ -39,7 +50,7 @@
</a> </a>
{{end}} {{end}}
{{else}} {{else}}
{{ errorf "Unable to load gallery in %s." .Page.Filename }} {{ errorf "Unable to load gallery in %s." .Page.Filename }}
{{end}} {{end}}
{{end}} {{end}}
</div> </div>
+1 -3
View File
@@ -1,6 +1,5 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range (where .Data.Pages "Section" "!=" "home") }} {{ range .Data.Pages }}
{{ if not .Params.widget }}
<url> <url>
{{ if .IsTranslated }} {{ if .IsTranslated }}
<xhtml:link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Lang }}"/>{{ range .Translations }} <xhtml:link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Lang }}"/>{{ range .Translations }}
@@ -11,6 +10,5 @@
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }} <priority>{{ .Sitemap.Priority }}</priority>{{ end }}
</url> </url>
{{ end }}
{{ end }} {{ end }}
</urlset> </urlset>
+1
View File
@@ -0,0 +1 @@
{{ partial "widget_page.html" . }}