feat: new style and faster

This commit is contained in:
Dillon
2019-08-12 01:36:19 +08:00
parent a8bb44da3a
commit 9433736ede
75 changed files with 2330 additions and 4364 deletions

View File

@@ -1,11 +1,3 @@
{{ $cdn_url := ""}}
{{ if eq ( getenv "HUGO_ENV" ) "production" }}
{{ with .Site.Params.cdn_url }}
{{ $cdn_url = .}}
{{ end }}
{{ end }}
{{ .Scratch.Set "cdn_url" $cdn_url }}
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
@@ -13,6 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
{{ partial "head.html" . }}
{{ $style := resources.Get "css/style.scss" | resources.ToCSS | resources.Minify}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
</head>
<body class="">
<div class="wrapper">
@@ -24,5 +18,6 @@
</main>
{{ partial "footer.html" . }}
</div>
{{ partial "js.html" . }}
</body>
</html>

View File

@@ -1,7 +1,7 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
<div class="post-warp archive">
<div class="post-warp">
<h2 class="post-title" style="text-align:right;padding-bottom:2em">{{ .Title }}</h2>
<div class="post-content">
{{ .Content }}

View File

@@ -7,19 +7,25 @@
<link href="{{ .Permalink }}index.xml" rel="self"/>
<link href="{{ .Permalink }}"/>{{ if not .Date.IsZero }}
<updated>{{ .Date.Format "02-01-2006T15:04:05-07:00" | safeHTML }}</updated>{{ end }}
<id>{{ .Permalink }}</id>{{ with .Site.Author.name }}
<id>{{ .Permalink }}</id>
<author>
<name>{{.}}</name>{{ with $.Site.Author.email }}
<email>{{.}}</email>{{end}}
</author>{{end}}
{{ with .Site.Author.name }}
<name>{{ . }}</name>
{{ end }}
{{ with $.Site.Author.email }}
<email>{{ . }}</email>
{{ end }}
</author>
<generator>Hugo -- gohugo.io</generator>{{ range first 15 (where .Data.Pages "Type" "in" .Site.Params.mainSections) }}
<entry>
{{ `<title type="html"><![CDATA[` | safeHTML }}{{ .Title }}]]></title>
<link href="{{ .Permalink }}"/>
<id>{{ .Permalink }}</id>{{ with .Site.Params.Author }}
<author>
<name>{{.}}</name>
</author>{{end}}
<id>{{ .Permalink }}</id>
{{ with .Site.Author.Name }}
<author>
<name>{{ . }}</name>
</author>
{{ end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}]]></content>

View File

@@ -1,7 +1,15 @@
{{ define "content" }}
{{ if eq .Site.Params.home_mode "post" }}
{{ partial "home_post.html" . }}
<div class="post-warp">
{{ partial "home/profile.html" . }}
{{ range (.Paginate (where .Pages "Type" "posts")).Pages }}
{{ .Render "summary" }}
{{ end }}
{{ partial "paginator.html" . }}
</div>
{{ else }}
{{ partial "home_profile.html" . }}
{{ partial "home/profile.html" . }}
{{ end }}
{{ end }}

View File

@@ -1,4 +0,0 @@
{{ $style := resources.Get "css/main.scss" | resources.ToCSS | resources.Minify}}
{{ $iconfont := resources.Get "font/iconfont.css" | resources.Minify }}
<link rel="stylesheet" href="{{ $iconfont.RelPermalink }}">
<link rel="stylesheet" href="{{ $style.RelPermalink }}">

View File

@@ -3,13 +3,12 @@
&copy;
{{ with .Site.Params.since }}
<span itemprop="copyrightYear">{{ if lt . now.Year }}{{ . }} - {{ end }}{{ now.Year }}</span>
{{ else }}
<span itemprop="copyrightYear">{{ now.Year }}</span>
{{ end }}
{{ if .Site.Params.author }}
<span class="author" itemprop="copyrightHolder"><a href="{{ .Site.BaseURL }}">{{ .Site.Params.author }}</a> |
</span>
{{ with .Site.Author.Name }}
<span class="author" itemprop="copyrightHolder"><a href="{{ .Site.BaseURL }}">{{ . }}</a> | </span>
{{ end }}
<span>{{ (printf (T "powered") `<a href="https://gohugo.io/" target="_blank" rel="external nofollow noopener noreffer">Hugo</a>`) | safeHTML }} | {{ T "theme" }}<a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="external nofollow noopener noreffer">LoveIt</a></span>
</div>
</footer>
{{ partial "js.html" . }}

View File

@@ -31,8 +31,6 @@
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
{{ partial "css.html" . }}
{{ with .OutputFormats.Get "RSS" }}
<link rel="alternate" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ site.Title }}">
<link rel="feed" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ site.Title }}">

View File

@@ -1,11 +1,9 @@
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<div class="intro">
{{ $avatar := "" }}
{{ if or .Params.gravatar.Email (and .Site.Params.gravatar.Email (ne .Params.gravatar.Email false)) }}
{{ $avatar = (printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" (md5 .Site.Params.gravatar.email)) }}
{{ else if .Site.Params.avatar }}
{{ $avatar = (printf "%s%s" $cdn_url .Site.Params.avatar) }}
{{ $avatar = .Site.Params.avatar }}
{{ end }}
{{ if $avatar }}
<div class="avatar">
@@ -22,12 +20,12 @@
<div id={{ $id }} class="typeit"></div>
<script>
var typeitMap = window.typeitMap || {};
typeitMap[{{ $id }}] = true;
typeitMap["{{ $id }}"] = true;
</script>
</h2>
{{ end }}
<div class="social-links">
{{ partial "social.html" . }}
{{ partial "home/social.html" . }}
</div>
</div>

View File

@@ -1,59 +0,0 @@
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<div class="post-warp">
{{ partial "intro.html" . }}
{{ range (.Paginate (where .Pages "Type" "posts")).Pages }}
<article class="post" itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>
</header>
<div class="post-content">
<!--featured_image-->
{{ with .Params.featured_image }}
{{ $img := . }}
<p>
<img itemprop="image" src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image">
</p>
{{ end }}
<!-- end featured_image-->
{{ .Summary }}
</div>
<div class="post-footer">
<div class="post-meta">
<span class="post-time">
<time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">
{{ .Date.Format (.Site.Params.dateFormatToUse | default "2 January 2006") }}
</time>
</span>
in
{{ with .Params.categories }}
<i class="iconfont icon-folder"></i>
<span class="post-category">
{{ range . }}
{{ $name := . }}
{{ with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) }}
<a href="{{ .Permalink }}">{{ $name }}</a>
{{ end }}
{{ end }}
</span>
{{ end }}
</div>
{{ with .Params.tags }}
<div class="post-tags">
{{ range . }}
<span class="tag">
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{ . }}</a>
</span>
{{ end }}
</div>
{{ end }}
</div>
</article>
{{ end }}
{{ partial "paginator.html" . }}
</div>

View File

@@ -1 +0,0 @@
{{ partial "intro.html" . }}

View File

@@ -1,20 +1,10 @@
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ $postHasImages := .Scratch.Get "postHasImages" }}
{{ $scripts := resources.Get "/js/main.js" | slice }}
{{ $dynamicToTop := resources.Get "/js/dynamicToTop.min.js" }}
{{ $lightGallery_init := resources.Get "/js/lightGallery-init.js" }}
{{ $dynamicToTop := resources.Get "/js/dynamicToTop.js" }}
<!-- jQuery https://github.com/jquery/jquery -->
{{ $jquery := `
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
` }}
<!-- lightGallery https://github.com/sachinchoolur/lightGallery -->
{{ $lightGallery := `
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.12/dist/css/lightgallery.min.css" integrity="sha256-8rfHbJr+ju3Oc099jFJMR1xAPu8CTPHU8uP5J3X/VAY=" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.12/dist/js/lightgallery-all.min.js" integrity="sha256-w14QFJrxOYkUnF0hb8pVFCSgYcsF0hMIKrqGb8A7J8A=" crossorigin="anonymous"></script>
` }}
<!-- lazysizes https://github.com/aFarkas/lazysizes -->
{{ $lazysizes := `
<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.1.1/lazysizes.min.js" integrity="sha256-6zKmNZVeImc0d1Y55vm4So/0W5mbwWiPS4zJt3F4t2A=" crossorigin="anonymous"></script>
` }}
@@ -26,19 +16,19 @@
` }}
<!-- TypeIt https://github.com/alexmacarthur/typeit -->
{{ $typeit := `
<script src="https://cdn.jsdelivr.net/npm/typeit@6.0.3/dist/typeit.min.js" integrity="sha256-jl1b2Wp4cXCUyX8FxPZ8Z0PPIPV3QYNb/jPSLGDej2c=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/typeit@6.0.3/dist/typeit.min.js" integrity="sha256-jl1b2Wp4cXCUyX8FxPZ8Z0PPIPV3QYNb/jPSLGDej2c=" crossorigin="anonymous"></script>
` }}
<!-- jQuery.countdown https://github.com/hilios/jQuery.countdown/ -->
<!-- jQuery.countdown https://github.com/hilios/jQuery.countdown -->
{{ $countdown := `
<script src="https://cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js" integrity="sha256-Ikk5myJowmDQaYVCUD0Wr+vIDkN8hGI58SGWdE671A8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js" integrity="sha256-Ikk5myJowmDQaYVCUD0Wr+vIDkN8hGI58SGWdE671A8=" crossorigin="anonymous"></script>
` }}
<!-- jQuery.countdown https://github.com/hilios/jQuery.countdown/ -->
<!-- MetingJS https://github.com/metowolf/MetingJS -->
{{ $metingjs := `
<!-- require APlayer -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<!-- require MetingJS -->
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
<!-- require APlayer -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<!-- require MetingJS -->
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
` }}
{{ $jquery | safeHTML }}
@@ -49,24 +39,18 @@
{{ $metingjs | safeHTML }}
{{ end }}
{{ $countdown | safeHTML }}
{{ $scripts = $scripts | append $dynamicToTop }}
{{ if $postHasImages }}
{{ $lightGallery | safeHTML }}
{{ $lazysizes | safeHTML }}
{{ $scripts = $scripts | append $lightGallery_init }}
{{ $scripts = $scripts | resources.Concat "/js/vendor_gallery.js" | resources.Minify }}
{{ else }}
{{ $scripts = $scripts | resources.Concat "/js/vendor_no_gallery.js" | resources.Minify }}
{{ end }}
{{ if or .Params.Math .Site.Params.Math }}
{{ $katex | safeHTML }}
{{ end }}
{{ $lazysizes | safeHTML }}
{{ $scripts = $scripts | append $dynamicToTop }}
{{ $scripts = $scripts | resources.Concat "/js/vendor_post.js" | resources.Minify }}
{{ else }}
{{ $scripts = $scripts | resources.Concat "/js/vendor_main.js" | resources.Minify}}
{{ end }}
<script src="{{ printf "%s%s" $cdn_url $scripts.RelPermalink }}" async=""></script>
<script src="{{ $scripts.RelPermalink }}" async=""></script>
{{ template "_internal/google_analytics_async.html" . }}

View File

@@ -80,15 +80,10 @@
}
},
{{ end }}
{{ if .Params.author }}
{{ if .Site.Author.Name }}
"author": {
"@type": "Person",
"name": "{{ .Params.author }}"
},
{{ else if .Site.Author.name }}
"author": {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
"name": "{{ .Site.Author.Name }}"
},
{{ end }}
"description": "{{ .Description }}"

View File

@@ -1,12 +1,11 @@
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $modify_date := .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $author := .Site.Params.author }}
{{ $author := .Site.Author.Name }}
{{ if isset .Params "author" }}
{{ $author = .Params.author }}
{{ $author = .Site.Author.Name }}
{{ end }}
<article class="post-warp">
@@ -36,20 +35,16 @@
</header>
<div class="post-content">
<!--featured_image-->
{{ $images := findRE "<img src=\"[^\"|\\\"]*\"" .Content -}}
{{ if ge (len $images) 1}}
{{ $.Scratch.Set "postHasImages" true }}
{{ end }}
{{ with .Params.featured_image }}
{{ $img := . }}<img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image">
<img src="{{ . }}" class="featured_image">
{{ end }}
<!-- end featured_image-->
{{ $reAltIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" />" }}
{{ $reAltOut := ( printf "<figure><img src=\"/images/ring.svg\" data-sizes=\"auto\" data-src=\"%s$1\" alt=\"$2\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $reAltIn := `<img src="([^"]+)" alt="([^"]+)?" />` }}
{{ $reAltOut := "<figure><img src=/images/loading.svg data-sizes=auto data-src=$1 alt=$2 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
{{ $reAltTitleIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" title=\"([^\"]+)?\" />" }}
{{ $reAltTitleOut := ( printf "<figure><img src=\"/images/ring.svg\" data-src=\"%s$1\" data-sizes=\"auto\" alt=\"$2\" title=\"$3\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $reAltTitleIn := `<img src="([^"]+)" alt="([^"]+)?" title="([^"]+)?" />` }}
{{ $reAltTitleOut := "<figure><img src=/images/loading.svg data-src=$1 data-sizes=auto alt=$2 title=$3 class=lazyload><figcaption class=image-caption>$2</figcaption></figure>" }}
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
</div>
@@ -68,7 +63,7 @@
<p class="copyright-item">
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
<span>{{ T "share" }}:</span>
<span>{{ partial "share-links.html" . }}</span>
<span>{{ partial "post/share-links.html" . }}</span>
{{ end }}
</p>

View File

@@ -0,0 +1,46 @@
<article class="post" itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>
</header>
<div class="post-content">
<!--featured_image-->
{{ with .Params.featured_image }}
<p><img itemprop="image" src={{ . }} class="featured_image"></p>
{{ end }}
<!-- end featured_image-->
{{ .Summary }}
</div>
<div class="post-footer">
<div class="post-meta">
<span class="post-time">
<time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">
{{ .Date.Format (.Site.Params.dateFormatToUse | default "2 January 2006") }}
</time>
</span>
in
{{ with .Params.categories }}
<i class="iconfont icon-folder"></i>
<span class="post-category">
{{ range . }}
{{ $name := . }}
{{ with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) }}
<a href="{{ .Permalink }}">{{ $name }}</a>
{{ end }}
{{ end }}
</span>
{{ end }}
</div>
{{ with .Params.tags }}
<div class="post-tags">
{{ range . }}
<span class="tag">
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{ . }}</a>
</span>
{{ end }}
</div>
{{ end }}
</div>
</article>

View File

@@ -1,23 +1,33 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}</title>
<title>{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<description>Recent content {{ with .Title }}in {{ . }} {{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>
{{ with .Site.LanguageCode }}
<language>{{ . }}</language>
{{ end }}
{{ with .Site.Author.Email }}
<managingEditor>{{ . }}{{ with .Site.Author.name }} ({{ . }}){{ end }}</managingEditor>
{{ end }}
{{ with .Site.Author.Email }}
<webMaster>{{ . }}{{ with .Site.Author.name }} ({{ . }}){{ end }}</webMaster>
{{ end }}
{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>
{{ end }}
{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end }}
<atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" />
{{ range first 15 (where .Data.Pages "Type" "!=" "home") }}
<item>
<title>{{ .Title }}</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}}
{{ with .Site.Author.Email }}
<author>{{ . }}{{ with .Site.Author.Name }} ({{ . }}){{ end }}</author>
{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
</item>

View File

@@ -0,0 +1,25 @@
{{ if .IsNamedParams }}
{{ if eq (.Get "details") "true" }}
<details class="admonition {{ .Get "type" }}">
{{ with .Get "title" }}<summary class="admonition-title">{{ . }}</summary>{{ end }}
{{ .Inner }}
</details>
{{ else }}
<div class="admonition {{ .Get "type" }}">
{{- with .Get "title" }}<p class="admonition-title">{{ . }}</p>{{ end }}
{{ .Inner }}
</div>
{{ end }}
{{ else }}
{{ if eq (.Get 2) "true" }}
<details class="admonition {{ .Get 0 }}">
{{- with .Get 1 }}<summary class="admonition-title">{{ . }}</summary>{{ end }}
{{ .Inner }}
</details>
{{ else }}
<div class="admonition {{ .Get 0 }}">
{{- with .Get 1 }}<p class="admonition-title">{{ . }}</p>{{ end }}
{{ .Inner }}
</div>
{{ end }}
{{ end }}

View File

@@ -1,35 +1,42 @@
{{ $content := .Inner }}
<!-- only the trailing newline is retained -->
{{ $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner }}
<!-- shuffle md5 as id -->
{{ $id := delimit (split (md5 $content) "" | shuffle) "" | printf "tp-%s" }}
{{ if .Get "raw" }}
{{ $content = trim $content "\n" }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
<div class={{ .Get "class" }} id={{ $id }}></div>
{{ else if .Get "code" }}
{{ $content = highlight $content (.Get "code") "encoding=utf-8" }}
{{ $content = replaceRE `<div class="highlight">\s*?<pre class="chroma">\s*?<code.*?>(?s)(.*?)</code>\s*?</pre>\s*?</div>` "$1" $content }}
{{ $content = trim $content "\n" }}
{{ $content = replaceRE `\n</span>` "</span>\n" $content }}
{{ $content = replaceRE `(?m)^(<span.*?>)(.*?)\[(.*?)\]\((.*?)\)(.*?)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content }}
{{ $content = replaceRE ` ` "&nbsp;" $content | replaceRE `(<\w+)&nbsp;` "$1 " | replaceRE `\n` "<br />" }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
<div class={{ .Get "class" | default "typeit-code" }} id={{ $id }}></div>
{{ else }}
{{ $tag := .Get "tag" | default "p" }}
{{ $content = $content | markdownify | chomp }}
{{ $content = trim $content "\n" }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
{{ printf "<%s class=%s id=%s></%s>" $tag (.Get "class" | default "typeit") $id $tag | safeHTML }}
{{ end }}
<script>
var typeitMap = window.typeitMap || {};
{{ with .Get "group" }}
if (!typeitMap[{{ . }}]) {
typeitMap[{{ . }}] = [];
}
typeitMap[{{ . }}].push({{ $id }});
<div class={{ .Get "class" | default "typeit" }}>
<!-- raw html content -->
{{ if .Get "raw" }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
<div id={{ $id }}></div>
{{ else if .Get "code" }}
<!-- highlight code content without line number -->
{{ $content = highlight $content (.Get "code") "linenos=" }}
<!-- delete outer label -->
{{ $content = replaceRE `<div class="highlight"><pre class="chroma"><code[^<>]*>(?s)(.*)</code></pre></div>` "$1" $content }}
<!-- parsing markdown links -->
{{ $content = replaceRE `(<span[^<>]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)(</span>)` "$1$2$6<a href=$4>$3</a>$1$5$6" $content }}
<!-- replace " " to "&nbsp;" and replace "\n" to "<br />" -->
{{ $content = replaceRE ` ` "&nbsp;" $content | replaceRE `(<\w+)&nbsp;` "$1 " | replaceRE `\n` "<br />" }}
<!-- fix "<br />" location error which is a bug of Typeit HTML parser -->
{{ $content = replaceRE `<br /></span>` "</span><br />" $content }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
<div class="code" id={{ $id }}></div>
{{ else }}
typeitMap[{{ $id }}] = true;
{{ $tag := .Get "tag" | default "p" }}
{{ $content = $content | markdownify | chomp }}
<div id={{ printf "r%s" $id }} hidden=true>{{ $content | safeHTML }}</div>
{{ printf "<%s id=%s></%s>" $tag $id $tag | safeHTML }}
{{ end }}
</script>
<script>
var typeitMap = window.typeitMap || {};
{{ with .Get "group" }}
if (!typeitMap[{{ . }}]) {
typeitMap[{{ . }}] = [];
}
typeitMap[{{ . }}].push({{ $id }});
{{ else }}
typeitMap[{{ $id }}] = true;
{{ end }}
</script>
</div>