mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 18:31:45 +01:00
reafctor(head): rewrite description.html function
This commit is contained in:
parent
6f5ee1bbdb
commit
5265af0b3b
4 changed files with 28 additions and 18 deletions
|
@ -1,11 +1,12 @@
|
|||
{{- with .Description -}}
|
||||
{{- . -}}
|
||||
{{- else -}}
|
||||
{{- if .IsPage -}}
|
||||
{{- .Summary -}}
|
||||
{{- else -}}
|
||||
{{- with .Site.Params.subtitle -}}
|
||||
{{- . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<!-- Use site subtitle by default -->
|
||||
{{ $description := .Site.Params.subtitle }}
|
||||
|
||||
{{ if .Description }}
|
||||
<!-- Page description exists -->
|
||||
{{ $description = .Description }}
|
||||
{{ else if .IsPage }}
|
||||
<!-- Use page summary -->
|
||||
{{ $description = .Summary }}
|
||||
{{ end }}
|
||||
|
||||
{{ return ($description | plainify)}}
|
|
@ -1,10 +1,13 @@
|
|||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<meta name='description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
|
||||
{{- $description := partial "data/description" . -}}
|
||||
<meta name='description' content='{{ $description }}'>
|
||||
|
||||
{{- $title := partial "data/title" . -}}
|
||||
<title>{{ $title }}</title>
|
||||
<title>{{ $title }}</title>
|
||||
|
||||
<link rel='canonical' href='{{ .Permalink }}'>
|
||||
|
||||
{{- partial "head/style.html" . -}}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<meta property='og:title' content='{{ partial "data/title" . }}'>
|
||||
<meta property='og:description' content='{{ chomp (partial "data/description" . | plainify ) }}'>
|
||||
{{- $title := partial "data/title" . -}}
|
||||
{{- $description := partial "data/description" . -}}
|
||||
|
||||
<meta property='og:title' content='{{ $title }}'>
|
||||
<meta property='og:description' content='{{ $description }}'>
|
||||
<meta property='og:url' content='{{ .Permalink }}'>
|
||||
<meta property='og:site_name' content='{{ .Site.Title }}'>
|
||||
<meta property='og:type' content='
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
<meta name="twitter:site" content="{{ . }}">
|
||||
{{- end -}}
|
||||
|
||||
<meta name="twitter:title" content="{{ partial "data/title" . }}">
|
||||
<meta name="twitter:description" content="{{ chomp (partial "data/description" . | plainify ) }}">
|
||||
{{- $title := partial "data/title" . -}}
|
||||
{{- $description := partial "data/description" . -}}
|
||||
|
||||
<meta name="twitter:title" content="{{ $title }}">
|
||||
<meta name="twitter:description" content="{{ $description }}">
|
||||
|
||||
{{- $image := partial "helper/image" (dict "Context" . "Type" "opengraph") -}}
|
||||
{{- if $image.exists -}}
|
||||
|
|
Loading…
Reference in a new issue