fix(hugo): compatibility for Hugo basic version (#315)

This commit is contained in:
Dillon 2020-05-04 15:19:18 +08:00 committed by GitHub
parent e4c71edddf
commit 4190c79491
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 17 deletions

1
.gitignore vendored
View file

@ -1,7 +1,6 @@
# Hugo default output directory
public/
/exampleSite/resources/
/resources/_gen/assets/scss/temp
node_modules/
build/

View file

@ -26,14 +26,14 @@ Discover what the Hugo - **LoveIt** theme is all about and the core-concepts beh
Thanks to the simplicity of Hugo, [Hugo](https://gohugo.io/) is the only dependency of this theme.
Just install latest version of [:(far fa-file-archive fa-fw): Hugo extended (> 0.62.0)](https://gohugo.io/getting-started/installing/) for your OS (**Windows**, **Linux**, **macOS**).
Just install latest version of [:(far fa-file-archive fa-fw): Hugo (> 0.62.0)](https://gohugo.io/getting-started/installing/) for your OS (**Windows**, **Linux**, **macOS**).
{{< admonition note "Why not support earlier versions of Hugo?" >}}
Since [Markdown Render Hooks](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) was introduced in the [Hugo Christmas Edition](https://gohugo.io/news/0.62.0-relnotes/), this theme only supports Hugo versions above **0.62.0**.
{{< /admonition >}}
{{< admonition note "Why need the Hugo extended version?" >}}
Since the theme processes SCSS to CSS, Hugo needs to be the **extended** version.
{{< admonition tip "Hugo extended version is recommended" >}}
Since some features of this theme need to processes :(fab fa-sass fa-fw): SCSS to :(fab fa-css3 fa-fw): CSS, it is recommended to use Hugo **extended** version for better experience.
{{< /admonition >}}
## 2 Installation

View file

@ -31,14 +31,14 @@ Welcome to take the time to propose a translation by [:(fas fa-code-branch fa-fw
Thanks to the simplicity of Hugo, [Hugo](https://gohugo.io/) is the only dependency of this theme.
Just install latest version of [:(far fa-file-archive fa-fw): Hugo extended (> 0.62.0)](https://gohugo.io/getting-started/installing/) for your OS (**Windows**, **Linux**, **macOS**).
Just install latest version of [:(far fa-file-archive fa-fw): Hugo (> 0.62.0)](https://gohugo.io/getting-started/installing/) for your OS (**Windows**, **Linux**, **macOS**).
{{< admonition note "Why not support earlier versions of Hugo?" >}}
Since [Markdown Render Hooks](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) was introduced in the [Hugo Christmas Edition](https://gohugo.io/news/0.62.0-relnotes/), this theme only supports Hugo versions above **0.62.0**.
{{< /admonition >}}
{{< admonition note "Why need the Hugo extended version?" >}}
Since the theme processes SCSS to CSS, Hugo needs to be the **extended** version.
{{< admonition tip "Hugo extended version is recommended" >}}
Since some features of this theme need to processes :(fab fa-sass fa-fw): SCSS to :(fab fa-css3 fa-fw): CSS, it is recommended to use Hugo **extended** version for better experience.
{{< /admonition >}}
## 2 Installation

View file

@ -26,7 +26,7 @@ toc:
由于 Hugo 提供的便利性, [Hugo](https://gohugo.io/) 本身是这个主题唯一的依赖.
直接安装满足你操作系统 (**Windows**, **Linux**, **macOS**) 的最新版本 [:(far fa-file-archive fa-fw): Hugo extended (> 0.62.0)](https://gohugo.io/getting-started/installing/).
直接安装满足你操作系统 (**Windows**, **Linux**, **macOS**) 的最新版本 [:(far fa-file-archive fa-fw): Hugo (> 0.62.0)](https://gohugo.io/getting-started/installing/).
{{< admonition note "为什么不支持早期版本的 Hugo?" >}}
由于 [Markdown 渲染钩子函数](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) 在 [Hugo 圣诞节版本](https://gohugo.io/news/0.62.0-relnotes/) 中被引入, 本主题只支持高于 **0.62.0** 的 Hugo 版本.
@ -36,6 +36,10 @@ toc:
由于本主题需要转换 SCSS 文件为 CSS 文件, Hugo **extended** 版本是必要的.
{{< /admonition >}}
{{< admonition tip "推荐使用 Hugo extended 版本" >}}
由于这个主题的一些特性需要将 :(fab fa-sass fa-fw): SCSS 转换为 :(fab fa-css3 fa-fw): CSS, 推荐使用 Hugo **extended** 版本来获得更好的使用体验.
{{< /admonition >}}
## 2 安装
以下步骤可帮助你初始化新网站. 如果你根本不了解 Hugo, 我们强烈建议你按照此 [快速入门文档](https://gohugo.io/getting-started/quick-start/) 进一步了解它.

View file

@ -24,6 +24,10 @@ lightgallery: true
{{< version 0.2.0 changed >}}
{{< admonition >}}
Hugo **extended** version is necessary for `style` shortcode.
{{< /admonition >}}
`style` is a shortcode to insert custom style in your post.
The `style` shortcode has two positional parameters.

View file

@ -29,6 +29,10 @@ Welcome to take the time to propose a translation by [:(fas fa-code-branch fa-fw
{{< version 0.2.0 changed >}}
{{< admonition >}}
Hugo **extended** version is necessary for `style` shortcode.
{{< /admonition >}}
`style` is a shortcode to insert custom style in your post.
The `style` shortcode has two positional parameters.

View file

@ -27,6 +27,10 @@ mapbox:
{{< version 0.2.0 changed >}}
{{< admonition >}}
Hugo **extended** 版本对于 `style` shortcode 是必需的.
{{< /admonition >}}
`style` shortcode 用来在你的文章中插入自定义样式.
`style` shortcode 有两个位置参数.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View file

@ -1,8 +1,6 @@
{{- /* ID */ -}}
{{- /* Content -> unique ID */ -}}
{{- /* shuffle md5 as id */ -}}
{{- $id := delimit (split (md5 now.Unix) "" | shuffle | first 6) "" | printf "id-%s" -}}
{{- with .scratch -}}
{{- dict $id $.content | dict "data" | dict "config" | merge (.Get "this") | .Set "this" -}}
{{- end -}}
{{- $count := (.scratch.Get "this").count | default 1 -}}
{{- $id := printf "id-%d" $count -}}
{{- $count | add 1 | .scratch.SetInMap "this" "count" -}}
{{- dict $id .content | dict "data" | dict "config" | merge (.scratch.Get "this") | .scratch.Set "this" -}}
{{- return $id -}}

View file

@ -1,10 +1,10 @@
{{- $content := .Inner | .Page.RenderString -}}
{{- $id := dict "content" $content | partial "function/id.html" -}}
{{- $id := dict "content" $content "scratch" .Page.Scratch | partial "function/id.html" -}}
{{- $tag := .Get 1 | default "div" -}}
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
{{- $style := .Get 0 | printf "#%s{%s}" $id -}}
{{- $res := resources.FromString (printf "temp/%s.scss" $id) $style -}}
{{- $res = $res | toCSS (dict "targetPath" (printf "temp/%s.css" $id)) -}}
{{- $res := resources.FromString (printf "stype/%s.scss" $id) $style -}}
{{- $res = $res | toCSS (dict "targetPath" (printf "stype/%s.css" $id)) -}}
{{- $styleArr := (.Page.Scratch.Get "this").styleArr | default slice -}}
{{- $styleArr | append $res.Content | .Page.Scratch.SetInMap "this" "styleArr" -}}

View file

@ -0,0 +1,2 @@
#id-1 img {
height: 1.25rem; }

View file

@ -0,0 +1 @@
{"Target":"stype/id-1.css","MediaType":"text/css","Data":{}}