mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 02:46:16 +01:00
feat: smarter typeit shortcode
This commit is contained in:
parent
c16db324fa
commit
a6bf8d8eae
10 changed files with 253 additions and 166 deletions
|
@ -1,18 +1,14 @@
|
|||
/** Font **/
|
||||
/* Lato */
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900);
|
||||
|
||||
/* Lato */
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900);
|
||||
|
||||
/* Montserrat */
|
||||
@import url(https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700,800);
|
||||
|
||||
/* Roboto */
|
||||
@import url(https://fonts.googleapis.com/css?family=Roboto:400,900);
|
||||
/* Montserrat */
|
||||
@import url(https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700,800);
|
||||
|
||||
|
||||
|
||||
|
||||
html {
|
||||
/* Roboto */
|
||||
@import url(https://fonts.googleapis.com/css?family=Roboto:400,900);
|
||||
|
||||
html {
|
||||
&::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
|
@ -25,8 +21,8 @@
|
|||
background-color: #ddd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: rgba(0, 149, 255, 0.1);
|
||||
}
|
||||
|
|
|
@ -161,39 +161,56 @@
|
|||
margin: 0 !important;
|
||||
}
|
||||
|
||||
div.code {
|
||||
div.typeit-code {
|
||||
padding: 6px;
|
||||
font-size: 14px;
|
||||
font-family: Consolas, Monaco, Menlo, Consolas, monospace;
|
||||
font-weight:bold;
|
||||
word-break: break-all;
|
||||
|
||||
.code-key {
|
||||
.k {
|
||||
color: #D371E3;
|
||||
}
|
||||
|
||||
.code-cvar {
|
||||
.kt {
|
||||
color: #D371E3;
|
||||
}
|
||||
|
||||
.kc {
|
||||
color: #D371E3;
|
||||
}
|
||||
|
||||
.o {
|
||||
color: #D371E3;
|
||||
}
|
||||
|
||||
.n {
|
||||
color: #ECBF6F;
|
||||
}
|
||||
|
||||
.code-var {
|
||||
.nf {
|
||||
color: #F16473;
|
||||
}
|
||||
|
||||
.code-func {
|
||||
.na {
|
||||
color: #41B1F5;
|
||||
}
|
||||
|
||||
.code-str {
|
||||
.s {
|
||||
color: #8BC56F;
|
||||
}
|
||||
|
||||
.code-num {
|
||||
.n {
|
||||
color: #DB975C;
|
||||
}
|
||||
|
||||
.code-comm {
|
||||
.c1 {
|
||||
color: #7E848F;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.space {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +258,6 @@
|
|||
|
||||
}
|
||||
|
||||
|
||||
.post-nav {
|
||||
|
||||
&:before,
|
||||
|
@ -280,7 +296,68 @@
|
|||
content: " / ";
|
||||
}
|
||||
|
||||
.post-comment{
|
||||
.post-comment {
|
||||
padding: 3em 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Background */ .chroma { color: #f8f8f2; background-color: #282a36 }
|
||||
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
|
||||
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; }
|
||||
/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc }
|
||||
/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
||||
/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
|
||||
/* Keyword */ .chroma .k { color: #ff79c6 }
|
||||
/* KeywordConstant */ .chroma .kc { color: #ff79c6 }
|
||||
/* KeywordDeclaration */ .chroma .kd { color: #8be9fd; font-style: italic }
|
||||
/* KeywordNamespace */ .chroma .kn { color: #ff79c6 }
|
||||
/* KeywordPseudo */ .chroma .kp { color: #ff79c6 }
|
||||
/* KeywordReserved */ .chroma .kr { color: #ff79c6 }
|
||||
/* KeywordType */ .chroma .kt { color: #8be9fd }
|
||||
/* NameAttribute */ .chroma .na { color: #50fa7b }
|
||||
/* NameBuiltin */ .chroma .nb { color: #8be9fd; font-style: italic }
|
||||
/* NameClass */ .chroma .nc { color: #50fa7b }
|
||||
/* NameFunction */ .chroma .nf { color: #50fa7b }
|
||||
/* NameLabel */ .chroma .nl { color: #8be9fd; font-style: italic }
|
||||
/* NameTag */ .chroma .nt { color: #ff79c6 }
|
||||
/* NameVariable */ .chroma .nv { color: #8be9fd; font-style: italic }
|
||||
/* NameVariableClass */ .chroma .vc { color: #8be9fd; font-style: italic }
|
||||
/* NameVariableGlobal */ .chroma .vg { color: #8be9fd; font-style: italic }
|
||||
/* NameVariableInstance */ .chroma .vi { color: #8be9fd; font-style: italic }
|
||||
/* LiteralString */ .chroma .s { color: #f1fa8c }
|
||||
/* LiteralStringAffix */ .chroma .sa { color: #f1fa8c }
|
||||
/* LiteralStringBacktick */ .chroma .sb { color: #f1fa8c }
|
||||
/* LiteralStringChar */ .chroma .sc { color: #f1fa8c }
|
||||
/* LiteralStringDelimiter */ .chroma .dl { color: #f1fa8c }
|
||||
/* LiteralStringDoc */ .chroma .sd { color: #f1fa8c }
|
||||
/* LiteralStringDouble */ .chroma .s2 { color: #f1fa8c }
|
||||
/* LiteralStringEscape */ .chroma .se { color: #f1fa8c }
|
||||
/* LiteralStringHeredoc */ .chroma .sh { color: #f1fa8c }
|
||||
/* LiteralStringInterpol */ .chroma .si { color: #f1fa8c }
|
||||
/* LiteralStringOther */ .chroma .sx { color: #f1fa8c }
|
||||
/* LiteralStringRegex */ .chroma .sr { color: #f1fa8c }
|
||||
/* LiteralStringSingle */ .chroma .s1 { color: #f1fa8c }
|
||||
/* LiteralStringSymbol */ .chroma .ss { color: #f1fa8c }
|
||||
/* LiteralNumber */ .chroma .m { color: #bd93f9 }
|
||||
/* LiteralNumberBin */ .chroma .mb { color: #bd93f9 }
|
||||
/* LiteralNumberFloat */ .chroma .mf { color: #bd93f9 }
|
||||
/* LiteralNumberHex */ .chroma .mh { color: #bd93f9 }
|
||||
/* LiteralNumberInteger */ .chroma .mi { color: #bd93f9 }
|
||||
/* LiteralNumberIntegerLong */ .chroma .il { color: #bd93f9 }
|
||||
/* LiteralNumberOct */ .chroma .mo { color: #bd93f9 }
|
||||
/* Operator */ .chroma .o { color: #ff79c6 }
|
||||
/* OperatorWord */ .chroma .ow { color: #ff79c6 }
|
||||
/* Comment */ .chroma .c { color: #6272a4 }
|
||||
/* CommentHashbang */ .chroma .ch { color: #6272a4 }
|
||||
/* CommentMultiline */ .chroma .cm { color: #6272a4 }
|
||||
/* CommentSingle */ .chroma .c1 { color: #6272a4 }
|
||||
/* CommentSpecial */ .chroma .cs { color: #6272a4 }
|
||||
/* CommentPreproc */ .chroma .cp { color: #ff79c6 }
|
||||
/* CommentPreprocFile */ .chroma .cpf { color: #ff79c6 }
|
||||
/* GenericDeleted */ .chroma .gd { color: #8b080b }
|
||||
/* GenericEmph */ .chroma .ge { text-decoration: underline }
|
||||
/* GenericHeading */ .chroma .gh { font-weight: bold }
|
||||
/* GenericInserted */ .chroma .gi { font-weight: bold }
|
||||
/* GenericOutput */ .chroma .go { color: #44475a }
|
||||
/* GenericSubheading */ .chroma .gu { font-weight: bold }
|
||||
/* GenericUnderline */ .chroma .gl { text-decoration: underline }
|
||||
|
|
|
@ -4,17 +4,31 @@ jQuery(function($) {
|
|||
|
||||
var _Blog = window._Blog || {};
|
||||
|
||||
_Blog.prettify = function() {
|
||||
$('pre').addClass('prettyprint linenums').attr('style', 'overflow:auto;');
|
||||
window.prettyPrint && prettyPrint();
|
||||
};
|
||||
|
||||
_Blog.typeit = function() {
|
||||
if (window.typeitMap) {
|
||||
for (let id in typeitMap) {
|
||||
new TypeIt(id, {
|
||||
strings: typeitMap[id],
|
||||
}).go();
|
||||
if (Array.isArray(typeitMap[id])) {
|
||||
const group = typeitMap[id];
|
||||
(function typeone (i) {
|
||||
if (i === group.length - 1) {
|
||||
new TypeIt(`#${group[i]}`, {
|
||||
strings: document.getElementById(`r${group[i]}`).innerHTML,
|
||||
}).go();
|
||||
return;
|
||||
}
|
||||
let instance = new TypeIt(`#${group[i]}`, {
|
||||
strings: document.getElementById(`r${group[i]}`).innerHTML,
|
||||
afterComplete: () => {
|
||||
instance.destroy();
|
||||
typeone(i + 1);
|
||||
},
|
||||
}).go();
|
||||
})(0);
|
||||
} else {
|
||||
new TypeIt(`#${id}`, {
|
||||
strings: document.getElementById(`r${id}`).innerHTML,
|
||||
}).go();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -74,7 +88,6 @@ jQuery(function($) {
|
|||
|
||||
$(document).ready(function() {
|
||||
_Blog.toggleTheme();
|
||||
_Blog.prettify();
|
||||
_Blog.countdown();
|
||||
_Blog.changeTitle();
|
||||
_Blog.toggleMobileMenu();
|
||||
|
|
|
@ -1,75 +1,58 @@
|
|||
{{ $cdn_url := .Scratch.Get "cdn_url" }}
|
||||
|
||||
<div class="post-warp">
|
||||
<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 .) }}
|
||||
{{ end }}
|
||||
{{ if $avatar }}
|
||||
<div class="avatar">
|
||||
<a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a>
|
||||
{{ 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>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.Params.subtitle }}
|
||||
<h2 class="description">
|
||||
<div id="subtitle"></div>
|
||||
</h2>
|
||||
<script>
|
||||
var typeitMap = window.typeitMap || {};
|
||||
typeitMap["#subtitle"] = "{{ . }}";
|
||||
</script>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ range (.Paginate .Pages).Pages }}
|
||||
<article class="post" itemscope 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 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 -}}
|
||||
<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 }}
|
||||
</span>
|
||||
{{- end }}
|
||||
</div>
|
||||
{{ with .Params.tags }}
|
||||
<div class="post-tags">
|
||||
{{ range . }}
|
||||
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">
|
||||
#{{.}}</a></span>
|
||||
</div>
|
||||
|
||||
{{ with .Params.tags }}
|
||||
<div class="post-tags">
|
||||
{{ range . }}
|
||||
<span class="tag">
|
||||
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{ . }}</a>
|
||||
</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "paginator.html" . }}
|
||||
|
|
|
@ -1,29 +1 @@
|
|||
{{ $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 .) }}
|
||||
{{ end }}
|
||||
{{ if $avatar }}
|
||||
<div class="avatar">
|
||||
<a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.Params.subtitle }}
|
||||
<h2 class="description">
|
||||
<div id="subtitle"></div>
|
||||
</h2>
|
||||
<script>
|
||||
var typeitMap = window.typeitMap || {};
|
||||
typeitMap["#subtitle"] = "{{ . }}";
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
<div class="social-links">
|
||||
{{ partial "social.html" . }}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial "intro.html" . }}
|
||||
|
|
33
layouts/partials/intro.html
Normal file
33
layouts/partials/intro.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{ $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) }}
|
||||
{{ end }}
|
||||
{{ if $avatar }}
|
||||
<div class="avatar">
|
||||
<a href="/posts/">
|
||||
<img src={{ $avatar }} alt="avatar">
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.Params.subtitle }}
|
||||
<h2 class="description">
|
||||
{{ $id := md5 . | printf "tp-%s" }}
|
||||
<div id={{ printf "r%s" $id }} hidden=true>{{ . | safeHTML }}</div>
|
||||
<div id={{ $id }} class="typeit"></div>
|
||||
<script>
|
||||
var typeitMap = window.typeitMap || {};
|
||||
typeitMap[{{ $id }}] = true;
|
||||
</script>
|
||||
</h2>
|
||||
{{ end }}
|
||||
|
||||
<div class="social-links">
|
||||
{{ partial "social.html" . }}
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||
{{ $cdn_url := .Scratch.Get "cdn_url" }}
|
||||
{{ $postHasImages := .Scratch.Get "postHasImages"}}
|
||||
{{ $postHasImages := .Scratch.Get "postHasImages" }}
|
||||
|
||||
{{ $scripts := resources.Get "/js/main.js" | slice }}
|
||||
{{ $dynamicToTop := resources.Get "/js/dynamicToTop.min.js" }}
|
||||
|
@ -9,10 +9,6 @@
|
|||
{{ $jquery := `
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
||||
` }}
|
||||
<!-- JavaScript code prettifier https://github.com/google/code-prettify -->
|
||||
{{ $prettify := `
|
||||
<script src="https://cdn.jsdelivr.net/npm/code-prettify@0.1.0/src/prettify.js" integrity="sha256-w3n8zE0N1lx/nrrWA16Dk7KnySbJF7cPs5E2CByeB7A=" 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">
|
||||
|
@ -49,9 +45,6 @@
|
|||
{{ $typeit | safeHTML }}
|
||||
|
||||
{{ if .IsPage }}
|
||||
{{ if .Params.Code }}
|
||||
{{ $prettify | safeHTML }}
|
||||
{{ end }}
|
||||
{{ if .Params.Music }}
|
||||
{{ $metingjs | safeHTML }}
|
||||
{{ end }}
|
||||
|
@ -76,5 +69,4 @@
|
|||
{{ end }}
|
||||
|
||||
<script src="{{ printf "%s%s" $cdn_url $scripts.RelPermalink }}" async=""></script>
|
||||
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
{{ define "title" }}{{ T "posts" }} - {{ .Site.Title }}{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
{{ $data := .Data }}
|
||||
<div class="post-warp archive">
|
||||
<h2 class="post-title" style="text-align:right;padding-bottom:2em">
|
||||
{{- printf "- %s -" (T "posts") -}}
|
||||
</h2>
|
||||
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
|
||||
<h3>{{ .Key }}</h3>
|
||||
{{ $data := .Data }}
|
||||
<div class="post-warp archive">
|
||||
<h2 class="post-title" style="text-align:right;padding-bottom:2em">
|
||||
{{ printf "- %s -" (T "posts") }}
|
||||
</h2>
|
||||
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
|
||||
<h3>{{ .Key }}</h3>
|
||||
|
||||
{{ range .Pages }}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a>
|
||||
<span class="archive-item-date">
|
||||
{{ .Date.Format (.Site.Params.dateFormatToUse | default "01-02") }}
|
||||
</span>
|
||||
</article>
|
||||
{{ end }} {{ end }}
|
||||
{{ partial "paginator.html" . }}
|
||||
</div>
|
||||
{{ range .Pages }}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a>
|
||||
<span class="archive-item-date">
|
||||
{{ .Date.Format (.Site.Params.dateFormatToUse | default "01-02") }}
|
||||
</span>
|
||||
</article>
|
||||
{{ end }} {{ end }}
|
||||
{{ partial "paginator.html" . }}
|
||||
</div>
|
||||
{{end }}
|
||||
|
|
|
@ -63,4 +63,4 @@ Disallow: /
|
|||
User-agent: ZoominfoBot
|
||||
Disallow: /
|
||||
|
||||
Sitemap: {{ "sitemap.xml" | absLangURL }}
|
||||
Sitemap: {{ "sitemap.xml" | absLangURL }}
|
||||
|
|
|
@ -1,13 +1,34 @@
|
|||
{{ if .Get "id" }}
|
||||
{{ $id := .Get "id" }}
|
||||
{{ with .Get "class" }}
|
||||
<div id={{ $id }} class="{{ . }}"></div>
|
||||
{{ else }}
|
||||
<div id={{ $id }}></div>
|
||||
{{ end }}
|
||||
{{ $id = printf "#%s" $id }}
|
||||
<script>
|
||||
var typeitMap = window.typeitMap || {};
|
||||
typeitMap["{{ $id }}"] = {{ .Inner | safeHTML }};
|
||||
</script>
|
||||
{{ $content := .Inner }}
|
||||
{{ $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><br />" $content | replaceRE `\n` "<br />" }}
|
||||
{{ $content = replaceRE `>( +)<span` "><span class=space>$1</span><span" $content }}
|
||||
<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 }});
|
||||
{{ else }}
|
||||
typeitMap[{{ $id }}] = true;
|
||||
{{ end }}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue