Skip to content

Commit

Permalink
Merge pull request #303 from dillonzq/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored May 1, 2020
2 parents bbea71f + 971eff8 commit e3d774f
Show file tree
Hide file tree
Showing 42 changed files with 184 additions and 175 deletions.
3 changes: 2 additions & 1 deletion assets/css/_partial/_single/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
@include overflow-wrap(break-word);
box-sizing: border-box;
top: if($header-normal-mode-desktop, 5rem, 10rem);
left: $MAX_LENGTH;
left: 0;
visibility: hidden;

@include blur;

Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ enableEmoji = true
snippetLength = 30
# HTML tag name of the highlight part in results
highlightTag = "em"
# whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[languages.en.params.search.algolia]
index = "index.en"
appID = "PASDMWALPK"
Expand Down Expand Up @@ -321,6 +323,8 @@ enableEmoji = true
snippetLength = 50
# 搜索结果中高亮部分的 HTML 标签
highlightTag = "em"
# 是否在搜索索引中使用基于 baseURL 的绝对路径
absoluteURL = false
[languages.zh-cn.params.search.algolia]
index = "index.zh-cn"
appID = "PASDMWALPK"
Expand Down Expand Up @@ -513,6 +517,8 @@ enableEmoji = true
snippetLength = 30
# HTML tag name of the highlight part in results
highlightTag = "em"
# whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[languages.fr.params.search.algolia]
index = "index.fr"
appID = "PASDMWALPK"
Expand Down Expand Up @@ -729,6 +735,9 @@ enableEmoji = true
# whether to show link to Raw Markdown content of the content
# 是否显示原始 Markdown 文档内容的链接
linkToMarkdown = true
# whether to show the full text content in RSS
# 是否在 RSS 中显示全文内容
rssFullText = false
# Table of the contents config
# 目录配置
[params.page.toc]
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/posts/basic-markdown-syntax.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author: "Dillon"
authorLink: "https://dillonzq.com"
description: "This article shows the basic Markdown syntax and format."

tags: ["Markdown"]
tags: ["Markdown", "HTML"]
categories: ["Markdown"]
featuredImage: "/images/basic-markdown-syntax/featured-image.png"

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/posts/basic-markdown-syntax.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Cet article présente la syntaxe et le format de base de Markdown."

tags: ["Markdown"]
tags: ["Markdown", "HTML"]
categories: ["Markdown"]
featuredImage: "/images/basic-markdown-syntax/featured-image.png"

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/posts/basic-markdown-syntax.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author: "Dillon"
authorLink: "https://dillonzq.com"
description: "这篇文章展示了基本的 Markdown 语法和格式."

tags: ["Markdown"]
tags: ["Markdown", "HTML"]
categories: ["Markdown"]
featuredImage: "/images/basic-markdown-syntax/featured-image.png"

Expand Down
6 changes: 6 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ Please open the code block below to view the complete sample configuration :(far
snippetLength = 30
# {{< version 0.2.1 >}} HTML tag name of the highlight part in results
highlightTag = "em"
# {{< version 0.2.4 >}} whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down Expand Up @@ -401,6 +403,8 @@ Please open the code block below to view the complete sample configuration :(far
fontawesome = true
# whether to show link to Raw Markdown content of the content
linkToMarkdown = true
# {{< version 0.2.4 >}} whether to show the full text content in RSS
rssFullText = false
# {{< version 0.2.0 >}} Table of the contents config
[params.page.toc]
# whether to enable the table of the contents
Expand Down Expand Up @@ -985,6 +989,8 @@ Here is the search configuration in your [site configuration](#site-configuratio
snippetLength = 30
# {{< version 0.2.1 >}} HTML tag name of the highlight part in results
highlightTag = "em"
# {{< version 0.2.4 >}} whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ Please open the code block below to view the complete sample configuration :(far
snippetLength = 30
# {{< version 0.2.1 >}} HTML tag name of the highlight part in results
highlightTag = "em"
# {{< version 0.2.4 >}} whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down Expand Up @@ -406,6 +408,8 @@ Please open the code block below to view the complete sample configuration :(far
fontawesome = true
# whether to show link to Raw Markdown content of the content
linkToMarkdown = true
# {{< version 0.2.4 >}} whether to show the full text content in RSS
rssFullText = false
# {{< version 0.2.0 >}} Table of the contents config
[params.page.toc]
# whether to enable the table of the contents
Expand Down Expand Up @@ -990,6 +994,8 @@ Here is the search configuration in your [site configuration](#site-configuratio
snippetLength = 30
# {{< version 0.2.1 >}} HTML tag name of the highlight part in results
highlightTag = "em"
# {{< version 0.2.4 >}} whether to use the absolute URL based on the baseURL in search index
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ hugo
snippetLength = 50
# {{< version 0.2.1 >}} 搜索结果中高亮部分的 HTML 标签
highlightTag = "em"
# {{< version 0.2.4 >}} 是否在搜索索引中使用基于 baseURL 的绝对路径
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down Expand Up @@ -404,6 +406,8 @@ hugo
fontawesome = true
# 是否在文章页面显示原始 Markdown 文档链接
linkToMarkdown = true
# {{< version 0.2.4 >}} 是否在 RSS 中显示全文内容
rssFullText = false
# {{< version 0.2.0 >}} 目录配置
[params.page.toc]
# 是否使用目录
Expand Down Expand Up @@ -990,6 +994,8 @@ defaultContentLanguage = "zh-cn"
snippetLength = 50
# {{< version 0.2.1 >}} 搜索结果中高亮部分的 HTML 标签
highlightTag = "em"
# {{< version 0.2.4 >}} 是否在搜索索引中使用基于 baseURL 的绝对路径
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
Expand Down
4 changes: 3 additions & 1 deletion exampleSite/content/posts/theme-documentation-content.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ruby: true
fraction: true
fontawesome: true
linkToMarkdown: true
rssFullText: false

toc:
enable: true
Expand Down Expand Up @@ -112,7 +113,8 @@ comment:
* **ruby**: {{< version 0.2.0 >}} if `true`, the content will enable the [ruby extended syntax](#ruby).
* **fraction**: {{< version 0.2.0 >}} if `true`, the content will enable the [fraction extended syntax](#fraction).
* **fontawesome**: {{< version 0.2.0 >}} if `true`, the content will enable the [Font Awesome extended syntax](#fontawesome).
* **linkToMarkdown**: if `true`, the footer of the content will show the link to the orignal Markdown file.
* **linkToMarkdown**: if `true`, the footer of the content will be shown the link to the orignal Markdown file.
* **rssFullText**: {{< version 0.2.4 >}} if `true`, the full text content will be shown in RSS.

* **toc**: {{< version 0.2.0 changed >}} the same as the `params.page.toc` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **code**: {{< version 0.2.0 >}} the same as the `params.page.code` part in the [site configuration](../theme-documentation-basics#site-configuration).
Expand Down
4 changes: 3 additions & 1 deletion exampleSite/content/posts/theme-documentation-content.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ ruby: true
fraction: true
fontawesome: true
linkToMarkdown: true
rssFullText: false

toc:
enable: true
Expand Down Expand Up @@ -117,7 +118,8 @@ comment:
* **ruby**: {{< version 0.2.0 >}} if `true`, the content will enable the [ruby extended syntax](#ruby).
* **fraction**: {{< version 0.2.0 >}} if `true`, the content will enable the [fraction extended syntax](#fraction).
* **fontawesome**: {{< version 0.2.0 >}} if `true`, the content will enable the [Font Awesome extended syntax](#fontawesome).
* **linkToMarkdown**: if `true`, the footer of the content will show the link to the orignal Markdown file.
* **linkToMarkdown**: if `true`, the footer of the content will be shown the link to the orignal Markdown file.
* **rssFullText**: {{< version 0.2.4 >}} if `true`, the full text content will be shown in RSS.

* **toc**: {{< version 0.2.0 changed >}} the same as the `params.page.toc` part in the [site configuration](../theme-documentation-basics#site-configuration).
* **code**: {{< version 0.2.0 >}} the same as the `params.page.code` part in the [site configuration](../theme-documentation-basics#site-configuration).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ruby: true
fraction: true
fontawesome: true
linkToMarkdown: true
rssFullText: false

toc:
enable: true
Expand Down Expand Up @@ -113,6 +114,7 @@ comment:
* **fraction**: {{< version 0.2.0 >}} 如果设为 `true`, 这篇文章会使用 [分数扩展语法](#fraction).
* **fontawesome**: {{< version 0.2.0 >}} 如果设为 `true`, 这篇文章会使用 [Font Awesome 扩展语法](#fontawesome).
* **linkToMarkdown**: 如果设为 `true`, 内容的页脚将显示指向原始 Markdown 文件的链接.
* **rssFullText**: {{< version 0.2.4 >}} 如果设为 `true`, 在 RSS 中将会显示全文内容.

* **toc**: {{< version 0.2.0 changed >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.toc` 部分相同.
* **code**: {{< version 0.2.0 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.code` 部分相同.
Expand Down
2 changes: 1 addition & 1 deletion layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- define "title" }}
{{- T "pageNotFound" | printf "404 %s" }} | {{ .Site.Title -}}
{{- T "pageNotFound" | printf "404 %s" }} - {{ .Site.Title -}}
{{- end -}}

{{- define "content" -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- with .Title -}}
<figure>
{{- partial "plugin/image.html" (dict "src" $.Destination "alt" $.Text "caption" . "linked" true) -}}
{{- dict "src" $.Destination "alt" $.Text "caption" . "linked" true | partial "plugin/image.html" -}}
<figcaption class="image-caption">
{{- . | safeHTML -}}
</figcaption>
</figure>
{{- else -}}
{{- partial "plugin/image.html" (dict "src" .Destination "alt" .Text) -}}
{{- dict "src" .Destination "alt" .Text | partial "plugin/image.html" -}}
{{- end -}}
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{- end -}}

{{- $params := .Params | merge .Site.Params.page -}}
{{- .Scratch.Set "version" "0.2.3" -}}
{{- .Scratch.Set "version" "0.2.4" -}}

{{- if eq hugo.Environment "production" -}}
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/section.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- define "title" }}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") }} - {{ .Site.Title -}}
{{- end -}}

{{- define "content" -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
{{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}}

{{- define "content" -}}
{{- $params := .Scratch.Get "params" -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="featured-image-preview">
<a href="{{ $.RelPermalink }}">
{{- $image := $params.featuredimagepreview | default . -}}
{{- partial "plugin/image.html" (dict "src" $image "alt" $.Description "large" true) -}}
{{- dict "src" $image "alt" $.Description "large" true | partial "plugin/image.html" -}}
</a>
</div>
{{- end -}}
Expand Down
73 changes: 39 additions & 34 deletions layouts/index.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
{{- $index := slice -}}
{{- $pages := .Site.RegularPages -}}
{{- if .Site.Params.page.hiddenFromSearch -}}
{{- $pages = where $pages "Params.hiddenfromsearch" false -}}
{{- else -}}
{{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}}
{{- end -}}
{{- range $pages -}}
{{- $uri := .RelPermalink -}}
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}}
{{- $meta = .PublishDate.Format ($.Site.Params.dateFormat | default "2006-01-02") | dict "date" | merge $meta -}}
{{- with .Description -}}
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}
{{- if .Site.Params.search -}}
{{- $index := slice -}}
{{- $pages := .Site.RegularPages -}}
{{- if .Site.Params.page.hiddenFromSearch -}}
{{- $pages = where $pages "Params.hiddenfromsearch" false -}}
{{- else -}}
{{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}}
{{- end -}}
{{- $params := .Params | merge $.Site.Params.page -}}
{{/* Extended Markdown syntax */}}
{{- $content := dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" -}}
{{/* Remove line number for code */}}
{{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}}
{{- range $i, $contenti := split $content "<h2 id=" -}}
{{- if gt $i 0 -}}
{{- $contenti = printf "<h2 id=%s" $contenti -}}
{{- range $pages -}}
{{- $uri := .RelPermalink -}}
{{- if $.Site.Params.search.absoluteURL -}}
{{- $uri = .Permalink -}}
{{- end -}}
{{- range $j, $contentj := split $contenti "<h3 id=" -}}
{{- if gt $j 0 -}}
{{- $contentj = printf "<h3 id=%s" $contentj -}}
{{- end -}}
{{/* Plainify, unescape and remove (\n, \t) */}}
{{- $contentj = $contentj | plainify | htmlUnescape | replaceRE `[\n\t ]+` " " -}}
{{- if gt $.Site.Params.search.contentLength 0 -}}
{{- $contentj = substr $contentj 0 $.Site.Params.search.contentLength -}}
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}}
{{- $meta = .PublishDate.Format ($.Site.Params.dateFormat | default "2006-01-02") | dict "date" | merge $meta -}}
{{- with .Description -}}
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}
{{- end -}}
{{- $params := .Params | merge $.Site.Params.page -}}
{{/* Extended Markdown syntax */}}
{{- $content := dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" -}}
{{/* Remove line number for code */}}
{{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}}
{{- range $i, $contenti := split $content "<h2 id=" -}}
{{- if gt $i 0 -}}
{{- $contenti = printf "<h2 id=%s" $contenti -}}
{{- end -}}
{{- if $contentj | and (ne $contentj " ") -}}
{{- $one := printf "%s:%d:%d" $uri $i $j | dict "content" $contentj "objectID" | merge $meta -}}
{{- $index = $index | append $one -}}
{{- range $j, $contentj := split $contenti "<h3 id=" -}}
{{- if gt $j 0 -}}
{{- $contentj = printf "<h3 id=%s" $contentj -}}
{{- end -}}
{{/* Plainify, unescape and remove (\n, \t) */}}
{{- $contentj = $contentj | plainify | htmlUnescape | replaceRE `[\n\t ]+` " " -}}
{{- if gt $.Site.Params.search.contentLength 0 -}}
{{- $contentj = substr $contentj 0 $.Site.Params.search.contentLength -}}
{{- end -}}
{{- if $contentj | and (ne $contentj " ") -}}
{{- $one := printf "%s:%d:%d" $uri $i $j | dict "content" $contentj "objectID" | merge $meta -}}
{{- $index = $index | append $one -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- $index | jsonify | safeJS -}}
{{- $index | jsonify | safeJS -}}
{{- end -}}
25 changes: 1 addition & 24 deletions layouts/index.rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,7 @@
{{- end -}}
<atom:link href="{{ .Permalink }}" rel="self" type="application/rss+xml" />
{{- range where .Site.RegularPages "Type" "posts" | first (.Site.Params.home.rss | default 10) -}}
<item>
<title>
{{- .Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<pubDate>
{{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
</pubDate>
<author>
{{- .Params.author | default $.Site.Author.name | default (T "author") -}}
</author>
<guid>
{{- .Permalink -}}
</guid>
<description>
{{- with .Summary -}}
{{- dict "content" . "ruby" true "fraction" true "fontawesome" true | partial "function/content.html" | plainify -}}
{{- else -}}
{{- .Description | plainify -}}
{{- end -}}
</description>
</item>
{{- dict "page" . "site" .Site | partial "rss/item.html" -}}
{{- end -}}
</channel>
</rss>
2 changes: 1 addition & 1 deletion layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
</script>

{{- /* Polyfill.io */ -}}
{{- partial "plugin/script.html" (dict "source" "https://polyfill.io/v3/polyfill.min.js?features=Element.prototype.closest%2CrequestAnimationFrame%2CCustomEvent%2CPromise%2CObject.entries%2CObject.assign%2CObject.values%2Cfetch%2CElement.prototype.after%2CArray.prototype.fill%2CIntersectionObserver%2CArray.from%2CArray.prototype.find%2CMath.sign") -}}
{{- dict "source" "https://polyfill.io/v3/polyfill.min.js?features=Element.prototype.closest%2CrequestAnimationFrame%2CCustomEvent%2CPromise%2CObject.entries%2CObject.assign%2CObject.values%2Cfetch%2CElement.prototype.after%2CArray.prototype.fill%2CIntersectionObserver%2CArray.from%2CArray.prototype.find%2CMath.sign" | partial "plugin/script.html" -}}

{{- range (.Scratch.Get "this").script -}}
{{- partial "plugin/script.html" . -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}">
{{- with .Site.Params.header.title -}}
{{- with .logo -}}
{{- partial "plugin/image.html" (dict "src" . "alt" $.Site.Title "class" "logo") -}}
{{- dict "src" . "alt" $.Site.Title "class" "logo" | partial "plugin/image.html" -}}
{{- end -}}
{{- with .pre -}}
<span class="header-title-pre">{{ . | safeHTML }}</span>
Expand Down Expand Up @@ -83,7 +83,7 @@
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}">
{{- with .Site.Params.header.title -}}
{{- with .logo -}}
{{- partial "plugin/image.html" (dict "src" . "alt" $.Site.Title "class" "logo") -}}
{{- dict "src" . "alt" $.Site.Title "class" "logo" | partial "plugin/image.html" -}}
{{- end -}}
{{- with .pre -}}
<span class="header-title-pre">{{ . | safeHTML }}</span>
Expand Down
Loading

0 comments on commit e3d774f

Please sign in to comment.