{{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}} | {{/* Now, range through the next four after the initial $n_posts items. Nest the requirements, "after" then "first" on the outside */}} | ||||
{{ range (first 4 (after $n_posts $section)) }} | {{ range (first 4 (after $n_posts $section)) }} | ||||
<h2 class="f5 fw4 mb4 dib mr3"> | <h2 class="f5 fw4 mb4 dib mr3"> | ||||
<a href="{{ .Permalink }}" class="link black dim"> | |||||
<a href="{{ .RelPermalink }}" class="link black dim"> | |||||
{{ .Title }} | {{ .Title }} | ||||
</a> | </a> | ||||
</h2> | </h2> | ||||
{{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}} | {{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}} | ||||
{{ with .Site.GetPage "section" $section_name }} | {{ with .Site.GetPage "section" $section_name }} | ||||
<a href="{{ .Permalink }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a> | |||||
<a href="{{ .RelPermalink }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a> | |||||
{{ end }} | {{ end }} | ||||
</section> | </section> | ||||
{{ end }} | {{ end }} |
{{/* | {{/* | ||||
GetFeaturedImage | GetFeaturedImage | ||||
This partial gets the url for featured image for a given page. | |||||
This partial gets the url for featured image for a given page. | |||||
If a featured_image was set in the page's front matter, then that will be used. | If a featured_image was set in the page's front matter, then that will be used. | ||||
If not set, this will search page resources to find an image that contains the word | If not set, this will search page resources to find an image that contains the word | ||||
If no featured_image was set, and there's no "cover" image in page resources, then | If no featured_image was set, and there's no "cover" image in page resources, then | ||||
this partial returns an empty string (which evaluates to false). | this partial returns an empty string (which evaluates to false). | ||||
@return Permalink to featured image, or an empty string if not found. | |||||
@return RelPermalink to featured image, or an empty string if not found. | |||||
*/}} | */}} | ||||
{{ else }} | {{ else }} | ||||
{{ $img := (.Resources.ByType "image").GetMatch "*cover*" }} | {{ $img := (.Resources.ByType "image").GetMatch "*cover*" }} | ||||
{{ with $img }} | {{ with $img }} | ||||
{{ $linkToCover = .Permalink }} | |||||
{{ $linkToCover = .RelPermalink }} | |||||
{{ end }} | {{ end }} | ||||
{{ end }} | {{ end }} | ||||
{{/* return either a permalink, or an empty string. Note that partials can only have a single | {{/* return either a permalink, or an empty string. Note that partials can only have a single | ||||
return statement, so this needs to be at the end of the partial (and not in the if block) */}} | return statement, so this needs to be at the end of the partial (and not in the if block) */}} | ||||
{{ return $linkToCover }} | |||||
{{ return $linkToCover }} |
{{ $title := .Title }} | {{ $title := .Title }} | ||||
{{ $url := printf "%s" .Permalink | absLangURL }} | |||||
{{ $url := printf "%s" .RelPermalink | absLangURL }} | |||||
{{ $icon_size := "32px" }} | {{ $icon_size := "32px" }} | ||||
{{ if not .Params.disable_share }} | {{ if not .Params.disable_share }} |
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} | {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} | ||||
{{ $featured_image := (trim $featured_image "/") | absURL }} | {{ $featured_image := (trim $featured_image "/") | absURL }} | ||||
<div class="pr3-ns mb4 mb0-ns w-100 w-40-ns"> | <div class="pr3-ns mb4 mb0-ns w-100 w-40-ns"> | ||||
<a href="{{.Permalink}}" class="db grow"> | |||||
<a href="{{.RelPermalink}}" class="db grow"> | |||||
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}"> | <img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}"> | ||||
</a> | </a> | ||||
</div> | </div> | ||||
{{ end }} | {{ end }} | ||||
<div class="blah w-100{{ if $featured_image }} w-60-ns pl3-ns{{ end }}"> | <div class="blah w-100{{ if $featured_image }} w-60-ns pl3-ns{{ end }}"> | ||||
<h1 class="f3 fw1 athelas mt0 lh-title"> | <h1 class="f3 fw1 athelas mt0 lh-title"> | ||||
<a href="{{.Permalink}}" class="color-inherit dim link"> | |||||
<a href="{{.RelPermalink}}" class="color-inherit dim link"> | |||||
{{ .Title }} | {{ .Title }} | ||||
</a> | </a> | ||||
</h1> | </h1> | ||||
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links"> | <div class="f6 f5-l lh-copy nested-copy-line-height nested-links"> | ||||
{{ .Summary }} | {{ .Summary }} | ||||
</div> | </div> | ||||
<a href="{{.Permalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a> | |||||
<a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a> | |||||
{{/* TODO: add author | {{/* TODO: add author | ||||
<p class="f6 lh-copy mv0">By {{ .Author }}</p> */}} | <p class="f6 lh-copy mv0">By {{ .Author }}</p> */}} | ||||
</div> | </div> |
<div class="bg-white mb3 pa4 gray overflow-hidden"> | <div class="bg-white mb3 pa4 gray overflow-hidden"> | ||||
<span class="f6 db">{{ humanize .Section }}</span> | <span class="f6 db">{{ humanize .Section }}</span> | ||||
<h1 class="f3 near-black"> | <h1 class="f3 near-black"> | ||||
<a href="{{ .Permalink }}" class="link black dim"> | |||||
<a href="{{ .RelPermalink }}" class="link black dim"> | |||||
{{ .Title }} | {{ .Title }} | ||||
</a> | </a> | ||||
</h1> | </h1> |
<article class="bb b--black-10"> | <article class="bb b--black-10"> | ||||
<a class="db pv4 ph3 ph0-l no-underline dark-gray dim" href="{{ .Permalink }}"> | |||||
<a class="db pv4 ph3 ph0-l no-underline dark-gray dim" href="{{ .RelPermalink }}"> | |||||
<div class="flex flex-column flex-row-ns"> | <div class="flex flex-column flex-row-ns"> | ||||
{{ $featured_image := partial "func/GetFeaturedImage.html" . }} | {{ $featured_image := partial "func/GetFeaturedImage.html" . }} | ||||
{{ if $featured_image }} | {{ if $featured_image }} |
</div> | </div> | ||||
{{ end }} | {{ end }} | ||||
<h1 class="f3 near-black"> | <h1 class="f3 near-black"> | ||||
<a href="{{ .Permalink }}" class="link black dim"> | |||||
<a href="{{ .RelPermalink }}" class="link black dim"> | |||||
{{ .Title }} | {{ .Title }} | ||||
</a> | </a> | ||||
</h1> | </h1> |