Forráskód Böngészése

Auto-hide unused homepage sections; consolidate all instances of article metadata and publication links to two dynamic partials; convert publication links to absolute URLs; improve SEO; and rename section pager partial.

George Cushen 9 éve
szülő
commit
5c23d6b413

+ 8 - 7
layouts/_default/single.html

@@ -2,18 +2,19 @@
 {{ partial "navbar.html" . }}
 <div class="container">
 
-    <h1>{{ .Title }}</h1>
-    {{ partial "article_metadata" . }}
+    <article class="article" itemscope itemtype="http://schema.org/Article">
+        <h1 itemprop="name">{{ .Title }}</h1>
 
-    <div class="post">
-        {{ .Content }}
-    </div>
+        {{ partial "article_metadata" (dict "content" . "is_list" 0) }}
 
-    {{ partial "section_item_pager.html" . }}
+        <div class="post" itemprop="articleBody">
+            {{ .Content }}
+        </div>
+    </article>
 
+    {{ partial "section_pager.html" . }}
     {{ partial "comments.html" . }}
 
     {{ partial "footer_container.html" . }}
-
  </div>
 {{ partial "footer.html" . }}

+ 22 - 13
layouts/index.html

@@ -7,7 +7,7 @@
 
 
     <!-- Biography Section -->
-    {{ range $index, $page := where .Site.Pages "Section" "=" "home" }}
+    {{ range where .Data.Pages "Type" "home" }}
     {{ if eq .Title "about" }}
     <section id="bio" class="home-section-wrapper full_width home" style="padding-top: 0;">
         {{ partial "home_biography" . }}
@@ -17,6 +17,8 @@
 
 
     <!-- Publications Section -->
+    {{ $pubs_len := len (where .Data.Pages "Type" "publication") }}
+    {{ if gt $pubs_len 0 }}
     <section id="publications" class="home-section-wrapper full_width home">
         <div class="row">
             <div class="col-xs-12 col-md-4">
@@ -25,20 +27,23 @@
             </div>
             <div class="col-xs-12 col-md-8">
                 <ul class="fa-ul">
-                    {{ range first 5 (where .Data.Pages.ByDate "Section" "publication").Reverse }}
+                    {{ range $index, $page := first 10 (where .Data.Pages "Type" "publication") }}
                     <li>
                         <i class="fa-li fa fa-file-text-o pub-icon" aria-hidden="true"></i>
-                        <span style="padding-right: 8px">{{ .Title | markdownify }}</span>
-                        <p>{{ partial "publication_list_buttons" . }}</p>
+                        <span style="padding-right: 8px">{{ .Title }}</span>
+                        <p>{{ partial "publication_links" (dict "content" $page "is_list" 1) }}</p>
                     </li>
                     {{ end }}
                 </ul>
             </div>
         </div>
     </section>
+    {{ end }}
 
 
     <!-- Blog Posts Section -->
+    {{ $posts_len := len (where .Data.Pages "Type" "post") }}
+    {{ if gt $posts_len 0 }}
     <section id="posts" class="home-section-wrapper full_width home">
         <div class="row">
             <div class="col-xs-12 col-md-4">
@@ -46,15 +51,15 @@
                 <p><a href="{{ .Site.BaseURL }}post/">More Posts <i class="fa fa-angle-double-right" style="padding-left: 5px;"></i></a></p>
             </div>
             <div class="col-xs-12 col-md-8">
-                {{ range last 5 (where .Data.Pages "Section" "=" "post") }}
-                <div class="article-list-item">
-                    <h3 class="post-title"><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
-                    {{ partial "article_metadata_compact" . }}
-                    <p>
+                {{ range first 5 (where .Data.Pages "Type" "post") }}
+                <div class="article-list-item" itemscope="" itemprop="blogPost">
+                    <h3 class="post-title" itemprop="name"><a href="{{ .Permalink }}" itemprop="url">{{ .Title }}</a></h3>
+                    {{ partial "article_metadata" (dict "content" . "is_list" 1) }}
+                    <p itemprop="articleBody">
                         {{ if .Truncated }}
                             {{ .Summary }}
                         {{ else }}
-                            {{ .Content | markdownify }}
+                            {{ .Content }}
                         {{ end }}
                     </p>
                     <p class="read-more">
@@ -65,9 +70,12 @@
             </div>
         </div>
     </section>
+    {{ end }}
 
 
     <!-- Projects Section -->
+    {{ $projects_len := len (where .Data.Pages "Type" "project") }}
+    {{ if gt $projects_len 0 }}
     <section id="projects" class="home-section-wrapper full_width home">
         <div class="row">
             <div class="col-xs-12 col-md-4">
@@ -75,11 +83,11 @@
             </div>
             <div class="col-xs-12 col-md-8">
                 <ul class="fa-ul">
-                {{ range where .Data.Pages "Section" "=" "project" }}
+                {{ range where .Data.Pages "Type" "project" }}
                     <li>
                         {{ 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>
-                        <span style="padding-right: 8px">{{ .Title | markdownify }}</span>
+                        <span style="padding-right: 8px">{{ .Title }}</span>
                         {{ if .Content }}</a >{{ else }}{{ with .Params.external_link }}</a>{{ end }}{{ end }}
                     </li>
                 {{ end }}
@@ -87,10 +95,11 @@
             </div>
         </div>
     </section>
+    {{ end }}
 
 
     <!-- Custom Sections -->
-    {{ range $index, $page := where .Site.Pages "Section" "=" "home" }}
+    {{ range $index, $page := where .Data.Pages "Type" "home" }}
     {{ if and (isset .Params "section_id") (not (eq .Params.section_id 0)) }}
     {{ $title_words := split $page.Title " " }}
     <section id="{{ range $k, $v := $title_words }}{{ if eq $k 0 }}{{ . | urlize | lower }}{{ end }}{{ end }}" class="home-section-wrapper full_width home">

+ 8 - 5
layouts/partials/article_metadata.html

@@ -1,24 +1,27 @@
+{{ $is_list := .is_list }}
+{{ $ := .content }}
 <div class="article-metadata">
 
     <span class="article-date">
-        <time datetime="{{ .Date }}" itemprop="datePublished">{{ .Date.Format .Site.Params.date_format }}</time>
+        <time datetime="{{ $.Date }}" itemprop="datePublished">{{ $.Date.Format $.Site.Params.date_format }}</time>
     </span>
 
-    {{ if isset .Params "tags" }}
-    {{ $tagsLen := len .Params.tags }}
+    {{ if isset $.Params "tags" }}
+    {{ $tagsLen := len $.Params.tags }}
     {{ if gt $tagsLen 0 }}
     <span class="article-tags">
         <i class="fa fa-tags"></i>
-        {{ range $k, $v := .Params.tags }}
+        {{ range $k, $v := $.Params.tags }}
         <a class="article-tag-link" href="{{ $.Site.BaseURL }}tags/{{ . | urlize | lower }}">{{ . }}</a>{{ if lt $k (sub $tagsLen 1) }}, {{ end }}
         {{ end }}
     </span>
     {{ end }}
     {{ end }}
 
-
+    {{ if ne $is_list 1 }}
     <div class="pull-right">
         {{ partial "share.html" . }}
     </div>
+    {{ end }}
 
 </div>

+ 0 - 19
layouts/partials/article_metadata_compact.html

@@ -1,19 +0,0 @@
-<div class="article-metadata">
-
-    <span class="article-date">
-        <time datetime="{{ .Date }}" itemprop="datePublished">{{ .Date.Format .Site.Params.date_format }}</time>
-    </span>
-
-    {{ if isset .Params "tags" }}
-    {{ $tagsLen := len .Params.tags }}
-    {{ if gt $tagsLen 0 }}
-    <span class="article-tags">
-        <i class="fa fa-tags"></i>
-        {{ range $k, $v := .Params.tags }}
-        <a class="article-tag-link" href="{{ $.Site.BaseURL }}tags/{{ . | urlize | lower }}">{{ . }}</a>{{ if lt $k (sub $tagsLen 1) }}, {{ end }}
-        {{ end }}
-    </span>
-    {{ end }}
-    {{ end }}
-
-</div>

+ 17 - 0
layouts/partials/publication_links.html

@@ -0,0 +1,17 @@
+{{ $is_list := .is_list }}
+{{ $ := .content }}
+
+{{ if $is_list }}
+<a class="btn btn-primary btn-outline btn-xs" href="{{ $.Permalink }}">Details</a>
+{{ end }}
+
+{{ with $.Params.url_pdf }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">PDF</a>{{ end }}
+{{ with $.Params.url_slides }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">Slides</a>{{ end }}
+{{ with $.Params.url_video }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">Video</a>{{ end }}
+{{ with $.Params.url_code }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">Code</a>{{ end }}
+{{ with $.Params.url_dataset }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">Dataset</a>{{ end }}
+{{ with $.Params.url_project }}<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">Project</a>{{ end }}
+
+{{ range $.Params.url_custom }}
+<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ .url | absURL }}">{{ .name }}</a>
+{{ end }}

+ 0 - 8
layouts/partials/publication_list_buttons.html

@@ -1,8 +0,0 @@
-<a class="btn btn-primary btn-outline btn-xs" href="{{ .Permalink }}">Details</a>
-{{ with .Params.url_pdf }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">PDF</a>{{ end }}
-{{ with .Params.url_code }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">Code</a>{{ end }}
-{{ with .Params.url_dataset }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">Dataset</a>{{ end }}
-{{ with .Params.url_project }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">Project</a>{{ end }}
-{{ with .Params.url_slides }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">Slides</a>{{ end }}
-{{ with .Params.url_video }}<a class="btn btn-primary btn-outline btn-xs" href="{{ . }}">Video</a>{{ end }}
-{{ range .Params.url_custom }}<a class="btn btn-primary btn-outline btn-xs" href="{{ .url }}">{{ .name }}</a>{{ end }}

+ 0 - 0
layouts/partials/section_item_pager.html → layouts/partials/section_pager.html


+ 10 - 6
layouts/project/single.html

@@ -2,13 +2,17 @@
 {{ partial "navbar.html" . }}
 <div class="container">
 
-    <h1>{{ .Title }}</h1>
-    {{ with .Params.external_link }}<a class="btn btn-primary btn-outline" href="{{ . }}">Go to Project Site</a>{{ end }}
-    <div class="post">
-        {{ .Content }}
-    </div>
+    <article class="article article-project" itemscope itemtype="http://schema.org/Article">
+        <h1 itemprop="name">{{ .Title }}</h1>
 
-    {{ partial "section_item_pager.html" . }}
+        {{ with .Params.external_link }}<a class="btn btn-primary btn-outline" href="{{ . }}">Go to Project Site</a>{{ end }}
+
+        <div class="post" itemprop="articleBody">
+            {{ .Content }}
+        </div>
+    </article>
+
+    {{ partial "section_pager.html" . }}
 
     {{ partial "footer_container.html" . }}
 

+ 2 - 8
layouts/publication/single.html

@@ -49,13 +49,7 @@
                     <div class="col-xs-12 col-sm-3" style="font-weight: bold; line-height:34px;">Links</div>
                     <div class="col-xs-12 col-sm-9">
 
-                        {{ with .Params.url_pdf }}<a class="btn btn-primary btn-outline" href="{{ . }}">PDF</a>{{ end }}
-                        {{ with .Params.url_code }}<a class="btn btn-primary btn-outline" href="{{ . }}">Code</a>{{ end }}
-                        {{ with .Params.url_dataset }}<a class="btn btn-primary btn-outline" href="{{ . }}">Dataset</a>{{ end }}
-                        {{ with .Params.url_project }}<a class="btn btn-primary btn-outline" href="{{ . }}">Project</a>{{ end }}
-                        {{ with .Params.url_slides }}<a class="btn btn-primary btn-outline" href="{{ . }}">Slides</a>{{ end }}
-                        {{ with .Params.url_video }}<a class="btn btn-primary btn-outline" href="{{ . }}">Video</a>{{ end }}
-                        {{ range .Params.url_custom }}<a class="btn btn-primary btn-outline" href="{{ .url }}">{{ .name }}</a>{{ end }}
+                        {{ partial "publication_links" (dict "content" . "is_list" 0) }}
 
                     </div>
                 </div>
@@ -70,7 +64,7 @@
 
     </div>
 
-    {{ partial "section_item_pager.html" . }}
+    {{ partial "section_pager.html" . }}
     {{ partial "footer_container.html" . }}
 </div>
 {{ partial "footer.html" . }}

+ 1 - 1
layouts/section/post.html

@@ -6,7 +6,7 @@
     {{ range $paginator.Pages }}
     <div>
         <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
-        <h4>{{ .Date.Format .Site.Params.date_format }}</h4>
+        {{ partial "article_metadata" (dict "content" . "is_list" 1) }}
         <p>{{ .Summary }}</p>
     </div>
     {{ end }}

+ 9 - 12
layouts/section/publication.html

@@ -1,37 +1,34 @@
 {{ partial "header.html" . }}
 {{ partial "navbar.html" . }}
-
 <div class="container">
-
-
     <div class="row">
         <div class="col-md-12">
             <h2>Publications</h2>
-            {{ range .Data.Pages.GroupByDate "2006" }}
 
+            {{ range .Data.Pages.GroupByDate "2006" }}
             <div class="row" id="pub_list">
                 <div class="col-md-2">
                     <h3>{{ .Key }}</h3>
                 </div>
                 <div class="col-md-10">
                     <ul class="compact fa-ul">
+
                         {{ range .Pages.ByDate.Reverse }}
                         <li>
-                            <i class="fa-li fa fa-file-text-o"  aria-hidden="true" style="color:#03396c;font-size:80%;padding-top:6px;"></i> {{ .Title | markdownify }}
-                            <p>{{ partial "publication_list_buttons" . }}</p>
+                            <i class="fa-li fa fa-file-text-o"  aria-hidden="true" style="color:#03396c;font-size:80%;padding-top:6px;"></i>
+                            {{ .Title }}
+                            <p>{{ partial "publication_links" (dict "content" . "is_list" 1) }}</p>
                         </li>
                         {{ end }}
+
                     </ul>
                 </div>
             </div>
-
             {{ end }}
-        </div>
-        </div>
 
+        </div>
+    </div>
 
     {{ partial "footer_container.html" . }}
-
 </div>
-
-{{ partial "footer.html" . }}
+{{ partial "footer.html" . }}