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 # 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. # The weight parameter defines the order that the links will appear in.
[[menu.main]] [[menu.main]]
name = "Home" name = "Home"
url = "#bio" url = "#about"
weight = 1 weight = 1
[[menu.main]] [[menu.main]]
name = "Publications" name = "Publications"
url = "#publications" url = "#publications_selected"
weight = 2 weight = 2
[[menu.main]] [[menu.main]]

View file

@ -5,11 +5,14 @@
<span id="homepage" style="display: none"></span> <span id="homepage" style="display: none"></span>
<!-- Widgets --> <!-- Widgets -->
{{ $pubs_selected_len := len (where (where .Data.Pages "Type" "publication") ".Params.selected" true) }}
{{ range $index, $page := where .Data.Pages "Type" "home" }} {{ 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" ) }} {{ $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 }} {{ end }}
<!-- Page Footer --> <!-- Page Footer -->

View file

@ -1,80 +1,70 @@
{{ $ := .root }} {{ $ := .root }}
{{ $page := .page }} {{ $page := .page }}
<!-- About/Biography widget --> <!-- About widget -->
<section id="bio" class="home-section"> <div class="row" itemprop="author" itemscope itemtype="http://schema.org/Person">
<div class="container"> <div class="col-xs-12 col-md-4">
<div id="profile">
<div class="row" itemprop="author" itemscope itemtype="http://schema.org/Person"> {{ with $.Site.Params.avatar }}
<div class="col-xs-12 col-md-4"> <div class="portrait" itemprop="image"
<div id="profile"> style="background-image: url('{{ "/img/" | relURL }}{{ . }}');">
</div>
{{ end }}
{{ with $.Site.Params.avatar }} <div class="portrait-title">
<div class="portrait" itemprop="image" <h2 itemprop="name">{{ $.Site.Params.name }}</h2>
style="background-image: url('{{ "/img/" | relURL }}{{ . }}');"> <h3 itemprop="jobTitle">{{ $.Site.Params.role }}</h3>
</div> {{ with $.Site.Params.organization }}<h3 itemprop="worksFor">{{ . }}</h3>{{ end }}
{{ 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> </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>
</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 }} {{ $autolink := default true $page.Params.autolink }}
<!-- Contact widget --> <!-- Contact widget -->
<section id="contact" class="home-section"> <div class="row">
<div class="container"> <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"> <ul class="fa-ul">
<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"> {{ 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 }} {{ with $.Site.Params.keybase }}
<li> <li>
<i class="fa-li fa fa-envelope fa-2x" aria-hidden="true"></i> <i class="fa-li fa fa-lock fa-2x" aria-hidden="true"></i>
<span> <span>
{{- if $autolink }}<a href="mailto:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}} <a href="https://keybase.io/{{ . }}" target="_blank">@{{ . }}</a> on Keybase.
</span> </span>
</li> </li>
{{ end }} {{ end }}
{{ with $.Site.Params.keybase }} {{ with $.Site.Params.phone }}
<li> <li>
<i class="fa-li fa fa-lock fa-2x" aria-hidden="true"></i> <i class="fa-li fa fa-phone fa-2x" aria-hidden="true"></i>
<span> <span>
<a href="https://keybase.io/{{ . }}" target="_blank">@{{ . }}</a> on Keybase. {{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
</span> </span>
</li> </li>
{{ end }} {{ end }}
{{ with $.Site.Params.phone }} {{ with $.Site.Params.address }}
<li> <li>
<i class="fa-li fa fa-phone fa-2x" aria-hidden="true"></i> <i class="fa-li fa fa-map-marker fa-2x" aria-hidden="true"></i>
<span> <span>{{ . }}</span>
{{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}} </li>
</span> {{ end }}
</li>
{{ end }}
{{ with $.Site.Params.address }} </ul>
<li>
<i class="fa-li fa fa-map-marker fa-2x" aria-hidden="true"></i>
<span>{{ . }}</span>
</li>
{{ end }}
</ul>
</div>
</div>
</div> </div>
</section> </div>

View file

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

View file

@ -1,42 +1,38 @@
{{ $ := .root }} {{ $ := .root }}
{{ $page := .page }} {{ $page := .page }}
{{ $posts_len := len (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }} {{ $posts_len := len (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
{{ if gt $posts_len 0 }}
<!-- Blog Posts widget --> <!-- Blog Posts widget -->
<section id="posts" class="home-section"> <div class="row">
<div class="container"> <div class="col-xs-12 col-md-4 section-heading">
<div class="row"> <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
<div class="col-xs-12 col-md-4 section-heading"> {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1> {{ if gt $posts_len $page.Params.count }}
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }} <p class="view-all">
{{ if gt $posts_len $page.Params.count }} <a href="{{ "/post/" | relURL }}">
<p class="view-all"> {{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
<a href="{{ "/post/" | relURL }}"> <i class="fa fa-angle-double-right"></i>
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }} </a>
<i class="fa fa-angle-double-right"></i> </p>
</a> {{ end }}
</p>
{{ end }}
</div>
<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>
</div> </div>
</section> <div class="col-xs-12 col-md-8">
{{ end }}
{{ 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 }} {{ $ := .root }}
{{ $page := .page }} {{ $page := .page }}
{{ $projects_len := len (where $.Data.Pages "Type" "project") }}
{{ if gt $projects_len 0 }}
<!-- Projects widget --> <!-- Projects widget -->
<section id="projects" class="home-section"> <div class="row">
<div class="container"> <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="project-toolbar">
<div class="col-xs-12 col-md-4 section-heading"> <div id="filters">
<h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1> <div class="btn-toolbar">
{{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }} <div class="btn-group">
</div> {{ range $page.Params.filter }}
<div class="col-xs-12 col-md-8"> <a href="#" data-filter="{{ .tag }}" class="btn btn-primary btn-large{{ if eq .tag "*" }} active{{ end }}">{{ .name }}</a>
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }} {{ 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> </div>
</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>
</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>
</section> </div>
{{ end }}

View file

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

View file

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