cleanup formatting, compress header blocks, make header blocks easier to parse by humans, etc

This commit is contained in:
KemoNine 2022-12-04 13:55:20 -05:00
parent b9d8f157d0
commit 200d5bb3b5
5 changed files with 92 additions and 177 deletions

View file

@ -1,69 +1,72 @@
{{ define "title" }} {{ define "title" }}
{{ .Title }} · {{ .Site.Title }} {{ .Title }} · {{ .Site.Title }}
{{ end }} {{ end }}
{{ define "content" }} {{ define "content" }}
<div class="container" itemscope itemtype="http://schema.org/Recipe"> <div class="container" itemscope itemtype="http://schema.org/Recipe">
<!-- call up the image and image credit link -->
<article class="post-content px2"> <article class="post-content px2">
<!-- call up the main recipe title and content --> <!-- call up the main recipe title and content -->
<header class="post-header"> <header class="post-header">
<h1 class="post-title center m1 sm-mt3" itemprop="name">{{ .Title }}</h1> <h1 class="post-title center m1 sm-mt3" itemprop="name">{{ .Title }}</h1>
</header> </header>
<div class="recipe-source"> <div class="recipe-source center">
<div class="clearfix mt3"> <div class="clearfix mt3">
Chef: Published: {{ .PublishDate.Format "January 2, 2006" }} &bull; Last Updated: {{ .Lastmod.Format "January 2, 2006" }}
{{if .Params.authorurl }} </div>
<a href="{{.Params.authorurl}}">{{.Params.AuthorName}}</a>
{{else}}
{{.Params.AuthorName}}
{{end}}
</div>
</div>
{{ with .Params.Category }}{{ partial "taxonomy/notes" . }}{{ end }} <div class="clearfix mt3">
{{ with .Params.Tags }}{{ partial "taxonomy/tags" . }}{{ end }} Chef:
{{if .Params.authorurl }}
<a href="{{.Params.authorurl}}">{{.Params.AuthorName}}</a>
{{else}}
{{.Params.AuthorName}}
{{end}}
</div>
{{ with .Params.Category }}{{ partial "taxonomy/notes" . }}{{ end }}
{{ with .Params.Tags }}{{ partial "taxonomy/tags" . }}{{ end }}
</div> </div>
<div class="px2 mt3 clearfix"> <div class="px2 mt3 clearfix">
<div class="sm-col-8 mx-auto" itemprop="description">{{.Content}}</div> <div class="sm-col-8 mx-auto" itemprop="description">{{.Content}}</div>
</div> </div>
<br /> {{ if .Params.inspiration }}
<div class="px2 mt3 clearfix center">
{{ if .Params.inspiration }} <div class="sm-col-8 mx-auto" itemprop="description">
<div class="px2 mt3 clearfix"><div class="sm-col-8 mx-auto" itemprop="description"> <h3 class="blue mt0 mb2 xs-center">Inspiration & Resources</h3>
<h3 class="blue mt0 mb2 xs-center">Inspiration & Resources</h3> {{ range .Params.inspiration }}
{{ range .Params.inspiration }} <ul class="recipe-source">
<ul class="recipe-source"> {{ if .url }}
{{ if .url }} <li><a href="{{ .URL }}">{{ .title }}</a></li>
<li><a href="{{ .URL }}">{{ .title }}</a></li> {{ else }}
{{ else }} <li>{{ .title }}</li>
<li>{{ .title }}</li> {{ end }}
{{ end }} </ul>
</ul> {{ end }}
{{ end }} {{ end }}
{{ end }} </div>
</div></div>
</div> </div>
<!-- call up the image and image credit link -->
{{ if .Params.image }} <!-- call up the image and image credit link -->
{{ if .Params.image }}
<div class="xs-p2 center"> <div class="xs-p2 center">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
{{ with .Resources.GetMatch .Params.Image }} {{ with .Resources.GetMatch .Params.Image }}
{{ with .Fit "1000x1000" }} {{ with .Fit "1000x1000" }}
<img itemprop="image" src="{{ .RelPermalink }}" {{ if .Params.imagecaption }}alt="{{.Params.imagecaption}}"{{ end }} style="max-width:75%"/> <img itemprop="image" src="{{ .RelPermalink }}" {{ if .Params.imagecaption }}alt="{{.Params.imagecaption}}" {{ end }} style="max-width:75%" />
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if .Params.imagecaption }} {{ if .Params.imagecaption }}
<figcaption><p><b>Pictured:</b> {{ .Params.imagecaption }}</p></figcaption> <figcaption>
<p><b>Pictured:</b> {{ .Params.imagecaption }}</p>
</figcaption>
{{ end }} {{ end }}
</figure> </figure>
</div> </div>
{{ end }} {{ end }}
</article> </article>
</div> </div>
{{ end }} {{ end }}

View file

@ -1,5 +0,0 @@
<div class="categories">
<p class="clearfix">{{ i18n "category"}}:
<a href="{{ ( printf "category/%s/" ( . | urlize ) ) | relLangURL }}"><span itemprop="recipeCategory">{{ . | humanize }}</span></a>
</p>
</div>

View file

@ -1,5 +0,0 @@
<div class="categories">
<p class="clearfix">{{ i18n "cuisine"}}:
<a href="{{ ( printf "cuisine/%s/" ( . | urlize ) ) | relLangURL }}"><span itemprop="recipeCuisine">{{ . | humanize }}</span></a>
</p>
</div>

View file

@ -1,5 +0,0 @@
<div class="categories">
<p class="clearfix">{{ i18n "cuisine"}}:
<a href="{{ ( printf "notes/%s/" ( . | urlize ) ) | relLangURL }}"><span itemprop="recipeCuisine">{{ . | humanize }}</span></a>
</p>
</div>

View file

@ -1,5 +1,5 @@
{{ define "title" }} {{ define "title" }}
{{ .Title }} · {{ .Site.Title }} {{ .Title }} · {{ .Site.Title }}
{{ end }} {{ end }}
{{ define "content" }} {{ define "content" }}
@ -10,41 +10,29 @@
<h1 class="post-title center m1 sm-mt3" itemprop="name">{{ .Title }}</h1> <h1 class="post-title center m1 sm-mt3" itemprop="name">{{ .Title }}</h1>
</header> </header>
<div class="recipe-source"> <div class="recipe-source center">
<div class="clearfix mt3"> <div class="clearfix mt3">
<div class="sm-col sm-col-3"> Published: {{ .PublishDate.Format "January 2, 2006" }} &bull; Last Updated: {{ .Lastmod.Format "January 2, 2006" }}
Chef:
{{if .Params.authorurl }}
<a href="{{.Params.authorurl}}">{{.Params.AuthorName}}</a>
{{else}}
{{.Params.AuthorName}}
{{end}}
</div>
<div class="sm-col sm-col-3">
{{ with .Params.Category }}{{ partial "taxonomy/category" . }}{{ end }}
</div>
<div class="sm-col sm-col-3">
{{ with .Params.Cuisine }}{{ partial "taxonomy/cuisine" . }}{{ end }}
</div>
</div>
{{ with .Params.Tags }}{{ partial "taxonomy/tags" . }}{{ end }}
</div>
<div class="clearfix mt3">
{{ with .Params.yield }}
<div class="sm-col sm-col-3">
<h4 class="blue mt0 mb2 xs-center">{{ i18n "yields" . }}</h4>
</div> </div>
{{ end }} <div class="clearfix mt3">
{{ with .Params.prepTime }} Chef:
<div class="sm-col sm-col-3"> {{ if .Params.authorurl }}<a href="{{ .Params.authorurl }}">{{ .Params.AuthorName }}</a>{{ else }}{{ .Params.AuthorName }}{{ end }}
<h4 class="blue mt0 mb2 xs-center">{{ i18n "prepTime" . }}</h4> {{ if .Params.Category }} &bull; {{ end }}
Category: <a href="{{ ( printf "category/%s/" ( .Params.Category | urlize ) ) | relLangURL }}"><span itemprop="recipeCategory">{{ .Params.Category | humanize }}</span></a>
{{ if .Params.Cuisine }} &bull; {{ end }}
Cuisine: <a href="{{ ( printf "cuisine/%s/" ( .Params.Cuisine | urlize ) ) | relLangURL }}"><span itemprop="recipeCuisine">{{ .Params.Cuisine | humanize }}</span></a>
</div> </div>
{{ end }} <div class="clearfix mt3">
{{ with .Params.cookTime }} {{ with .Params.Tags }}{{ partial "taxonomy/tags" . }}{{ end }}
<div class="sm-col sm-col-3"> </div>
<h4 class="blue mt0 mb2 xs-center">{{ i18n "cookTime" . }}</h4> {{ if (or (or .Params.yield .Params.prepTime) .Params.cookTime) }}
<div class="clearfix mt3">
{{ if .Params.yield }}Yields: {{ .Params.yield }}{{ end }}
{{ if (and .Params.prepTime .Params.yield) }} &bull; {{ end }}
{{ if .Params.prepTime }}Prep Time: {{ .Params.prepTime }}{{ end }}
{{ if (and .Params.cookTime (or .Params.yield .Params.prepTime)) }} &bull; {{ end }}
{{ if .Params.cookTime }}Cook Time: {{ .Params.cookTime }}{{ end }}
</div> </div>
{{ end }} {{ end }}
</div> </div>
@ -52,19 +40,6 @@
<!-- call up recipe and directions --> <!-- call up recipe and directions -->
<div class="clearfix mt3"> <div class="clearfix mt3">
<div class="sm-col sm-col-6 lg-col-6 recipeItems"> <div class="sm-col sm-col-6 lg-col-6 recipeItems">
<!-- check if it's a component-based recipe -->
{{ with .Params.Components}}
<h4 class="blue mt0 mb2 xs-center">{{ i18n "components" }}</h4>
<ul>
<!-- list components that make up recipe -->
{{ range . }}
<li>
{{ with ( . | markdownify) }}{{ partial "recipe_item.html" . }}{{ end }}
</li>
{{ end }}
</ul>
{{ end }}
{{ with .Params.Ingredients }} {{ with .Params.Ingredients }}
<h4 class="blue mt0 mb2 xs-center">{{ i18n "ingredients" }}</h4> <h4 class="blue mt0 mb2 xs-center">{{ i18n "ingredients" }}</h4>
<ul itemprop="ingredients"> <ul itemprop="ingredients">
@ -78,103 +53,55 @@
{{ end }} {{ end }}
</div> </div>
{{ if .Params.directions }}
<div class="sm-col sm-col-6 lg-col-6 recipeItems"> <div class="sm-col sm-col-6 lg-col-6 recipeItems">
<h4 class="blue mt0 mb2 xs-center">{{ i18n "directions" }}</h4> <h4 class="blue mt0 mb2 xs-center">{{ i18n "directions" }}</h4>
<ul itemprop="recipeInstructions"> <ul itemprop="recipeInstructions">
{{ range .Params.Directions }} {{ range .Params.Directions }}
<li> <li>
{{ with ( . | markdownify) }}{{ partial "recipe_item.html" . }}{{ end }}</li> {{ with ( . | markdownify) }}{{ partial "recipe_item.html" . }}{{ end }}
</li>
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
</div> </div>
{{ end }}
<!-- end recipe and directions --> <!-- end recipe and directions -->
<div class="px2 mt3 clearfix"> <div class="px2 mt3 clearfix">
<div class="sm-col-8 mx-auto" itemprop="description">{{.Content}}</div> <div class="sm-col-8 mx-auto" itemprop="description">{{.Content}}</div>
</div> </div>
<!-- check if it's a component-based recipe, render it -->
{{ with .Params.Components }}
<div class="components bg-darken-2 p2 mt3 mb3 center">
&darr; {{ i18n "this-is-a" }} <strong class="blue">{{ i18n "component-based-recipe" }}</strong> ({{ i18n "fancy-talk" }}). &darr;
</div>
<div class="clearfix mxn2">
{{ range . }}
{{ $compTitle := . }}
<div class="sm-col sm-col-4 px2 recipeItems">
{{ range where $.Site.Pages "Title" $compTitle }}
<h4 class="blue center"><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
{{ range (.Resources.ByType "image") }}
<div class="image ratio bg-cover" style="background-image:url({{$.Site.BaseURL}}{{ .RelPermalink }});">
<img class="hide" itemprop="photo" src="{{$.Site.BaseURL}}{{ .RelPermalink }}" />
</div>
{{ end }}
{{ if .Params.Imagecredit }}
<a href="{{ .Params.Imagecredit }}" class="right">
<svg class="js-geomicon geomicon" width="14" height="14" data-icon="camera" viewBox="0 0 32 32" style="fill:currentcolor">
<title>camera icon</title>
<path d="M0 6 L8 6 L10 2 L22 2 L24 6 L32 6 L32 28 L0 28 z M9 17 A7 7 0 0 0 23 17 A7 7 0 0 0 9 17"></path>
</svg>
</a>
{{ end }}
<h4 class="blue regular xs-center">{{ i18n "ingredients" }}</h4>
<ul class="ingredients" itemprop="ingredients">
{{ range .Params.Ingredients }}
<li itemprop="ingredient">
{{ with ( . | markdownify) }}{{ partial "recipe_item.html" . }}{{ end }}
</li>
{{ end }}
</ul>
<h4 class="blue regular xs-center">{{ i18n "steps" }}</h4>
<ul itemprop="instructions">
{{ range .Params.Directions }}
<li>
{{ with ( . | markdownify) }}{{ partial "recipe_item.html" . }}{{ end }}
</li>
{{ end }}
</ul>
{{ end }}
</div>
{{ end }}
</div>
{{ end }}
<!-- end components -->
<br />
{{ if .Params.inspiration }} {{ if .Params.inspiration }}
<h3 class="blue mt0 mb2 xs-center center">Inspiration & Resources</h3> <h3 class="blue mt0 mb2 xs-center center">Inspiration & Resources</h3>
{{ range .Params.inspiration }} {{ range .Params.inspiration }}
<ul class="center"> <ul class="center">
{{ if .url }} {{ if .url }}
<li><a href="{{ .url | safeURL }}">{{ .title }}</a></li> <li><a href="{{ .url | safeURL }}">{{ .title }}</a></li>
{{ else }} {{ else }}
<li>{{ .title }}</li> <li>{{ .title }}</li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
{{ end }} {{ end }}
<!-- call up the image and image credit link --> <!-- call up the image and image credit link -->
{{ if .Params.image }} {{ if .Params.image }}
<div class="xs-p2 center"> <div class="xs-p2 center">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
{{ with .Resources.GetMatch .Params.Image }} {{ with .Resources.GetMatch .Params.Image }}
{{ with .Fit "1000x1000" }} {{ with .Fit "1000x1000" }}
<img itemprop="image" src="{{ .RelPermalink }}" {{ if .Params.imagecaption }}alt="{{.Params.imagecaption}}"{{ end }} style="max-width:75%"/> <img itemprop="image" src="{{ .RelPermalink }}" {{ if .Params.imagecaption }}alt="{{.Params.imagecaption}}" {{ end }} style="max-width:75%" />
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if .Params.imagecaption }} {{ if .Params.imagecaption }}
<figcaption><p><b>Pictured:</b> {{ .Params.imagecaption }}</p></figcaption> <figcaption>
<p><b>Pictured:</b> {{ .Params.imagecaption }}</p>
</figcaption>
{{ end }} {{ end }}
</figure> </figure>
</div> </div>
{{ end }} {{ end }}
</article> </article>
</div> </div>
{{ end }} {{ end }}