mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-25 08:16:19 +01:00
feat(author): add author_link and fix highlight bug
This commit is contained in:
parent
2a7611b5ae
commit
8aa4b6dce6
22 changed files with 136 additions and 110 deletions
|
@ -1,4 +1,6 @@
|
|||
---
|
||||
author: ""
|
||||
author_link: ""
|
||||
title: "{{ replace .TranslationBaseName "-" " " | title }}"
|
||||
date: {{ .Date }}
|
||||
lastmod: {{ .Date }}
|
||||
|
@ -16,7 +18,7 @@ featured_image_preview: ""
|
|||
|
||||
comment: true
|
||||
toc: false
|
||||
autoCollapseToc: true
|
||||
auto_collapse_toc: true
|
||||
math: false
|
||||
---
|
||||
|
||||
|
|
|
@ -3,22 +3,35 @@
|
|||
max-width: 780px;
|
||||
|
||||
.post-toc {
|
||||
width: 300px;
|
||||
margin-left: 800px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1300px) {
|
||||
@media only screen and (max-width: 1440px) {
|
||||
.warpper {
|
||||
max-width: 680px;
|
||||
|
||||
.post-toc {
|
||||
width: 240px;
|
||||
margin-left: 700px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1200px) {
|
||||
.warpper {
|
||||
max-width: 560px;
|
||||
|
||||
.post-toc {
|
||||
width: 180px;
|
||||
margin-left: 580px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1080px) {
|
||||
@media only screen and (max-width: 960px) {
|
||||
.navbar {
|
||||
.navbar-container {
|
||||
margin: 0 2rem;
|
||||
|
@ -52,7 +65,7 @@
|
|||
|
||||
.categories-card {
|
||||
.card-item {
|
||||
width: 95%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
.warpper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 960px;
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
padding-top: 6rem;
|
||||
|
||||
|
|
|
@ -24,9 +24,20 @@
|
|||
padding: 0 2%;
|
||||
position: relative;
|
||||
|
||||
.categories {
|
||||
.card-item-wrapper {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
.card-item-title {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
span {
|
||||
float: right;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,14 +81,3 @@
|
|||
.more-post {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.categories {
|
||||
h3 {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
span {
|
||||
float: right;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
|
@ -65,7 +65,7 @@ p > code {
|
|||
}
|
||||
|
||||
@each $sign, $text in $code-type-list {
|
||||
& .#{$sign} table::after {
|
||||
&.#{$sign} table::after {
|
||||
content: $text;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
.post-toc {
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 240px;
|
||||
max-width: 300px;
|
||||
margin-left: 980px;
|
||||
width: 360px;
|
||||
margin-left: 1000px;
|
||||
padding: .8rem;
|
||||
border-left: 1px solid $global-border-color;
|
||||
word-wrap: break-word;
|
||||
|
|
|
@ -70,46 +70,46 @@ $code-font-family: Source Code Pro, Consolas, Liberation Mono, Menlo, Courier, m
|
|||
// Code type list.
|
||||
$code-type-list: (
|
||||
// Custom code type
|
||||
language-bash: "Bash",
|
||||
language-c: "C",
|
||||
language-cs: "C#",
|
||||
language-cpp: "C++",
|
||||
language-css: "CSS",
|
||||
language-coffeescript: "CoffeeScript",
|
||||
language-html: "HTML",
|
||||
language-xml: "XML",
|
||||
language-http: "HTTP",
|
||||
language-json: "JSON",
|
||||
language-java: "Java",
|
||||
language-js: "JavaScript",
|
||||
language-javascript: "JavaScript",
|
||||
language-makefile: "Makefile",
|
||||
language-markdown: "Markdown",
|
||||
language-objectivec: "Objective-C",
|
||||
language-php: "PHP",
|
||||
language-perl: "Perl",
|
||||
language-python: "Python",
|
||||
language-ruby: "Ruby",
|
||||
language-sql: "SQL",
|
||||
language-shell: "Shell",
|
||||
language-erlang: "Erlang",
|
||||
language-go: "Go",
|
||||
language-go-html-template: "Go HTML Template",
|
||||
language-groovy: "Groovy",
|
||||
language-haskell: "Haskell",
|
||||
language-kotlin: "Kotlin",
|
||||
language-clojure: "Clojure",
|
||||
language-less: "Less",
|
||||
language-lisp: "Lisp",
|
||||
language-lua: "Lua",
|
||||
language-matlab: "Matlab",
|
||||
language-rust: "Rust",
|
||||
language-scss: "Scss",
|
||||
language-scala: "Scala",
|
||||
language-swift: "Swift",
|
||||
language-typescript: "TypeScript",
|
||||
language-yml: "YAML",
|
||||
language-yaml: "YAML",
|
||||
language-toml: "TOML",
|
||||
language-diff: "Diff"
|
||||
language-bash: 'Bash',
|
||||
language-c: 'C',
|
||||
language-cs: 'C#',
|
||||
language-cpp: 'C++',
|
||||
language-css: 'CSS',
|
||||
language-coffeescript: 'CoffeeScript',
|
||||
language-html: 'HTML',
|
||||
language-xml: 'XML',
|
||||
language-http: 'HTTP',
|
||||
language-json: 'JSON',
|
||||
language-java: 'Java',
|
||||
language-js: 'JavaScript',
|
||||
language-javascript: 'JavaScript',
|
||||
language-makefile: 'Makefile',
|
||||
language-markdown: 'Markdown',
|
||||
language-objectivec: 'Objective-C',
|
||||
language-php: 'PHP',
|
||||
language-perl: 'Perl',
|
||||
language-python: 'Python',
|
||||
language-ruby: 'Ruby',
|
||||
language-sql: 'SQL',
|
||||
language-shell: 'Shell',
|
||||
language-erlang: 'Erlang',
|
||||
language-go: 'Go',
|
||||
language-go-html-template: 'Go HTML Template',
|
||||
language-groovy: 'Groovy',
|
||||
language-haskell: 'Haskell',
|
||||
language-kotlin: 'Kotlin',
|
||||
language-clojure: 'Clojure',
|
||||
language-less: 'Less',
|
||||
language-lisp: 'Lisp',
|
||||
language-lua: 'Lua',
|
||||
language-matlab: 'Matlab',
|
||||
language-rust: 'Rust',
|
||||
language-scss: 'Scss',
|
||||
language-scala: 'Scala',
|
||||
language-swift: 'Swift',
|
||||
language-typescript: 'TypeScript',
|
||||
language-yml: 'YAML',
|
||||
language-yaml: 'YAML',
|
||||
language-toml: 'TOML',
|
||||
language-diff: 'Diff'
|
||||
) !default;
|
||||
|
|
|
@ -73,12 +73,13 @@ jQuery(function($) {
|
|||
});
|
||||
};
|
||||
|
||||
_Blog.chroma = function() {
|
||||
_Blog.chroma = function () {
|
||||
const blocks = document.querySelectorAll('.highlight > .chroma');
|
||||
for (let i = 0; i < blocks.length; i++) {
|
||||
const block = blocks[i];
|
||||
const afterHighLight = block.querySelector('pre.chroma > code');
|
||||
const lang = afterHighLight ? afterHighLight.className : '';
|
||||
const codes = block.querySelectorAll('pre.chroma > code');
|
||||
const code = codes[codes.length - 1];
|
||||
const lang = code ? code.className.toLowerCase() : '';
|
||||
block.className += ' ' + lang;
|
||||
}
|
||||
};
|
||||
|
@ -298,4 +299,4 @@ jQuery(function($) {
|
|||
_Blog.typeit();
|
||||
_Blog.toc();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ featured_image_preview: ""
|
|||
|
||||
comment: true
|
||||
toc: true
|
||||
autoCollapseToc: true
|
||||
auto_collapse_toc: true
|
||||
math: true
|
||||
---
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
author: "Hugo Authors"
|
||||
author_link: "https://gohugo.io/"
|
||||
title: "Markdown Syntax Guide"
|
||||
date: 2020-01-30T21:57:40+08:00
|
||||
lastmod: 2020-01-30T21:57:40+08:00
|
||||
|
@ -17,7 +18,6 @@ tags: [
|
|||
]
|
||||
categories: [
|
||||
"themes",
|
||||
"syntax",
|
||||
]
|
||||
|
||||
featured_image: /images/markdown.png
|
||||
|
@ -25,7 +25,7 @@ featured_image_preview: ""
|
|||
|
||||
comment: true
|
||||
toc: true
|
||||
autoCollapseToc: true
|
||||
auto_collapse_toc: true
|
||||
math: false
|
||||
---
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ featu红色_image_preview: ''
|
|||
|
||||
comment: true
|
||||
toc: true
|
||||
autoCollapseToc: false
|
||||
auto_collapse_toc: false
|
||||
math: true
|
||||
---
|
||||
|
||||
|
|
|
@ -94,9 +94,6 @@ other = "min"
|
|||
|
||||
[second]
|
||||
other = "sec"
|
||||
|
||||
[return]
|
||||
other = "return"
|
||||
# === posts/single.html ===
|
||||
|
||||
# === 404.html ===
|
||||
|
|
|
@ -97,9 +97,6 @@ other = "分"
|
|||
|
||||
[second]
|
||||
other = "秒"
|
||||
|
||||
[return]
|
||||
other = "返回"
|
||||
# === posts/single.html ===
|
||||
|
||||
# === 404.html ===
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<figure>
|
||||
<img
|
||||
{{- $res := resources.Get "svg/loading.svg" | minify -}}
|
||||
{{ $res := resources.Get "svg/loading.svg" | minify -}}
|
||||
src="{{ $res.RelPermalink }}"
|
||||
data-sizes="auto"
|
||||
data-src="{{ .Destination | safeURL }}"
|
||||
alt="{{ .Text }}"
|
||||
{{- with .Title -}}
|
||||
{{ with .Title -}}
|
||||
title="{{ . }}"
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
class="lazyload"
|
||||
>
|
||||
<figcaption class="image-caption">
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<a href="{{ .Destination | safeURL }}"
|
||||
{{- with .Title -}}
|
||||
{{ with .Title -}}
|
||||
title="{{ . }}"
|
||||
{{- end -}}
|
||||
{{- if strings.HasPrefix .Destination "http" -}}
|
||||
{{ end -}}
|
||||
{{ if strings.HasPrefix .Destination "http" -}}
|
||||
target="_blank"
|
||||
{{- end -}}
|
||||
{{ end -}}
|
||||
>
|
||||
{{- .Text -}}
|
||||
</a>
|
|
@ -17,7 +17,7 @@
|
|||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<sup>\[return\]</sup>` -}}
|
||||
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}}
|
||||
{{- $REout = `↩︎` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
|
||||
|
@ -28,6 +28,10 @@
|
|||
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<li (id="fn:.+?")(.*?)>\s?<p>` -}}
|
||||
{{- $REout = `<li $2><p><a class="post-dummy-target" $1></a>` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<article class="post" itemscope itemtype="http://schema.org/Article">
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
|
||||
{{- $author := .Site.Author.name -}}
|
||||
{{- if isset .Params "author" -}}
|
||||
{{- $author = .Site.Author.name -}}
|
||||
{{- end -}}
|
||||
{{- $author := .Params.author | default .Site.Author.name -}}
|
||||
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
|
||||
|
||||
<!--featured_image-->
|
||||
{{- with .Params.featured_image -}}
|
||||
|
@ -19,11 +17,13 @@
|
|||
</h1>
|
||||
|
||||
<div class="post-meta">
|
||||
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }} </a>
|
||||
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
|
||||
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}
|
||||
</a>
|
||||
{{ T "publish" }} <time datetime={{ $publish_date }}>{{ $publish_date }}</time>
|
||||
{{- with .Params.categories -}}
|
||||
<span class="post-category">
|
||||
{{- T "included" -}}
|
||||
{{- T "included" -}}
|
||||
{{- range . -}}
|
||||
{{- $name := . -}}
|
||||
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
|
||||
|
@ -41,12 +41,15 @@
|
|||
</p>
|
||||
{{- else -}}
|
||||
{{- $summary := .Summary -}}
|
||||
|
||||
{{- $REin := `:\(([\w- ]+?)\):` -}}
|
||||
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
|
||||
{{- $summary = replaceRE $REin $REout $summary -}}
|
||||
|
||||
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
|
||||
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
|
||||
{{- $summary = replaceRE $REin $REout $summary -}}
|
||||
|
||||
{{- $summary | safeHTML -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
@ -55,7 +58,9 @@
|
|||
{{- with .Params.tags -}}
|
||||
<div class="post-tags">
|
||||
{{- range . -}}
|
||||
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>{{ . }}</a></span>
|
||||
<span class="tag">
|
||||
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i> {{ . }}</a>
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
<section>
|
||||
{{- with .Params.tags -}}
|
||||
{{- range . -}}
|
||||
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>{{ . }}</a></span>
|
||||
<span class="tag">
|
||||
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i> {{ . }}</a>
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</section>
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
|
||||
{{- define "content" -}}
|
||||
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
|
||||
{{- $author := .Site.Author.name -}}
|
||||
{{- if isset .Params "author" -}}
|
||||
{{- $author = .Site.Author.name -}}
|
||||
{{- end }}
|
||||
{{- $author := .Params.author | default .Site.Author.name -}}
|
||||
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
|
||||
|
||||
<article class="warpper">
|
||||
<h1 class="post-title animated flipInX">{{ .Title }}</h1>
|
||||
|
||||
<div class="post-meta">
|
||||
<div class="post-meta-main">
|
||||
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }} </a>
|
||||
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
|
||||
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}
|
||||
</a>
|
||||
{{- with .Params.categories -}}
|
||||
<span class="post-category">
|
||||
{{- T "included" -}}
|
||||
{{- T "included" -}}
|
||||
{{- range . -}}
|
||||
{{- $name := . -}}
|
||||
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
|
||||
|
@ -47,8 +47,8 @@
|
|||
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
|
||||
<div class="post-toc" id="post-toc">
|
||||
<h2 class="post-toc-title">{{ T "toc" }}</h2>
|
||||
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
|
||||
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}">
|
||||
{{- $globalAutoCollapseToc := .Site.Params.auto_collapse_toc | default true }}
|
||||
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.auto_collapse_toc false)) }} always-active{{ end }}">
|
||||
{{- .TableOfContents -}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -81,17 +81,21 @@
|
|||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<sup>\[return\]</sup>` -}}
|
||||
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}}
|
||||
{{- $REout = `↩︎` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
|
||||
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<(.+) (id="fnref:.+?")>` -}}
|
||||
{{- $REin = `<(.+?) (id="fnref:.+?")>` -}}
|
||||
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $REin = `<li (id="fn:.+?")(.*?)>\s?<p>` -}}
|
||||
{{- $REout = `<li $2><p><a class="post-dummy-target" $1></a>` -}}
|
||||
{{- $content = replaceRE $REin $REout $content -}}
|
||||
|
||||
{{- $content | safeHTML -}}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<h2 class="post-title animated pulse faster">
|
||||
{{- $taxonomy := .Data.Singular -}}
|
||||
{{- if eq $taxonomy "category" -}}
|
||||
<i class="far fa-folder-open fa-fw"></i>{{ .Title }}
|
||||
<i class="far fa-folder-open fa-fw"></i> {{ .Title }}
|
||||
{{- else if eq $taxonomy "tag" -}}
|
||||
<i class="fas fa-tag fa-fw"></i>{{ .Title }}
|
||||
<i class="fas fa-tag fa-fw"></i> {{ .Title }}
|
||||
{{- else -}}
|
||||
{{- printf "%s - %s" (T $taxonomy | default (humanize $taxonomy)) .Title -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -20,10 +20,12 @@
|
|||
{{- $pages := .Pages -}}
|
||||
{{- with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) -}}
|
||||
<div class="card-item">
|
||||
<div class="categories">
|
||||
<a href="{{ .Permalink }}">
|
||||
<h3><i class="far fa-folder fa-fw"></i>{{ $term | humanize}}</h3>
|
||||
</a>
|
||||
<div class="card-item-wrapper">
|
||||
<h3 class="card-item-title">
|
||||
<a href="{{ .Permalink }}">
|
||||
<i class="far fa-folder fa-fw"></i> {{ $term | humanize}}
|
||||
</a>
|
||||
</h3>
|
||||
{{- range first 5 $pages -}}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .Permalink }}" class="archive-item-link">
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue