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.
widget = "about" # Do not modify this line!
# About widget.
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
weight = 20 # Order that this section will appear in.
+2 -1
View File
@@ -1,6 +1,7 @@
+++
# 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
weight = 50 # Order that this section will appear.
+3 -4
View File
@@ -1,14 +1,13 @@
+++
# 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
weight = 130 # Order that this section will appear.
title = "Contact"
subtitle = ""
# Order that this section will appear in.
weight = 130
# Automatically link email and phone?
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/
# 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
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"
subtitle = ""
+2 -1
View File
@@ -1,6 +1,7 @@
+++
# 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
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
# `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
weight = 80 # Order that this section will appear.
+4 -6
View File
@@ -1,14 +1,12 @@
+++
# Custom widget.
widget = "custom" # Do not modify this line!
# Gallery section using the Blank widget and Gallery element (shortcode).
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
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"
subtitle = ""
# Order that this section will appear in.
weight = 66
+++
{{< gallery >}}
+2 -1
View File
@@ -1,6 +1,7 @@
+++
# 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
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.
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
weight = 68 # Order that this section will appear.
title = "People"
subtitle = ""
# Order that this section will appear in.
weight = 68
# List user groups to display.
# Edit each user's `user_groups` to add them to one or more of these groups.
user_groups = ["Principal Investigators",
+2 -1
View File
@@ -2,7 +2,8 @@
# A Recent Blog Posts section created with the Pages widget.
# 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
weight = 60 # Order that this section will appear.
+3 -2
View File
@@ -1,6 +1,7 @@
+++
# Portfolio widget.
widget = "portfolio" # Do not modify this line!
# A Projects section created with the Portfolio widget.
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
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.
# 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
weight = 90 # Order that this section will appear.
+4 -5
View File
@@ -1,14 +1,13 @@
+++
# Feature/Skill widget.
widget = "featurette" # Do not modify this line!
# A Skills section created with the Featurette widget.
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
weight = 30 # Order that this section will appear.
title = "Skills"
subtitle = ""
# Order that this section will appear in.
weight = 30
# Showcase personal skills or business features.
#
# Add/remove as many `[[feature]]` blocks below as you like.
+3 -4
View File
@@ -1,10 +1,9 @@
+++
# 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
# Order that this section will appear in.
weight = 1
weight = 1 # Order that this section will appear.
# Slide interval.
# 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.
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
weight = 120 # Order that this section will appear.
title = "Popular Topics"
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.
# 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
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. */ -}}
{{- $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. */ -}}
{{- $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. */ -}}
+11 -7
View File
@@ -4,15 +4,17 @@
<!-- Flag for jQuery -->
<span id="homepage" class="d-none"></span>
{{ $section := "" }}
{{/* Get widget page path */}}
{{ $page := "" }}
{{ if .IsHome }}
{{ $section = "home" }}
{{ $page = "/home" }}
{{ else }}
{{ $section = .Section }}
{{ $page = .File.Path }}
{{ end }}
<!-- Widgets -->
{{ range $index, $st := where (where .Data.Pages "Section" $section) ".Params.active" "!=" false }}
{{/* Load page sections */}}
{{ $headless_bundle := .Site.GetPage $page }}
{{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
{{/* Begin widget styling */}}
{{ $bg := $st.Params.design.background }}
{{ $style := "" }}
@@ -39,14 +41,17 @@
{{ end }}
{{ $params := dict "root" $ "page" $st }}
{{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base (path.Split .Path).Dir) }}
{{ $widget := or $st.Params.widget "blank" }}
{{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
{{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
{{ $widget_path := printf "widgets/%s.html" $widget }}
{{ if in (slice "slider") $widget }}
{{ partial $widget_path $params }}
{{ 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">
{{ partial $widget_path $params }}
</div>
@@ -54,6 +59,5 @@
{{ end }}
{{ end }}
<!-- Page Footer -->
{{ partial "footer_container.html" . }}
{{ partial "footer.html" . }}
+2 -2
View File
@@ -3,14 +3,14 @@
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link>
<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 }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<atom:link href="{{.URL}}" rel="self" type="application/rss+xml" />
{{ range first 15 (where .Data.Pages "Type" "!=" "home") }}
{{ range first 15 .Data.Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
View File
Whitespace-only changes.
+17 -6
View File
@@ -1,11 +1,22 @@
{{ $album := "gallery" }}
{{ with .Get "album" }}{{ $album = . }}{{ end }}
{{ $album_path := printf "%s/*" $album }}
{{/* if eq .Page.Type "home" */}}{{/* $album_path = "*" */}}{{/* end */}}
{{/* Get album folder or default to `gallery/`. */}}
{{ $album := "" }}
{{ with .Get "album" }}{{ $album = . }}{{else}}{{ $album = "gallery" }}{{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">
{{/* 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 }}
{{ range $images }}
{{ $image := .Resize "x190" }}
@@ -39,7 +50,7 @@
</a>
{{end}}
{{else}}
{{ errorf "Unable to load gallery in %s." .Page.Filename }}
{{ errorf "Unable to load gallery in %s." .Page.Filename }}
{{end}}
{{end}}
</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">
{{ range (where .Data.Pages "Section" "!=" "home") }}
{{ if not .Params.widget }}
{{ range .Data.Pages }}
<url>
{{ if .IsTranslated }}
<xhtml:link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Lang }}"/>{{ range .Translations }}
@@ -11,6 +10,5 @@
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}
</url>
{{ end }}
{{ end }}
</urlset>
+1
View File
@@ -0,0 +1 @@
{{ partial "widget_page.html" . }}