mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-26 19:15:16 +02:00
Enable widgets to be used on other pages, not only homepage (#300)
This commit is contained in:
parent
25baf85bca
commit
22ed2d0161
9 changed files with 49 additions and 33 deletions
|
@ -1,3 +1,9 @@
|
|||
{{ if .Params.widgets }}
|
||||
|
||||
{{ partial "widget_page.html" . }}
|
||||
|
||||
{{ else }}
|
||||
|
||||
{{ partial "header.html" . }}
|
||||
{{ partial "navbar.html" . }}
|
||||
|
||||
|
@ -30,3 +36,5 @@
|
|||
</div>
|
||||
{{ partial "footer_container.html" . }}
|
||||
{{ partial "footer.html" . }}
|
||||
|
||||
{{ end }}
|
||||
|
|
|
@ -1,20 +1 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ partial "navbar.html" . }}
|
||||
|
||||
<!-- Flag for jQuery -->
|
||||
<span id="homepage" style="display: none"></span>
|
||||
|
||||
<!-- Widgets -->
|
||||
{{ range $index, $page := where .Data.Pages "Type" "home" }}
|
||||
{{ $params := dict "root" $ "page" $page }}
|
||||
{{ $widget := printf "widgets/%s.html" ( or $page.Params.widget "custom" ) }}
|
||||
<section id="{{ $page.File.TranslationBaseName }}" class="home-section">
|
||||
<div class="container">
|
||||
{{ partial $widget $params }}
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
<!-- Page Footer -->
|
||||
{{ partial "footer_container.html" . }}
|
||||
{{ partial "footer.html" . }}
|
||||
{{ partial "widget_page.html" . }}
|
||||
|
|
27
layouts/partials/widget_page.html
Normal file
27
layouts/partials/widget_page.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ partial "navbar.html" . }}
|
||||
|
||||
<!-- Flag for jQuery -->
|
||||
<span id="homepage" style="display: none"></span>
|
||||
|
||||
{{ if .IsHome }}
|
||||
{{ .Scratch.Set "section" "home" }}
|
||||
{{ else }}
|
||||
{{ .Scratch.Set "section" .Section }}
|
||||
{{ end }}
|
||||
{{ $section := .Scratch.Get "section" }}
|
||||
|
||||
<!-- Widgets -->
|
||||
{{ range $index, $page := where .Data.Pages "Section" $section }}
|
||||
{{ $params := dict "root" $ "page" $page }}
|
||||
{{ $widget := printf "widgets/%s.html" ( or $page.Params.widget "custom" ) }}
|
||||
<section id="{{ $page.File.TranslationBaseName }}" class="home-section">
|
||||
<div class="container">
|
||||
{{ partial $widget $params }}
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
<!-- Page Footer -->
|
||||
{{ partial "footer_container.html" . }}
|
||||
{{ partial "footer.html" . }}
|
|
@ -1,6 +1,6 @@
|
|||
{{ $ := .root }}
|
||||
{{ $page := .page }}
|
||||
{{ $posts_len := len (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
|
||||
{{ $posts_len := len (where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil) }}
|
||||
|
||||
<!-- Blog Posts widget -->
|
||||
<div class="row">
|
||||
|
@ -23,7 +23,7 @@
|
|||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ if gt (len $page.Params.tags_include) 0 }}
|
||||
{{ $posts := where (where (where $.Data.Pages "Type" "post") ".Params.tags" "intersect" $page.Params.tags_include) ".Params.notonhomepage" nil }}
|
||||
{{ $posts := where (where (where $.Site.RegularPages "Type" "post") ".Params.tags" "intersect" $page.Params.tags_include) ".Params.notonhomepage" nil }}
|
||||
|
||||
{{ $.Scratch.Add "show_post" "1" }}
|
||||
{{ range $post := first $page.Params.count $posts }}
|
||||
|
@ -50,7 +50,7 @@
|
|||
|
||||
{{ end }}
|
||||
{{ else}}
|
||||
{{ $posts := where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil }}
|
||||
{{ $posts := where (where $.Site.RegularPages "Type" "post") ".Params.notonhomepage" nil }}
|
||||
|
||||
{{ $.Scratch.Add "show_post" "1" }}
|
||||
{{ range $post := first $page.Params.count $posts }}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
{{ if eq $page.Params.view 0 }}
|
||||
|
||||
<div class="row isotope projects-container">
|
||||
{{ range where $.Data.Pages "Type" "project" }}
|
||||
{{ range where $.Site.RegularPages "Type" "project" }}
|
||||
<div class="col-md-12 project-item isotope-item {{ delimit .Params.tags " " }}" itemscope itemtype="http://schema.org/CreativeWork">
|
||||
<i class="fa fa-files-o pub-icon" aria-hidden="true"></i>
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
<div class="row isotope projects-container">
|
||||
|
||||
{{ range $project := where $.Data.Pages "Type" "project" }}
|
||||
{{ range $project := where $.Site.RegularPages "Type" "project" }}
|
||||
{{ $.Scratch.Set "project_url" $project.Permalink }}
|
||||
{{ $.Scratch.Set "target" "" }}
|
||||
{{ if $project.Params.external_link }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{ $ := .root }}
|
||||
{{ $page := .page }}
|
||||
{{ $pubs_len := len (where $.Data.Pages "Type" "publication") }}
|
||||
{{ $pubs_len := len (where $.Site.RegularPages "Type" "publication") }}
|
||||
|
||||
<!-- Publications widget -->
|
||||
<div class="row">
|
||||
|
@ -20,9 +20,9 @@
|
|||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }}
|
||||
{{ $.Scratch.Set "recent_pubs" (where (where $.Data.Pages "Type" "publication") ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }}
|
||||
{{ $.Scratch.Set "recent_pubs" (where (where $.Site.RegularPages "Type" "publication") ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "recent_pubs" (where $.Data.Pages "Type" "publication") }}
|
||||
{{ $.Scratch.Set "recent_pubs" (where $.Site.RegularPages "Type" "publication") }}
|
||||
{{ end }}
|
||||
|
||||
{{ $recent_pubs := $.Scratch.Get "recent_pubs" }}
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ if and ($page.Params.publication_type) (ne $page.Params.publication_type "-1") }}
|
||||
{{ $.Scratch.Set "sel_pubs" (where (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }}
|
||||
{{ $.Scratch.Set "sel_pubs" (where (where (where $.Site.RegularPages "Type" "publication") ".Params.selected" true) ".Params.publication_types" "intersect" (slice $page.Params.publication_type)) }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "sel_pubs" (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }}
|
||||
{{ $.Scratch.Set "sel_pubs" (where (where $.Site.RegularPages "Type" "publication") ".Params.selected" true) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $sel_pubs := $.Scratch.Get "sel_pubs" }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{ $ := .root }}
|
||||
{{ $page := .page }}
|
||||
{{ $talks_len := len (where $.Data.Pages "Type" "talk") }}
|
||||
{{ $talks_len := len (where $.Site.RegularPages "Type" "talk") }}
|
||||
|
||||
<!-- Talks widget -->
|
||||
<div class="row">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<div class="col-xs-12 col-md-8">
|
||||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ range first $page.Params.count (where $.Data.Pages "Type" "talk") }}
|
||||
{{ range first $page.Params.count (where $.Site.RegularPages "Type" "talk") }}
|
||||
{{ if eq $page.Params.list_format 1 }}
|
||||
{{ partial "talk_li_detailed" . }}
|
||||
{{ else }}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="col-xs-12 col-md-8">
|
||||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ range (where (where $.Data.Pages "Type" "talk") ".Params.selected" true) }}
|
||||
{{ range (where (where $.Site.RegularPages "Type" "talk") ".Params.selected" true) }}
|
||||
{{ if eq $page.Params.list_format 1 }}
|
||||
{{ partial "talk_li_detailed" . }}
|
||||
{{ else }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue