use partial for referenced <link>
s
This commit is contained in:
parent
fd6fc99ab0
commit
54a41716c6
3 changed files with 108 additions and 77 deletions
|
@ -1,8 +1,7 @@
|
||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
{{ partialCached "copying.html" . }}
|
{{ partialCached "copying.html" . }}
|
||||||
|
|
||||||
|
|
||||||
<html
|
<html
|
||||||
class="h-card"
|
class="h-card"
|
||||||
lang="en-gb"
|
lang="en-gb"
|
||||||
|
@ -22,87 +21,20 @@
|
||||||
{{- partialCached "head/title.html" ( slice .Site.Title .Site.Params.tagline ) .Site.Title .Site.Params.tagline -}}
|
{{- partialCached "head/title.html" ( slice .Site.Title .Site.Params.tagline ) .Site.Title .Site.Params.tagline -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<link
|
<!-- References -->
|
||||||
rel="license"
|
{{- partialCached "head/references.html" ( dict "sc" $ "pc" . ) -}}
|
||||||
href="{{ block "head-license" . }}https://creativecommons.org/publicdomain/zero/1.0/{{ end }}"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
class="u-url u-uid"
|
|
||||||
rel="me"
|
|
||||||
href="{{ .Site.Home.Permalink }}"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
class="u-email"
|
|
||||||
rel="me"
|
|
||||||
href="mailto:me+bg@bengoldsworthy.net"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
class="u-url"
|
|
||||||
rel="me"
|
|
||||||
href="https://github.com/Rumperuu"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
class="u-url"
|
|
||||||
rel="me"
|
|
||||||
href="https://news.ycombinator.com/user?id=Rumperuu"
|
|
||||||
/>
|
|
||||||
<link
|
|
||||||
class="u-logo"
|
|
||||||
rel="icon"
|
|
||||||
sizes="192x192"
|
|
||||||
href="/images/icon.png"
|
|
||||||
/>
|
|
||||||
{{- with .Site.Params.keyfile -}}
|
|
||||||
<link
|
|
||||||
class="u-key"
|
|
||||||
rel="author"
|
|
||||||
href="{{ . }}"
|
|
||||||
/>
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
|
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="{{ .Permalink }}"
|
href="{{- .Permalink -}}"
|
||||||
/>
|
/>
|
||||||
|
{{- with .OutputFormats.Get "rss" -}}
|
||||||
{{ with .OutputFormats.Get "rss" -}}
|
|
||||||
<link
|
<link
|
||||||
rel="{{ .Rel }}"
|
rel="{{ .Rel }}"
|
||||||
type="{{ .MediaType.Type | html }}"
|
type="{{ .MediaType.Type | html }}"
|
||||||
href="{{ .RelPermalink }}"
|
href="{{ .RelPermalink }}"
|
||||||
title="{{ $.Site.Title | safeHTML }}"
|
title="{{ $.Site.Title | safeHTML }}"
|
||||||
/>
|
/>
|
||||||
{{- end }}
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
<link
|
|
||||||
href="/css/sanitize.css"
|
|
||||||
rel="stylesheet"
|
|
||||||
/>
|
|
||||||
{{- $mainStylesheet := resources.Get "css/main.scss" }}
|
|
||||||
{{- $mainStylesheet := $mainStylesheet | css.Sass | resources.Fingerprint }}
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href="{{ $mainStylesheet.Permalink }}"
|
|
||||||
integrity="{{ $mainStylesheet.Data.Integrity | html }}"
|
|
||||||
/>
|
|
||||||
{{- $printStylesheet := resources.Get "css/print.scss" }}
|
|
||||||
{{- $printStylesheet := $printStylesheet | css.Sass | resources.Fingerprint }}
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
media="print"
|
|
||||||
href="{{ $printStylesheet.Permalink }}"
|
|
||||||
integrity="{{ $printStylesheet.Data.Integrity | html }}"
|
|
||||||
/>
|
|
||||||
{{- $feedsStylesheet := resources.Get "css/feeds.scss" }}
|
|
||||||
{{- $feedsStylesheet := $feedsStylesheet | css.Sass }}
|
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="{{ $feedsStylesheet.Permalink }}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{{- if .Param "math" -}}
|
{{- if .Param "math" -}}
|
||||||
{{- partialCached "head/math.html" . -}}
|
{{- partialCached "head/math.html" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -113,10 +45,9 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="site-container site-container{{ block "main-class" . }}layouts-default-baseof{{ end }}">
|
<body class="site-container site-container{{ block "main-class" . }}layouts-default-baseof{{ end }}">
|
||||||
{{ block "header" . -}}
|
{{- block "header" . -}}
|
||||||
{{- partialCached "header/site-header.html" . -}}
|
{{- partialCached "header/site-header.html" . -}}
|
||||||
{{- end }}
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
<article
|
<article
|
||||||
class="{{ block "article-class" . }}h-entry{{ end }}site-content site-content{{ block "main-class" . }}{{ end }}"
|
class="{{ block "article-class" . }}h-entry{{ end }}site-content site-content{{ block "main-class" . }}{{ end }}"
|
||||||
|
|
54
layouts/partials/head/references.html
Normal file
54
layouts/partials/head/references.html
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{{- /*
|
||||||
|
Displays comments for an item
|
||||||
|
|
||||||
|
@params pc Page context
|
||||||
|
@params sc Site context
|
||||||
|
*/
|
||||||
|
-}}
|
||||||
|
|
||||||
|
<!-- Validation -->
|
||||||
|
|
||||||
|
{{- if ( not ( isset . "sc" ) ) -}}
|
||||||
|
{{- errorf "No site context received" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if ( not ( isset . "pc" ) ) -}}
|
||||||
|
{{- errorf "No page context received (%q)" .sc.Page.File.Dir -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<!-- Rendering -->
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="license"
|
||||||
|
href="{{- partialCached "util/get_licence_link.html" ( dict "licences_data" .sc.Site.Data.licences "licence" .sc.Site.Params.licence "licence_link" .sc.Site.Params.licence_link ) -}}"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
class="u-url u-uid"
|
||||||
|
rel="me"
|
||||||
|
href="{{- .sc.Site.Home.Permalink -}}"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
class="u-email"
|
||||||
|
rel="me"
|
||||||
|
href="mailto:{{- .sc.Site.Params.author.email -}}"
|
||||||
|
/>
|
||||||
|
{{- range .sc.Site.Params.meLinks -}}
|
||||||
|
<link
|
||||||
|
class="u-url"
|
||||||
|
rel="me"
|
||||||
|
href="{{ . }}"
|
||||||
|
/>
|
||||||
|
{{- end -}}
|
||||||
|
<link
|
||||||
|
class="u-logo"
|
||||||
|
rel="icon"
|
||||||
|
sizes="192x192"
|
||||||
|
href="/images/icon.png"
|
||||||
|
/>
|
||||||
|
{{- with .sc.Site.Params.keyfile -}}
|
||||||
|
<link
|
||||||
|
class="u-key"
|
||||||
|
rel="author"
|
||||||
|
href="{{- . -}}"
|
||||||
|
/>
|
||||||
|
{{- end -}}
|
46
layouts/partials/util/get_licence_link.html
Normal file
46
layouts/partials/util/get_licence_link.html
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{{- /*
|
||||||
|
Returns the URL for a given licence, either from the site data or from a defined URL.
|
||||||
|
|
||||||
|
@params licences_data Site data of licences, indexed by SPDX IDs.
|
||||||
|
@params licence Licence identifier.
|
||||||
|
@params licence_link Manually-defined licence URL. Optional.
|
||||||
|
*/
|
||||||
|
-}}
|
||||||
|
|
||||||
|
<!-- Validation -->
|
||||||
|
|
||||||
|
{{- if ( not ( isset . "licences_data" ) ) -}}
|
||||||
|
{{- errorf "No licence data passed to partial" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if ( not ( isset . "licence" ) ) -}}
|
||||||
|
{{- errorf "No licence requested in partial" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<!-- Variable assignment -->
|
||||||
|
|
||||||
|
{{- $licences_data := .licences_data -}}
|
||||||
|
{{- $licence := .licence -}}
|
||||||
|
{{- $licence_link := .licence_link -}}
|
||||||
|
|
||||||
|
{{- $final_licence_link := "" -}}
|
||||||
|
|
||||||
|
<!-- Rendering -->
|
||||||
|
|
||||||
|
{{- if ( index $licences_data $licence ) -}}
|
||||||
|
{{- if eq ( index $licences_data $licence ) $licence_link -}}
|
||||||
|
{{- warnf "Redundant license link '%s' defined, it already exists in the site data" ( index $licences_data $licence ) -}}
|
||||||
|
{{- $final_licence_link = ( index $licences_data $licence ) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- if ( and ( $licence_link ) ( not ( eq ( index $licences_data $licence ) $licence_link ) ) ) -}}
|
||||||
|
{{- warnf "Licence '%s' has a different link ('%s') defined in the site data, using '%s' instead" $licence ( index $licences_data $licence ) $licence_link -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $final_licence_link = $licence_link -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- else if $licence_link -}}
|
||||||
|
{{- warnidf "licence-link-not-in-site-data" "License link '%s' for licence '%s' should be in the site data, unless it's rarely used" $licence_link $licence -}}
|
||||||
|
{{- $final_licence_link = $licence_link -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- return $final_licence_link -}}
|
Loading…
Add table
Add a link
Reference in a new issue