Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix(hugo): compatibility for Hugo basic version (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored May 4, 2020
1 parent e4c71ed commit 4190c79
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Hugo default output directory
public/
/exampleSite/resources/
/resources/_gen/assets/scss/temp

node_modules/
build/
Expand Down
6 changes: 3 additions & 3 deletions exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 版本.
Expand All @@ -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/) 进一步了解它.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ mapbox:

{{< version 0.2.0 changed >}}

{{< admonition >}}
Hugo **extended** 版本对于 `style` shortcode 是必需的.
{{< /admonition >}}

`style` shortcode 用来在你的文章中插入自定义样式.

`style` shortcode 有两个位置参数.
Expand Down
Binary file modified images/tn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions layouts/partials/function/id.html
Original file line number Diff line number Diff line change
@@ -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 -}}
6 changes: 3 additions & 3 deletions layouts/shortcodes/style.html
Original file line number Diff line number Diff line change
@@ -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" -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#id-1 img {
height: 1.25rem; }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"stype/id-1.css","MediaType":"text/css","Data":{}}

0 comments on commit 4190c79

Please sign in to comment.