feat(author): add author_link and fix highlight bug

This commit is contained in:
Dillon 2020-02-01 01:52:27 +08:00
parent 2a7611b5ae
commit 8aa4b6dce6
22 changed files with 136 additions and 110 deletions

View file

@ -1,4 +1,6 @@
--- ---
author: ""
author_link: ""
title: "{{ replace .TranslationBaseName "-" " " | title }}" title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }} date: {{ .Date }}
lastmod: {{ .Date }} lastmod: {{ .Date }}
@ -16,7 +18,7 @@ featured_image_preview: ""
comment: true comment: true
toc: false toc: false
autoCollapseToc: true auto_collapse_toc: true
math: false math: false
--- ---

View file

@ -3,22 +3,35 @@
max-width: 780px; max-width: 780px;
.post-toc { .post-toc {
width: 300px;
margin-left: 800px; 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 { .warpper {
max-width: 560px; max-width: 560px;
.post-toc { .post-toc {
width: 180px;
margin-left: 580px; margin-left: 580px;
} }
} }
} }
@media only screen and (max-width: 1080px) { @media only screen and (max-width: 960px) {
.navbar { .navbar {
.navbar-container { .navbar-container {
margin: 0 2rem; margin: 0 2rem;
@ -52,7 +65,7 @@
.categories-card { .categories-card {
.card-item { .card-item {
width: 95%; width: 100%;
} }
} }
} }

View file

@ -3,7 +3,7 @@
.warpper { .warpper {
position: relative; position: relative;
width: 100%; width: 100%;
max-width: 960px; max-width: 980px;
margin: 0 auto; margin: 0 auto;
padding-top: 6rem; padding-top: 6rem;

View file

@ -24,9 +24,20 @@
padding: 0 2%; padding: 0 2%;
position: relative; position: relative;
.categories { .card-item-wrapper {
width: 100%; width: 100%;
overflow: hidden; 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 { .more-post {
text-align: right; text-align: right;
} }
.categories {
h3 {
display: inline-block;
}
span {
float: right;
padding-right: 1rem;
}
}

View file

@ -65,7 +65,7 @@ p > code {
} }
@each $sign, $text in $code-type-list { @each $sign, $text in $code-type-list {
& .#{$sign} table::after { &.#{$sign} table::after {
content: $text; content: $text;
} }
} }

View file

@ -1,9 +1,8 @@
.post-toc { .post-toc {
display: block; display: block;
position: absolute; position: absolute;
width: 240px; width: 360px;
max-width: 300px; margin-left: 1000px;
margin-left: 980px;
padding: .8rem; padding: .8rem;
border-left: 1px solid $global-border-color; border-left: 1px solid $global-border-color;
word-wrap: break-word; word-wrap: break-word;

View file

@ -70,46 +70,46 @@ $code-font-family: Source Code Pro, Consolas, Liberation Mono, Menlo, Courier, m
// Code type list. // Code type list.
$code-type-list: ( $code-type-list: (
// Custom code type // Custom code type
language-bash: "Bash", language-bash: 'Bash',
language-c: "C", language-c: 'C',
language-cs: "C#", language-cs: 'C#',
language-cpp: "C++", language-cpp: 'C++',
language-css: "CSS", language-css: 'CSS',
language-coffeescript: "CoffeeScript", language-coffeescript: 'CoffeeScript',
language-html: "HTML", language-html: 'HTML',
language-xml: "XML", language-xml: 'XML',
language-http: "HTTP", language-http: 'HTTP',
language-json: "JSON", language-json: 'JSON',
language-java: "Java", language-java: 'Java',
language-js: "JavaScript", language-js: 'JavaScript',
language-javascript: "JavaScript", language-javascript: 'JavaScript',
language-makefile: "Makefile", language-makefile: 'Makefile',
language-markdown: "Markdown", language-markdown: 'Markdown',
language-objectivec: "Objective-C", language-objectivec: 'Objective-C',
language-php: "PHP", language-php: 'PHP',
language-perl: "Perl", language-perl: 'Perl',
language-python: "Python", language-python: 'Python',
language-ruby: "Ruby", language-ruby: 'Ruby',
language-sql: "SQL", language-sql: 'SQL',
language-shell: "Shell", language-shell: 'Shell',
language-erlang: "Erlang", language-erlang: 'Erlang',
language-go: "Go", language-go: 'Go',
language-go-html-template: "Go HTML Template", language-go-html-template: 'Go HTML Template',
language-groovy: "Groovy", language-groovy: 'Groovy',
language-haskell: "Haskell", language-haskell: 'Haskell',
language-kotlin: "Kotlin", language-kotlin: 'Kotlin',
language-clojure: "Clojure", language-clojure: 'Clojure',
language-less: "Less", language-less: 'Less',
language-lisp: "Lisp", language-lisp: 'Lisp',
language-lua: "Lua", language-lua: 'Lua',
language-matlab: "Matlab", language-matlab: 'Matlab',
language-rust: "Rust", language-rust: 'Rust',
language-scss: "Scss", language-scss: 'Scss',
language-scala: "Scala", language-scala: 'Scala',
language-swift: "Swift", language-swift: 'Swift',
language-typescript: "TypeScript", language-typescript: 'TypeScript',
language-yml: "YAML", language-yml: 'YAML',
language-yaml: "YAML", language-yaml: 'YAML',
language-toml: "TOML", language-toml: 'TOML',
language-diff: "Diff" language-diff: 'Diff'
) !default; ) !default;

View file

@ -73,12 +73,13 @@ jQuery(function($) {
}); });
}; };
_Blog.chroma = function() { _Blog.chroma = function () {
const blocks = document.querySelectorAll('.highlight > .chroma'); const blocks = document.querySelectorAll('.highlight > .chroma');
for (let i = 0; i < blocks.length; i++) { for (let i = 0; i < blocks.length; i++) {
const block = blocks[i]; const block = blocks[i];
const afterHighLight = block.querySelector('pre.chroma > code'); const codes = block.querySelectorAll('pre.chroma > code');
const lang = afterHighLight ? afterHighLight.className : ''; const code = codes[codes.length - 1];
const lang = code ? code.className.toLowerCase() : '';
block.className += ' ' + lang; block.className += ' ' + lang;
} }
}; };
@ -298,4 +299,4 @@ jQuery(function($) {
_Blog.typeit(); _Blog.typeit();
_Blog.toc(); _Blog.toc();
}); });
}); });

View file

@ -16,7 +16,7 @@ featured_image_preview: ""
comment: true comment: true
toc: true toc: true
autoCollapseToc: true auto_collapse_toc: true
math: true math: true
--- ---

View file

@ -1,5 +1,6 @@
--- ---
author: "Hugo Authors" author: "Hugo Authors"
author_link: "https://gohugo.io/"
title: "Markdown Syntax Guide" title: "Markdown Syntax Guide"
date: 2020-01-30T21:57:40+08:00 date: 2020-01-30T21:57:40+08:00
lastmod: 2020-01-30T21:57:40+08:00 lastmod: 2020-01-30T21:57:40+08:00
@ -17,7 +18,6 @@ tags: [
] ]
categories: [ categories: [
"themes", "themes",
"syntax",
] ]
featured_image: /images/markdown.png featured_image: /images/markdown.png
@ -25,7 +25,7 @@ featured_image_preview: ""
comment: true comment: true
toc: true toc: true
autoCollapseToc: true auto_collapse_toc: true
math: false math: false
--- ---

View file

@ -16,7 +16,7 @@ featu红色_image_preview: ''
comment: true comment: true
toc: true toc: true
autoCollapseToc: false auto_collapse_toc: false
math: true math: true
--- ---

View file

@ -94,9 +94,6 @@ other = "min"
[second] [second]
other = "sec" other = "sec"
[return]
other = "return"
# === posts/single.html === # === posts/single.html ===
# === 404.html === # === 404.html ===

View file

@ -97,9 +97,6 @@ other = "分"
[second] [second]
other = "秒" other = "秒"
[return]
other = "返回"
# === posts/single.html === # === posts/single.html ===
# === 404.html === # === 404.html ===

View file

@ -1,13 +1,13 @@
<figure> <figure>
<img <img
{{- $res := resources.Get "svg/loading.svg" | minify -}} {{ $res := resources.Get "svg/loading.svg" | minify -}}
src="{{ $res.RelPermalink }}" src="{{ $res.RelPermalink }}"
data-sizes="auto" data-sizes="auto"
data-src="{{ .Destination | safeURL }}" data-src="{{ .Destination | safeURL }}"
alt="{{ .Text }}" alt="{{ .Text }}"
{{- with .Title -}} {{ with .Title -}}
title="{{ . }}" title="{{ . }}"
{{- end -}} {{ end -}}
class="lazyload" class="lazyload"
> >
<figcaption class="image-caption"> <figcaption class="image-caption">

View file

@ -1,10 +1,10 @@
<a href="{{ .Destination | safeURL }}" <a href="{{ .Destination | safeURL }}"
{{- with .Title -}} {{ with .Title -}}
title="{{ . }}" title="{{ . }}"
{{- end -}} {{ end -}}
{{- if strings.HasPrefix .Destination "http" -}} {{ if strings.HasPrefix .Destination "http" -}}
target="_blank" target="_blank"
{{- end -}} {{ end -}}
> >
{{- .Text -}} {{- .Text -}}
</a> </a>

View file

@ -17,7 +17,7 @@
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}} {{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}} {{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}} {{- $REin = `<(h[23456]) (id=".+?")>` -}}
@ -28,6 +28,10 @@
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}} {{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $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 -}} {{- $content | safeHTML -}}
</div> </div>
</div> </div>

View file

@ -1,9 +1,7 @@
<article class="post" itemscope itemtype="http://schema.org/Article"> <article class="post" itemscope itemtype="http://schema.org/Article">
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}} {{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Site.Author.name -}} {{- $author := .Params.author | default .Site.Author.name -}}
{{- if isset .Params "author" -}} {{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
{{- $author = .Site.Author.name -}}
{{- end -}}
<!--featured_image--> <!--featured_image-->
{{- with .Params.featured_image -}} {{- with .Params.featured_image -}}
@ -19,11 +17,13 @@
</h1> </h1>
<div class="post-meta"> <div class="post-meta">
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;</a> <a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
</a>
{{ T "publish" }}&nbsp;<time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp; {{ T "publish" }}&nbsp;<time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
{{- with .Params.categories -}} {{- with .Params.categories -}}
<span class="post-category"> <span class="post-category">
{{- T "included" -}} {{- T "included" -}}&nbsp;
{{- range . -}} {{- range . -}}
{{- $name := . -}} {{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}} {{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
@ -41,12 +41,15 @@
</p> </p>
{{- else -}} {{- else -}}
{{- $summary := .Summary -}} {{- $summary := .Summary -}}
{{- $REin := `:\(([\w- ]+?)\):` -}} {{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}} {{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $summary = replaceRE $REin $REout $summary -}} {{- $summary = replaceRE $REin $REout $summary -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}} {{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}} {{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $summary = replaceRE $REin $REout $summary -}} {{- $summary = replaceRE $REin $REout $summary -}}
{{- $summary | safeHTML -}} {{- $summary | safeHTML -}}
{{- end -}} {{- end -}}
</div> </div>
@ -55,7 +58,9 @@
{{- with .Params.tags -}} {{- with .Params.tags -}}
<div class="post-tags"> <div class="post-tags">
{{- range . -}} {{- range . -}}
&nbsp;&nbsp;<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>{{ . }}</a></span> <span class="tag">
&nbsp;<a href="{{ "tags/" | absURL }}{{ . | urlize }}/"><i class="fas fa-tag fa-fw"></i>&nbsp;{{ . }}</a>
</span>
{{- end -}} {{- end -}}
</div> </div>
{{- end -}} {{- end -}}

View file

@ -41,7 +41,9 @@
<section> <section>
{{- with .Params.tags -}} {{- with .Params.tags -}}
{{- range . -}} {{- 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>&nbsp;{{ . }}</a>&nbsp;
</span>
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
</section> </section>

View file

@ -2,20 +2,20 @@
{{- define "content" -}} {{- define "content" -}}
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}} {{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Site.Author.name -}} {{- $author := .Params.author | default .Site.Author.name -}}
{{- if isset .Params "author" -}} {{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
{{- $author = .Site.Author.name -}}
{{- end }}
<article class="warpper"> <article class="warpper">
<h1 class="post-title animated flipInX">{{ .Title }}</h1> <h1 class="post-title animated flipInX">{{ .Title }}</h1>
<div class="post-meta"> <div class="post-meta">
<div class="post-meta-main"> <div class="post-meta-main">
<a class="author" href="{{.Site.BaseURL }}" rel="author"><i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;</a> <a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
</a>
{{- with .Params.categories -}} {{- with .Params.categories -}}
<span class="post-category"> <span class="post-category">
{{- T "included" -}} {{- T "included" -}}&nbsp;
{{- range . -}} {{- range . -}}
{{- $name := . -}} {{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}} {{- 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)) -}} {{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="post-toc" id="post-toc"> <div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2> <h2 class="post-toc-title">{{ T "toc" }}</h2>
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }} {{- $globalAutoCollapseToc := .Site.Params.auto_collapse_toc | default true }}
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}"> <div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.auto_collapse_toc false)) }} always-active{{ end }}">
{{- .TableOfContents -}} {{- .TableOfContents -}}
</div> </div>
</div> </div>
@ -81,17 +81,21 @@
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}} {{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = printf "<sup>[%s]</sup>" (T "return") -}} {{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}} {{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}} {{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+) (id="fnref:.+?")>` -}} {{- $REin = `<(.+?) (id="fnref:.+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}} {{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}} {{- $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 -}} {{- $content | safeHTML -}}
</div> </div>

View file

@ -7,9 +7,9 @@
<h2 class="post-title animated pulse faster"> <h2 class="post-title animated pulse faster">
{{- $taxonomy := .Data.Singular -}} {{- $taxonomy := .Data.Singular -}}
{{- if eq $taxonomy "category" -}} {{- if eq $taxonomy "category" -}}
<i class="far fa-folder-open fa-fw"></i>{{ .Title }} <i class="far fa-folder-open fa-fw"></i>&nbsp;{{ .Title }}
{{- else if eq $taxonomy "tag" -}} {{- else if eq $taxonomy "tag" -}}
<i class="fas fa-tag fa-fw"></i>{{ .Title }} <i class="fas fa-tag fa-fw"></i>&nbsp;{{ .Title }}
{{- else -}} {{- else -}}
{{- printf "%s - %s" (T $taxonomy | default (humanize $taxonomy)) .Title -}} {{- printf "%s - %s" (T $taxonomy | default (humanize $taxonomy)) .Title -}}
{{- end -}} {{- end -}}

View file

@ -20,10 +20,12 @@
{{- $pages := .Pages -}} {{- $pages := .Pages -}}
{{- with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) -}} {{- with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) -}}
<div class="card-item"> <div class="card-item">
<div class="categories"> <div class="card-item-wrapper">
<a href="{{ .Permalink }}"> <h3 class="card-item-title">
<h3><i class="far fa-folder fa-fw"></i>{{ $term | humanize}}</h3> <a href="{{ .Permalink }}">
</a> <i class="far fa-folder fa-fw"></i>&nbsp;{{ $term | humanize}}
</a>
</h3>
{{- range first 5 $pages -}} {{- range first 5 $pages -}}
<article class="archive-item"> <article class="archive-item">
<a href="{{ .Permalink }}" class="archive-item-link"> <a href="{{ .Permalink }}" class="archive-item-link">

File diff suppressed because one or more lines are too long