mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-09-11 01:25:32 -04:00
strip any markdown in page titles from meta/social tags in head
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{{- $section := $.Site.GetPage "section" .Section }}
|
||||
{{- range .Site.AllPages -}}
|
||||
{{- if or (and (.IsDescendant $section) (and (not .Draft) (not .Params.private))) $section.IsHome -}}
|
||||
{{- $.Scratch.Add "index" (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "description" .Description "kind" .Kind "lang" .Lang "lastmod" .Lastmod.UTC.Unix "permalink" .Permalink "publishdate" .PublishDate "readingtime" .ReadingTime "summary" .Summary "title" .Title "type" .Type "url" .RelPermalink "weight" .Weight "wordcount" .WordCount "section" .Section "tags" .Params.Tags "authors" $.Site.Author.name)}}
|
||||
{{- $.Scratch.Add "index" (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "description" .Description "kind" .Kind "lang" .Lang "lastmod" .Lastmod.UTC.Unix "permalink" .Permalink "publishdate" .PublishDate "readingtime" .ReadingTime "summary" .Summary "title" (.Title | markdownify | htmlUnescape | plainify) "type" .Type "url" .RelPermalink "weight" .Weight "wordcount" .WordCount "section" .Section "tags" .Params.Tags "authors" $.Site.Author.name)}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $.Scratch.Get "index" | jsonify -}}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!doctype html>
|
||||
<html ⚡ lang="en">
|
||||
<head>
|
||||
{{ partial "functions/meta-scratch" . }}
|
||||
<meta charset="utf-8">
|
||||
{{ hugo.Generator }}
|
||||
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
||||
@@ -12,7 +13,7 @@
|
||||
{{ if .HasShortcode "gist" }}<script async custom-element="amp-gist" src="https://cdn.ampproject.org/v0/amp-gist-0.1.js"></script>{{ end }}
|
||||
{{ if .HasShortcode "instagram" }}<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-0.1.js"></script>{{ end }}
|
||||
{{ if .HasShortcode "vimeo" }}<script async custom-element="amp-vimeo" src="https://cdn.ampproject.org/v0/amp-vimeo-0.1.js"></script>{{ end }}
|
||||
<title>{{ .Title }} – {{ .Site.Title }}</title>
|
||||
<title>{{ .Scratch.Get "plainTitle" }} – {{ .Site.Title }}</title>
|
||||
{{ with .OutputFormats.Get "html" }}<link rel="canonical" href="{{ .Permalink }}">{{ end }}
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
{{- $img := partial "functions/social-images" . -}}
|
||||
{{- $img := partial "functions/meta-scratch" . -}}
|
||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title>{{ .Site.Title }}</title>
|
||||
@@ -23,7 +23,7 @@
|
||||
{{- end }}
|
||||
{{- range (where .Site.RegularPages "Section" .Site.Params.mainSection) }}
|
||||
<entry>
|
||||
<title>{{ .Title }}</title>
|
||||
<title>{{ .Title | markdownify | htmlUnescape | plainify }}</title>
|
||||
{{- with .Site.Author.name }}
|
||||
<author>
|
||||
<name>{{ . }}</name>
|
||||
|
||||
+6
@@ -1,3 +1,9 @@
|
||||
{{/* Strip any markdown styling from page title for use in meta tags */}}
|
||||
|
||||
{{- with .Title -}}
|
||||
{{- $.Scratch.Set "plainTitle" (. | markdownify | htmlUnescape | plainify) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Chooses and initializes various images for use by JSON schema & open graph tags */}}
|
||||
|
||||
{{/* Author image (default) */}}
|
||||
@@ -1,5 +1,5 @@
|
||||
{{ partial "functions/meta-scratch" . -}}
|
||||
{{ partial "head/meta" . -}}
|
||||
{{ partial "functions/social-images" . -}}
|
||||
{{ partial "head/open-graph" . -}}
|
||||
{{ partialCached "head/mobile" . -}}
|
||||
{{ partialCached "head/preload" . -}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<meta charset="utf-8">
|
||||
{{ hugo.Generator }}
|
||||
<title>{{ .Title }}{{ if not .IsHome }} – {{ .Site.Title }}{{ else }} 👨💻{{ end }}</title>
|
||||
<title>{{ .Scratch.Get "plainTitle" }}{{ if not .IsHome }} – {{ .Site.Title }}{{ end }}</title>
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<meta property="og:title" content="{{ .Title }}">
|
||||
<meta property="og:title" content="{{ .Scratch.Get "plainTitle" }}">
|
||||
<meta property="og:site_name" content="{{ .Site.Title }}">
|
||||
<meta property="og:type" content="{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}article{{ else }}website{{ end }}">
|
||||
<meta property="og:locale" content="en_US">
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta property="og:image:type" content="{{ .MediaType }}">
|
||||
<meta property="og:image:width" content="{{ .Width }}">
|
||||
<meta property="og:image:height" content="{{ .Height }}">
|
||||
<meta property="og:image:alt" content="{{ $.Title }}">
|
||||
<meta property="og:image:alt" content="{{ $.Scratch.Get "plainTitle" }}">
|
||||
{{ end -}}
|
||||
|
||||
{{- if and .IsPage (eq .Type .Site.Params.mainSection) }}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"@type": "BlogPosting",
|
||||
"url": {{ with .OutputFormats.Get "html" }}{{ .Permalink }}{{ end }},
|
||||
"mainEntityOfPage": {{ with .OutputFormats.Get "html" }}{{ .Permalink }}{{ end }},
|
||||
"name": {{ .Title }},
|
||||
"headline": {{ .Title }},
|
||||
"name": {{ .Scratch.Get "plainTitle" }},
|
||||
"headline": {{ .Scratch.Get "plainTitle" }},
|
||||
"datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }},
|
||||
"dateModified": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }},
|
||||
"keywords": {{ with .Params.tags }}{{ delimit . ", " }}{{ end }},
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
{{- $img := partial "functions/social-images" . -}}
|
||||
{{- $img := partial "functions/meta-scratch" . -}}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ .Site.Title }}</title>
|
||||
@@ -19,7 +19,7 @@
|
||||
{{ end }}
|
||||
{{- range (where .Site.RegularPages "Section" .Site.Params.mainSection) }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<title>{{ .Title | markdownify | htmlUnescape | plainify }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</author>{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user