Set widget identifiers to their respective filenames

Example: `content/home/about.md` widget is now linked from the
menu bar by setting the relevant URL as "#about" in `config.toml`.
This commit is contained in:
George Cushen 2016-11-24 15:57:54 +00:00
commit 8277658b81
9 changed files with 265 additions and 312 deletions

View file

@ -82,16 +82,18 @@ googleAnalytics = ""
# Navigation Links
# To link a homepage widget, specify the URL as a hash `#` followed by the filename of the
# desired widget in your `content/home/` folder.
# The weight parameter defines the order that the links will appear in.
[[menu.main]]
name = "Home"
url = "#bio"
url = "#about"
weight = 1
[[menu.main]]
name = "Publications"
url = "#publications"
url = "#publications_selected"
weight = 2
[[menu.main]]

View file

@ -5,11 +5,14 @@
<span id="homepage" style="display: none"></span>
<!-- Widgets -->
{{ $pubs_selected_len := len (where (where .Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ range $index, $page := where .Data.Pages "Type" "home" }}
{{ $params := dict "root" $ "page" $page "pubs_selected_len" $pubs_selected_len }}
{{ $params := dict "root" $ "page" $page }}
{{ $widget := printf "widgets/%s.html" ( or $page.Params.widget "custom" ) }}
{{ partial $widget $params }}
<section id="{{ $page.File.BaseFileName }}" class="home-section">
<div class="container">
{{ partial $widget $params }}
</div>
</section>
{{ end }}
<!-- Page Footer -->

View file

@ -1,80 +1,70 @@
{{ $ := .root }}
{{ $page := .page }}
<!-- About/Biography widget -->
<section id="bio" class="home-section">
<div class="container">
<!-- About widget -->
<div class="row" itemprop="author" itemscope itemtype="http://schema.org/Person">
<div class="col-xs-12 col-md-4">
<div id="profile">
<div class="row" itemprop="author" itemscope itemtype="http://schema.org/Person">
<div class="col-xs-12 col-md-4">
<div id="profile">
{{ with $.Site.Params.avatar }}
<div class="portrait" itemprop="image"
style="background-image: url('{{ "/img/" | relURL }}{{ . }}');">
</div>
{{ end }}
{{ with $.Site.Params.avatar }}
<div class="portrait" itemprop="image"
style="background-image: url('{{ "/img/" | relURL }}{{ . }}');">
</div>
{{ end }}
<div class="portrait-title">
<h2 itemprop="name">{{ $.Site.Params.name }}</h2>
<h3 itemprop="jobTitle">{{ $.Site.Params.role }}</h3>
{{ with $.Site.Params.organization }}<h3 itemprop="worksFor">{{ . }}</h3>{{ end }}
</div>
<ul class="social-icon" aria-hidden="true">
{{ range $.Site.Params.social }}
{{ $pack := or .icon_pack "fa" }}
<li>
<a href="{{ .link }}">
<i class="{{ $pack }} {{ $pack }}-{{ .icon }} big-icon"></i>
</a>
</li>
{{ end }}
</ul>
</div>
<div class="portrait-title">
<h2 itemprop="name">{{ $.Site.Params.name }}</h2>
<h3 itemprop="jobTitle">{{ $.Site.Params.role }}</h3>
{{ with $.Site.Params.organization }}<h3 itemprop="worksFor">{{ . }}</h3>{{ end }}
</div>
<div class="visible-sm visible-xs"></div>
<ul class="social-icon" aria-hidden="true">
{{ range $.Site.Params.social }}
{{ $pack := or .icon_pack "fa" }}
<li>
<a href="{{ .link }}">
<i class="{{ $pack }} {{ $pack }}-{{ .icon }} big-icon"></i>
</a>
</li>
{{ end }}
</ul>
<div class="col-xs-12 col-md-8" itemprop="description">
{{ $page.Content }}
<div class="row">
{{ with $page.Params.interests }}
<div class="col-sm-5">
<h3>{{ .title | default "Interests" | markdownify }}</h3>
<ul class="ul-interests">
{{ range .interests }}
<li>{{ . }}</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ with $page.Params.education }}
<div class="col-sm-7">
<h3>{{ .title | default "Education" | markdownify }}</h3>
<ul class="ul-edu fa-ul">
{{ range .courses }}
<li>
<i class="fa-li fa fa-graduation-cap"></i>
<div class="description">
<p class="course">{{ .course }}{{ with .year }}, {{ . }}{{ end }}</p>
<p class="institution">{{ .institution }}</p>
</div>
</li>
{{ end }}
</ul>
</div>
{{ end }}
</div>
</div>
</div>
</div>
</section>
<div class="col-xs-12 col-md-8" itemprop="description">
{{ $page.Content }}
<div class="row">
{{ with $page.Params.interests }}
<div class="col-sm-5">
<h3>{{ .title | default "Interests" | markdownify }}</h3>
<ul class="ul-interests">
{{ range .interests }}
<li>{{ . }}</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ with $page.Params.education }}
<div class="col-sm-7">
<h3>{{ .title | default "Education" | markdownify }}</h3>
<ul class="ul-edu fa-ul">
{{ range .courses }}
<li>
<i class="fa-li fa fa-graduation-cap"></i>
<div class="description">
<p class="course">{{ .course }}{{ with .year }}, {{ . }}{{ end }}</p>
<p class="institution">{{ .institution }}</p>
</div>
</li>
{{ end }}
</ul>
</div>
{{ end }}
</div>
</div>
</div>

View file

@ -3,57 +3,51 @@
{{ $autolink := default true $page.Params.autolink }}
<!-- Contact widget -->
<section id="contact" class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<ul class="fa-ul">
<ul class="fa-ul">
{{ with $.Site.Params.email }}
<li>
<i class="fa-li fa fa-envelope fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="mailto:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.email }}
<li>
<i class="fa-li fa fa-envelope fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="mailto:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.keybase }}
<li>
<i class="fa-li fa fa-lock fa-2x" aria-hidden="true"></i>
<span>
<a href="https://keybase.io/{{ . }}" target="_blank">@{{ . }}</a> on Keybase.
</span>
</li>
{{ end }}
{{ with $.Site.Params.keybase }}
<li>
<i class="fa-li fa fa-lock fa-2x" aria-hidden="true"></i>
<span>
<a href="https://keybase.io/{{ . }}" target="_blank">@{{ . }}</a> on Keybase.
</span>
</li>
{{ end }}
{{ with $.Site.Params.phone }}
<li>
<i class="fa-li fa fa-phone fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.phone }}
<li>
<i class="fa-li fa fa-phone fa-2x" aria-hidden="true"></i>
<span>
{{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span>
</li>
{{ end }}
{{ with $.Site.Params.address }}
<li>
<i class="fa-li fa fa-map-marker fa-2x" aria-hidden="true"></i>
<span>{{ . }}</span>
</li>
{{ end }}
{{ with $.Site.Params.address }}
<li>
<i class="fa-li fa fa-map-marker fa-2x" aria-hidden="true"></i>
<span>{{ . }}</span>
</li>
{{ end }}
</ul>
</div>
</div>
</ul>
</div>
</section>
</div>

View file

@ -1,19 +1,12 @@
{{ $page := .page }}
{{ $title_words := split $page.Title " " }}
<!-- Custom widget -->
<section
id="{{ range $k, $v := $title_words }}{{ if eq $k 0 }}{{ . | urlize | lower }}{{ end }}{{ end }}"
class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ title $page.Title }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ $page.Content }}
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ title $page.Title }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
</section>
<div class="col-xs-12 col-md-8">
{{ $page.Content }}
</div>
</div>

View file

@ -1,42 +1,38 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $posts_len := len (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
{{ if gt $posts_len 0 }}
<!-- Blog Posts widget -->
<section id="posts" class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $posts_len $page.Params.count }}
<p class="view-all">
<a href="{{ "/post/" | relURL }}">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>
{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $posts_len $page.Params.count }}
<p class="view-all">
<a href="{{ "/post/" | relURL }}">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>
{{ end }}
{{ if $page.Params.tags }}
{{ range first $page.Params.count (where (where (where $.Data.Pages "Type" "post") ".Params.tags" "intersect" $page.Params.tags) ".Params.notonhomepage" nil) }}
{{ $params := dict "post" . "page" $page }}
{{ partial "post_li" $params }}
{{ end }}
{{ else }}
{{ range first $page.Params.count (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
{{ $params := dict "post" . "page" $page }}
{{ partial "post_li" $params }}
{{ end }}
{{ end }}
</div>
</div>
</div>
</section>
{{ end }}
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if $page.Params.tags }}
{{ range first $page.Params.count (where (where (where $.Data.Pages "Type" "post") ".Params.tags" "intersect" $page.Params.tags) ".Params.notonhomepage" nil) }}
{{ $params := dict "post" . "page" $page }}
{{ partial "post_li" $params }}
{{ end }}
{{ else }}
{{ range first $page.Params.count (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
{{ $params := dict "post" . "page" $page }}
{{ partial "post_li" $params }}
{{ end }}
{{ end }}
</div>
</div>

View file

@ -1,89 +1,80 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $projects_len := len (where $.Data.Pages "Type" "project") }}
{{ if gt $projects_len 0 }}
<!-- Projects widget -->
<section id="projects" class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<div class="project-toolbar">
<div id="filters">
<div class="btn-toolbar">
<div class="btn-group">
{{ range $page.Params.filter }}
<a href="#" data-filter="{{ .tag }}" class="btn btn-primary btn-large{{ if eq .tag "*" }} active{{ end }}">{{ .name }}</a>
{{ end }}
</div>
</div>
<div class="project-toolbar">
<div id="filters">
<div class="btn-toolbar">
<div class="btn-group">
{{ range $page.Params.filter }}
<a href="#" data-filter="{{ .tag }}" class="btn btn-primary btn-large{{ if eq .tag "*" }} active{{ end }}">{{ .name }}</a>
{{ end }}
</div>
</div>
{{ if eq $page.Params.view 0 }}
<div id="container-projects" class="isotope">
<ul class="fa-ul" style="position: relative">
{{ range where $.Data.Pages "Type" "project" }}
<li class="project-item isotope-item {{ delimit .Params.tags " " }}">
<span class="project-title">
{{ if .Content }}
<a href="{{ .Permalink }}">
{{ else }}
{{ with .Params.external_link }}<a href="{{ . }}">{{ end }}
{{ end }}
<i class="fa-li fa fa-files-o pub-icon" aria-hidden="true"></i>
{{ .Title }}
{{ if .Content }}</a>{{ else }}{{ with .Params.external_link }}</a>{{ end }}{{ end }}
</span>
{{ with .Params.summary }}<p class="project-summary">{{ . }}</p>{{ end }}
</li>
{{ end }}
</ul>
</div>
{{ else }}
<div id="container-projects" class="row isotope">
{{ range $project := where $.Data.Pages "Type" "project" }}
{{ $.Scratch.Set "project_url" $project.Permalink }}
{{ if $project.Params.external_link }}
{{ $.Scratch.Set "project_url" $project.Params.external_link }}
{{ end }}
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-6 project-item isotope-item {{ delimit .Params.tags " " }}">
<div class="card">
{{ with $project.Params.image_preview }}
<a href="{{ $.Scratch.Get "project_url" }}" title="" class="card-image hover-overlay">
<img src="{{ "/img/" | relURL }}{{ . }}" alt="" class="img-responsive">
</a>
{{ end }}
<div class="card-text">
<h4><a href="{{ $.Scratch.Get "project_url" }}">{{ .Title }}</a></h4>
<div class="card-desription">
{{ with $project.Params.summary }}<p>{{ . }}</p>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
</div>
{{ end }}
</div>
</div>
{{ if eq $page.Params.view 0 }}
<div id="container-projects" class="isotope">
<ul class="fa-ul" style="position: relative">
{{ range where $.Data.Pages "Type" "project" }}
<li class="project-item isotope-item {{ delimit .Params.tags " " }}">
<span class="project-title">
{{ if .Content }}
<a href="{{ .Permalink }}">
{{ else }}
{{ with .Params.external_link }}<a href="{{ . }}">{{ end }}
{{ end }}
<i class="fa-li fa fa-files-o pub-icon" aria-hidden="true"></i>
{{ .Title }}
{{ if .Content }}</a>{{ else }}{{ with .Params.external_link }}</a>{{ end }}{{ end }}
</span>
{{ with .Params.summary }}<p class="project-summary">{{ . }}</p>{{ end }}
</li>
{{ end }}
</ul>
</div>
{{ else }}
<div id="container-projects" class="row isotope">
{{ range $project := where $.Data.Pages "Type" "project" }}
{{ $.Scratch.Set "project_url" $project.Permalink }}
{{ if $project.Params.external_link }}
{{ $.Scratch.Set "project_url" $project.Params.external_link }}
{{ end }}
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-6 project-item isotope-item {{ delimit .Params.tags " " }}">
<div class="card">
{{ with $project.Params.image_preview }}
<a href="{{ $.Scratch.Get "project_url" }}" title="" class="card-image hover-overlay">
<img src="{{ "/img/" | relURL }}{{ . }}" alt="" class="img-responsive">
</a>
{{ end }}
<div class="card-text">
<h4><a href="{{ $.Scratch.Get "project_url" }}">{{ .Title }}</a></h4>
<div class="card-desription">
{{ with $project.Params.summary }}<p>{{ . }}</p>{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
</div>
{{ end }}
</div>
</section>
{{ end }}
</div>

View file

@ -1,43 +1,35 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $pubs_selected_len := .pubs_selected_len }}
{{ $pubs_len := len (where $.Data.Pages "Type" "publication") }}
{{ if gt $pubs_len 0 }}
<!-- Publications widget -->
<section {{ if eq $pubs_selected_len 0 }}id="publications" {{ end }}class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $pubs_len $page.Params.count }}
<p class="view-all">
<a href="{{ $.Site.BaseURL }}publication/">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>
{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if gt $pubs_len $page.Params.count }}
<p class="view-all">
<a href="{{ $.Site.BaseURL }}publication/">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>
{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if $page.Params.detailed_list }}
{{ range first $page.Params.count (where $.Data.Pages "Type" "publication") }}
{{ partial "publication_li_detailed" . }}
{{ end }}
{{ else }}
<ul class="fa-ul">
{{ range first $page.Params.count (where $.Data.Pages "Type" "publication") }}
{{ partial "publication_li_simple" . }}
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ if $page.Params.detailed_list }}
{{ range first $page.Params.count (where $.Data.Pages "Type" "publication") }}
{{ partial "publication_li_detailed" . }}
{{ end }}
{{ else }}
<ul class="fa-ul">
{{ range first $page.Params.count (where $.Data.Pages "Type" "publication") }}
{{ partial "publication_li_simple" . }}
{{ end }}
</ul>
{{ end }}
</div>
</section>
{{ end }}
</div>

View file

@ -1,34 +1,26 @@
{{ $ := .root }}
{{ $page := .page }}
{{ $pubs_selected_len := .pubs_selected_len }}
{{ if gt $pubs_selected_len 0 }}
<!-- Selected Publications widget -->
<section id="publications" class="home-section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
<div class="row">
<div class="col-xs-12 col-md-4 section-heading">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
</div>
<div class="col-xs-12 col-md-8">
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
{{ if $page.Params.detailed_list }}
{{ range (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ partial "publication_li_detailed" . }}
{{ end }}
{{ else }}
<ul class="fa-ul">
{{ range (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ partial "publication_li_simple" . }}
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ if $page.Params.detailed_list }}
{{ range (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ partial "publication_li_detailed" . }}
{{ end }}
{{ else }}
<ul class="fa-ul">
{{ range (where (where $.Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ partial "publication_li_simple" . }}
{{ end }}
</ul>
{{ end }}
</div>
</section>
{{ end }}
</div>