From 8aa4b6dce6da9601411c7caa07e6352c98ddc4f4 Mon Sep 17 00:00:00 2001 From: Dillon Date: Sat, 1 Feb 2020 01:52:27 +0800 Subject: [PATCH] feat(author): add author_link and fix highlight bug --- archetypes/default.md | 4 +- assets/css/_core/_media.scss | 19 ++++- assets/css/_page/_index.scss | 2 +- assets/css/_page/_terms.scss | 24 +++--- assets/css/_partial/_post/_code.scss | 2 +- assets/css/_partial/_post/_toc.scss | 5 +- assets/css/_variables.scss | 84 +++++++++---------- assets/js/blog.js | 9 +- exampleSite/content/posts/LoveIt-Preview.md | 2 +- exampleSite/content/posts/markdown-syntax.md | 4 +- .../content/posts/Basic-Markdown-Preview.md | 2 +- i18n/en.toml | 3 - i18n/zh.toml | 3 - layouts/_default/_markup/render-image.html | 6 +- layouts/_default/_markup/render-link.html | 8 +- layouts/_default/single.html | 6 +- layouts/_default/summary.html | 19 +++-- layouts/partials/post/footer.html | 4 +- layouts/posts/single.html | 24 +++--- layouts/taxonomy/list.html | 4 +- layouts/taxonomy/terms.html | 10 ++- ...s_b95b077eb505d5c0aff8055eaced30ad.content | 2 +- 22 files changed, 136 insertions(+), 110 deletions(-) diff --git a/archetypes/default.md b/archetypes/default.md index 97e6386d..ad7609c5 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -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 --- diff --git a/assets/css/_core/_media.scss b/assets/css/_core/_media.scss index e8a0f61b..ab9fd36d 100644 --- a/assets/css/_core/_media.scss +++ b/assets/css/_core/_media.scss @@ -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%; } } } diff --git a/assets/css/_page/_index.scss b/assets/css/_page/_index.scss index 8a0b5df4..568d9fd1 100644 --- a/assets/css/_page/_index.scss +++ b/assets/css/_page/_index.scss @@ -3,7 +3,7 @@ .warpper { position: relative; width: 100%; - max-width: 960px; + max-width: 980px; margin: 0 auto; padding-top: 6rem; diff --git a/assets/css/_page/_terms.scss b/assets/css/_page/_terms.scss index 1cfa0219..0288256d 100644 --- a/assets/css/_page/_terms.scss +++ b/assets/css/_page/_terms.scss @@ -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; - } -} \ No newline at end of file diff --git a/assets/css/_partial/_post/_code.scss b/assets/css/_partial/_post/_code.scss index 8d2d0ffe..6be97951 100644 --- a/assets/css/_partial/_post/_code.scss +++ b/assets/css/_partial/_post/_code.scss @@ -65,7 +65,7 @@ p > code { } @each $sign, $text in $code-type-list { - & .#{$sign} table::after { + &.#{$sign} table::after { content: $text; } } diff --git a/assets/css/_partial/_post/_toc.scss b/assets/css/_partial/_post/_toc.scss index 440e7ecf..3be0487f 100644 --- a/assets/css/_partial/_post/_toc.scss +++ b/assets/css/_partial/_post/_toc.scss @@ -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; diff --git a/assets/css/_variables.scss b/assets/css/_variables.scss index f4e1a150..ac180f73 100644 --- a/assets/css/_variables.scss +++ b/assets/css/_variables.scss @@ -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; diff --git a/assets/js/blog.js b/assets/js/blog.js index 6abaeaad..03c453ec 100644 --- a/assets/js/blog.js +++ b/assets/js/blog.js @@ -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(); }); -}); \ No newline at end of file +}); diff --git a/exampleSite/content/posts/LoveIt-Preview.md b/exampleSite/content/posts/LoveIt-Preview.md index f9938d61..30d44aca 100644 --- a/exampleSite/content/posts/LoveIt-Preview.md +++ b/exampleSite/content/posts/LoveIt-Preview.md @@ -16,7 +16,7 @@ featured_image_preview: "" comment: true toc: true -autoCollapseToc: true +auto_collapse_toc: true math: true --- diff --git a/exampleSite/content/posts/markdown-syntax.md b/exampleSite/content/posts/markdown-syntax.md index ffb943a7..5724066c 100644 --- a/exampleSite/content/posts/markdown-syntax.md +++ b/exampleSite/content/posts/markdown-syntax.md @@ -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 --- diff --git a/exampleSite/zh/content/posts/Basic-Markdown-Preview.md b/exampleSite/zh/content/posts/Basic-Markdown-Preview.md index 797dd67f..8231c849 100644 --- a/exampleSite/zh/content/posts/Basic-Markdown-Preview.md +++ b/exampleSite/zh/content/posts/Basic-Markdown-Preview.md @@ -16,7 +16,7 @@ featu红色_image_preview: '' comment: true toc: true -autoCollapseToc: false +auto_collapse_toc: false math: true --- diff --git a/i18n/en.toml b/i18n/en.toml index abf408f3..113b5ad9 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -94,9 +94,6 @@ other = "min" [second] other = "sec" - -[return] -other = "return" # === posts/single.html === # === 404.html === diff --git a/i18n/zh.toml b/i18n/zh.toml index 71c0f36e..d4d54097 100644 --- a/i18n/zh.toml +++ b/i18n/zh.toml @@ -97,9 +97,6 @@ other = "分" [second] other = "秒" - -[return] -other = "返回" # === posts/single.html === # === 404.html === diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index e0341bc8..193374d6 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,13 +1,13 @@
{{ .Text }}
diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index ccac741e..cb9f027b 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,10 +1,10 @@ {{- .Text -}} \ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index eb6e3467..cdc44ca2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -17,7 +17,7 @@ {{- $content = replaceRE $REin $REout $content -}} {{- $REin = `\[return\]` -}} - {{- $REout = printf "[%s]" (T "return") -}} + {{- $REout = `↩︎` -}} {{- $content = replaceRE $REin $REout $content -}} {{- $REin = `<(h[23456]) (id=".+?")>` -}} @@ -28,6 +28,10 @@ {{- $REout = `<$1>` -}} {{- $content = replaceRE $REin $REout $content -}} + {{- $REin = `
  • \s?

    ` -}} + {{- $REout = `

  • ` -}} + {{- $content = replaceRE $REin $REout $content -}} + {{- $content | safeHTML -}} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 8e633468..c67a5dad 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -1,9 +1,7 @@

    {{- $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 -}} {{- with .Params.featured_image -}} @@ -19,11 +17,13 @@ @@ -55,7 +58,9 @@ {{- with .Params.tags -}} {{- end -}} diff --git a/layouts/partials/post/footer.html b/layouts/partials/post/footer.html index 0f5bb069..56a3a474 100644 --- a/layouts/partials/post/footer.html +++ b/layouts/partials/post/footer.html @@ -41,7 +41,9 @@
    {{- with .Params.tags -}} {{- range . -}} - {{ . }} + +  {{ . }}  + {{- end -}} {{- end -}}
    diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 3f098ddd..38fe8fb5 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -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 -}}

    {{ .Title }}