Merge pull request #52 from rayjolt/block-template

Make all full-page templates inherit from a block template
This commit is contained in:
Michael Romero 2017-04-16 20:47:51 -07:00 committed by GitHub
commit be5a5c2ac7
10 changed files with 172 additions and 215 deletions

View File

@ -1,21 +1,11 @@
<!DOCTYPE html> {{ define "header" }}<!-- No header on 404 pages -->{{ end }}
<html lang="{{ .Lang }}"> {{ define "main" }}
<div role="main" class="container main-content">
{{ partial "head.html" . }} <div class="text-center">
<h1>{{ i18n "pageNotFound" }}</h1>
<body> <br/>
<img src="{{ .Site.BaseURL }}/img/404-southpark.jpg" />
{{ partial "nav.html" . }}
<div role="main" class="container main-content">
<div class="text-center">
<h1>{{ i18n "pageNotFound" }}</h1>
<br/>
<img src="{{ .Site.BaseURL }}/img/404-southpark.jpg" />
</div>
</div> </div>
</div>
{{ end }}
{{ partial "footer.html" . }}
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="{{ .Lang }}">
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}
{{ block "header" . }}{{ partial "header.html" . }}{{ end }}
{{ block "main" . }}{{ end }}
{{ partial "footer.html" . }}
</body>
</html>

View File

@ -1,70 +1,61 @@
<!DOCTYPE html> {{ define "header" }}
<html lang="{{ .Lang }}"> <header class="header-section ">
<div class="intro-header no-img">
{{ partial "head.html" . }} <div class="container">
<div class="row">
<body> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="page-heading">
{{ partial "nav.html" . }} <h2>#{{ .Title }}</h2>
<header class="header-section ">
<div class="intro-header no-img">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="page-heading">
<h2>#{{ .Title }}</h2>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</header> </div>
</header>
<div class="container" role="main"> {{ end }}
<div class="row"> {{ define "main" }}
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <div class="container" role="main">
<div class="posts-list"> <div class="row">
{{ $pag := .Paginate (where .Data.Pages "Type" "post") }} <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ range $pag.Pages }} <div class="posts-list">
<article class="post-preview"> {{ $pag := .Paginate (where .Data.Pages "Type" "post") }}
<a href="{{ .Permalink }}"> {{ range $pag.Pages }}
<h2 class="post-title">{{ .Title }}</h2> <article class="post-preview">
<a href="{{ .Permalink }}">
{{ if .Params.subtitle }} <h2 class="post-title">{{ .Title }}</h2>
<h3 class="post-subtitle">
{{ .Params.subtitle }} {{ if .Params.subtitle }}
</h3> <h3 class="post-subtitle">
{{ end }} {{ .Params.subtitle }}
</a> </h3>
<p class="post-meta">
{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
</p>
<div class="post-entry">
{{ if .Truncated }}
{{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ .Content }}
{{ end }}
</div>
{{ if .Params.tags }}
<span class="post-meta">
{{ range .Params.tags }}
#<a href="{{ $.Site.LanguagePrefix }}/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }} {{ end }}
</a>
</article>
{{ end }} <p class="post-meta">
</div> {{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
</p>
<div class="post-entry">
{{ if .Truncated }}
{{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ .Content }}
{{ end }}
</div>
{{ if .Params.tags }}
<span class="post-meta">
{{ range .Params.tags }}
#<a href="{{ $.Site.LanguagePrefix }}/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }}
</article>
{{ end }}
</div> </div>
</div> </div>
</div> </div>
{{ partial "footer.html" . }} </div>
{{ end }}
</body>
</html>

View File

@ -1,25 +1,6 @@
<!DOCTYPE html> {{ define "main" }}
<html lang="{{ .Lang }}"> <div class="container" role="main">
{{.Content}}
</div>
{{ end }}
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}
{{ partial "header.html" . }}
<div class="container" role="main">
{{ if eq .Type "post" }}
{{ partial "post.html" . }}
{{ else if eq .Type "page" }}
{{ partial "page.html" . }}
{{ else }}
NO MATCHING PARTIAL
{{.Content}}
{{ end }}
</div>
{{ partial "footer.html" . }}
</body>
</html>

View File

@ -1,27 +1,14 @@
<!DOCTYPE html> {{ define "main" }}
<html lang="{{ .Lang }}"> {{ $data := .Data }}
<div class="container" role="main">
<article class="post-preview">
<div class="list-group col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3">
{{ range $key, $value := .Data.Terms.ByCount }}
<a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}" class="list-group-item">
{{ $value.Name }}<span class="badge">{{ $value.Count }}</span></a>
{{ end }}
</div>
</article>
</div>
{{ end }}
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}
{{ partial "header.html" . }}
{{ $data := .Data }}
<div class="container" role="main">
<article class="post-preview">
<div class="list-group col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3">
{{ range $key, $value := .Data.Terms.ByCount }}
<a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}" class="list-group-item">
{{ $value.Name }}<span class="badge">{{ $value.Count }}</span></a>
{{ end }}
</div>
</article>
</div>
{{ partial "footer.html" . }}
</body>
</html>

View File

@ -1,28 +1,19 @@
<!DOCTYPE html> {{ define "main" }}
<html lang="{{ .Lang }}"> <div role="main" class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ with .Content }}
<div class="well">
{{.}}
</div>
{{ end }}
{{ partial "head.html" . }} <div class="posts-list">
{{ $pag := .Paginate (where .Data.Pages "Type" "post") }}
<body> {{ range $pag.Pages }}
<article class="post-preview">
{{ partial "nav.html" . }}
{{ partial "header.html" . }}
<div role="main" class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ with .Content }}
<div class="well">
{{.}}
</div>
{{ end }}
<div class="posts-list">
{{ $pag := .Paginate (where .Data.Pages "Type" "post") }}
{{ range $pag.Pages }}
<article class="post-preview">
<a href="{{ .Permalink }}"> <a href="{{ .Permalink }}">
<h2 class="post-title">{{ .Title }}</h2> <h2 class="post-title">{{ .Title }}</h2>
{{ if .Params.subtitle }} {{ if .Params.subtitle }}
<h3 class="post-subtitle"> <h3 class="post-subtitle">
{{ .Params.subtitle }} {{ .Params.subtitle }}
@ -47,30 +38,26 @@
{{ end }} {{ end }}
</span> </span>
{{ end }} {{ end }}
</article>
</article>
{{ end }}
</div>
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
<ul class="pager main-pager">
{{ if .Paginator.HasPrev }}
<li class="previous">
<a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}">&larr; {{ i18n "newerPosts" }}</a>
</li>
{{ end }}
{{ if .Paginator.HasNext }}
<li class="next">
<a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}">{{ i18n "olderPosts" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ end }} {{ end }}
</div> </div>
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
<ul class="pager main-pager">
{{ if .Paginator.HasPrev }}
<li class="previous">
<a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}">&larr; {{ i18n "newerPosts" }}</a>
</li>
{{ end }}
{{ if .Paginator.HasNext }}
<li class="next">
<a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}">{{ i18n "olderPosts" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ end }}
</div> </div>
</div> </div>
</div>
{{ end }}
{{ partial "footer.html" . }}
</body>
</html>

17
layouts/page/single.html Normal file
View File

@ -0,0 +1,17 @@
{{ define "main" }}
<div class="container" role="main">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ .Content }}
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}

View File

@ -1,12 +0,0 @@
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ .Content }}
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>

View File

@ -1,29 +0,0 @@
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post">
{{ .Content }}
</article>
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; {{ i18n "previousPost" }}</a>
</li>
{{ end }}
{{ if .NextInSection }}
<li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ i18n "nextPost" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>

34
layouts/post/single.html Normal file
View File

@ -0,0 +1,34 @@
{{ define "main" }}
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post">
{{ .Content }}
</article>
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; {{ i18n "previousPost" }}</a>
</li>
{{ end }}
{{ if .NextInSection }}
<li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ i18n "nextPost" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}