Skip to content

Commit

Permalink
chore: rm version detection and refactor config
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed May 7, 2022
1 parent 857047a commit c878a74
Show file tree
Hide file tree
Showing 17 changed files with 1,096 additions and 520 deletions.
581 changes: 581 additions & 0 deletions config.toml

Large diffs are not rendered by default.

825 changes: 410 additions & 415 deletions exampleSite/config.toml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "This article shows the basic Markdown syntax and format."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "这篇文章展示了基本的 Markdown 语法和格式."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.png"
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/emoji-support/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Guide to emoji usage in Hugo and LoveIt."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/emoji-support/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Hugo 和 LoveIt 中的 Emoji 的用法指南."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
93 changes: 44 additions & 49 deletions exampleSite/content/posts/theme-documentation-basics/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Discover what the Hugo - LoveIt theme is all about and the core-concepts behind it."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down Expand Up @@ -85,10 +86,6 @@ title = "My New Hugo Site"
# Change the default theme to be use when building the site with Hugo
theme = "LoveIt"

[params]
# LoveIt theme version
version = "0.2.X"

[menu]
[[menu.main]]
identifier = "posts"
Expand Down Expand Up @@ -194,12 +191,6 @@ Please open the code block below to view the complete sample configuration :(far

```toml
[params]
# {{< version 0.2.0 changed >}} LoveIt theme version
version = "0.2.X"
# site description
description = "This is My New Hugo Site"
# site keywords
keywords = ["Theme", "Hugo"]
# site default theme ("light", "dark", "auto")
defaultTheme = "auto"
# public git repo url only then enableGitInfo is true
Expand All @@ -209,46 +200,13 @@ Please open the code block below to view the complete sample configuration :(far
fingerprint = ""
# {{< version 0.2.0 >}} date format
dateFormat = "2006-01-02"
# website title for Open Graph and Twitter Cards
title = "My cool site"
# website description for RSS, SEO, Open Graph and Twitter Cards
description = "This is my cool site"
# website images for Open Graph and Twitter Cards
images = ["/logo.png"]

# {{< version 0.2.0 >}} App icon config
[params.app]
# optional site title override for the app when added to an iOS home screen or Android launcher
title = "LoveIt"
# whether to omit favicon resource links
noFavicon = false
# modern SVG favicon to use in place of older style .png and .ico files
svgFavicon = ""
# Android browser theme color
themeColor = "#ffffff"
# Safari mask icon color
iconColor = "#5bbad5"
# Windows v8-10 tile color
tileColor = "#da532c"

# {{< version 0.2.0 >}} Search config
[params.search]
enable = true
# type of search engine ("lunr", "algolia")
type = "lunr"
# max index length of the chunked content
contentLength = 4000
# placeholder of the search bar
placeholder = ""
# {{< version 0.2.1 >}} max number of results length
maxResultLength = 10
# {{< version 0.2.3 >}} snippet length of the result
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 = ""
searchKey = ""

# Header config
[params.header]
# desktop header mode ("fixed", "normal", "auto")
Expand Down Expand Up @@ -304,6 +262,43 @@ Please open the code block below to view the complete sample configuration :(far
# amount of RSS pages
rss = 10

# {{< version 0.2.0 >}} App icon config
[params.app]
# optional site title override for the app when added to an iOS home screen or Android launcher
title = "My cool site"
# whether to omit favicon resource links
noFavicon = false
# modern SVG favicon to use in place of older style .png and .ico files
svgFavicon = ""
# Android browser theme color
themeColor = "#ffffff"
# Safari mask icon color
iconColor = "#5bbad5"
# Windows v8-10 tile color
tileColor = "#da532c"

# {{< version 0.2.0 >}} Search config
[params.search]
enable = true
# type of search engine ("lunr", "algolia")
type = "lunr"
# max index length of the chunked content
contentLength = 4000
# placeholder of the search bar
placeholder = ""
# {{< version 0.2.1 >}} max number of results length
maxResultLength = 10
# {{< version 0.2.3 >}} snippet length of the result
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 = ""
searchKey = ""

# Home page config
[params.home]
# {{< version 0.2.0 >}} amount of RSS pages
Expand Down Expand Up @@ -401,7 +396,7 @@ Please open the code block below to view the complete sample configuration :(far
Email = "[email protected]"
RSS = true # {{< version 0.2.0 >}}

# {{< version 0.2.0 changed >}} Page config
# {{< version 0.2.0 changed >}} Page global config
[params.page]
# {{< version 0.2.0 >}} whether to hide a page from home page
hiddenFromHomePage = false
Expand Down Expand Up @@ -496,7 +491,7 @@ Please open the code block below to view the complete sample configuration :(far
Mix = false
# {{< version 0.2.0 changed >}} Comment config
[params.page.comment]
enable = true
enable = false
# {{< link "https://disqus.com/" Disqus >}} comment config
[params.page.comment.disqus]
# {{< version 0.1.1 >}}
Expand Down
89 changes: 44 additions & 45 deletions exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "探索 Hugo - LoveIt 主题的全部内容和背后的核心概念."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down Expand Up @@ -197,12 +198,6 @@ hugo

```toml
[params]
# {{< version 0.2.0 changed >}} LoveIt 主题版本
version = "0.2.X"
# 网站描述
description = "这是我的全新 Hugo 网站"
# 网站关键词
keywords = ["Theme", "Hugo"]
# 网站默认主题样式 ("light", "dark", "auto")
defaultTheme = "auto"
# 公共 git 仓库路径,仅在 enableGitInfo 设为 true 时有效
Expand All @@ -212,46 +207,13 @@ hugo
fingerprint = ""
# {{< version 0.2.0 >}} 日期格式
dateFormat = "2006-01-02"
# 网站标题, 用于 Open Graph 和 Twitter Cards
title = "我的网站"
# 网站描述, 用于 RSS, SEO, Open Graph 和 Twitter Cards
description = "这是我的全新 Hugo 网站"
# 网站图片, 用于 Open Graph 和 Twitter Cards
images = ["/logo.png"]

# {{< version 0.2.0 >}} 应用图标配置
[params.app]
# 当添加到 iOS 主屏幕或者 Android 启动器时的标题, 覆盖默认标题
title = "LoveIt"
# 是否隐藏网站图标资源链接
noFavicon = false
# 更现代的 SVG 网站图标, 可替代旧的 .png 和 .ico 文件
svgFavicon = ""
# Android 浏览器主题色
themeColor = "#ffffff"
# Safari 图标颜色
iconColor = "#5bbad5"
# Windows v8-10磁贴颜色
tileColor = "#da532c"

# {{< version 0.2.0 >}} 搜索配置
[params.search]
enable = true
# 搜索引擎的类型 ("lunr", "algolia")
type = "lunr"
# 文章内容最长索引长度
contentLength = 4000
# 搜索框的占位提示语
placeholder = ""
# {{< version 0.2.1 >}} 最大结果数目
maxResultLength = 10
# {{< version 0.2.3 >}} 结果内容片段长度
snippetLength = 50
# {{< version 0.2.1 >}} 搜索结果中高亮部分的 HTML 标签
highlightTag = "em"
# {{< version 0.2.4 >}} 是否在搜索索引中使用基于 baseURL 的绝对路径
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
searchKey = ""

# 页面头部导航栏配置
[params.header]
# 桌面端导航栏模式 ("fixed", "normal", "auto")
Expand Down Expand Up @@ -307,6 +269,43 @@ hugo
# RSS 文章数目
rss = 10

# {{< version 0.2.0 >}} 应用图标配置
[params.app]
# 当添加到 iOS 主屏幕或者 Android 启动器时的标题, 覆盖默认标题
title = "我的网站"
# 是否隐藏网站图标资源链接
noFavicon = false
# 更现代的 SVG 网站图标, 可替代旧的 .png 和 .ico 文件
svgFavicon = ""
# Android 浏览器主题色
themeColor = "#ffffff"
# Safari 图标颜色
iconColor = "#5bbad5"
# Windows v8-10磁贴颜色
tileColor = "#da532c"

# {{< version 0.2.0 >}} 搜索配置
[params.search]
enable = true
# 搜索引擎的类型 ("lunr", "algolia")
type = "lunr"
# 文章内容最长索引长度
contentLength = 4000
# 搜索框的占位提示语
placeholder = ""
# {{< version 0.2.1 >}} 最大结果数目
maxResultLength = 10
# {{< version 0.2.3 >}} 结果内容片段长度
snippetLength = 50
# {{< version 0.2.1 >}} 搜索结果中高亮部分的 HTML 标签
highlightTag = "em"
# {{< version 0.2.4 >}} 是否在搜索索引中使用基于 baseURL 的绝对路径
absoluteURL = false
[params.search.algolia]
index = ""
appID = ""
searchKey = ""

# 主页配置
[params.home]
# {{< version 0.2.0 >}} RSS 文章数目
Expand Down Expand Up @@ -404,7 +403,7 @@ hugo
Email = "[email protected]"
RSS = true # {{< version 0.2.0 >}}

# {{< version 0.2.0 changed >}} 文章页面配置
# {{< version 0.2.0 changed >}} 文章页面全局配置
[params.page]
# {{< version 0.2.0 >}} 是否在主页隐藏一篇文章
hiddenFromHomePage = false
Expand Down Expand Up @@ -499,7 +498,7 @@ hugo
Mix = false
# {{< version 0.2.0 changed >}} 评论系统设置
[params.page.comment]
enable = true
enable = false
# {{< link "https://disqus.com/" Disqus >}} 评论系统设置
[params.page.comment.disqus]
# {{< version 0.1.1 >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Hugo provides multiple built-in shortcodes for author convenience and to keep your markdown content clean."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Hugo 提供了多个内置的 Shortcodes, 以方便作者保持 Markdown 内容的整洁."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "Find out how to create and organize your content quickly and intuitively in LoveIt theme."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "了解如何在 LoveIt 主题中快速, 直观地创建和组织内容."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "LoveIt theme provides multiple shortcodes on top of built-in ones in Hugo."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "LoveIt 主题在 Hugo 内置的 shortcode 的基础上提供多个扩展的 shortcode."
images: ["featured-image.png"]
resources:
- name: "featured-image"
src: "featured-image.jpg"
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/dillonzq/LoveIt

go 1.18
10 changes: 0 additions & 10 deletions layouts/partials/init.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{{- .Scratch.Set "version" "0.2.10" -}}

{{- /* LoveIt theme version detection */ -}}
{{- $VERSION := "0.2.X" -}}
{{- if eq .Site .Sites.First -}}
{{- if not .Site.Params.version -}}
{{- errorf "Configuration Error 配置文件错误\n\nYou haven't configured the LoveIt version param correctly yet. See https://hugoloveit.com/theme-documentation-basics/#basic-configuration\n你还没有正确配置 LoveIt 的版本参数. 参考 https://hugoloveit.com/zh-cn/theme-documentation-basics/#basic-configuration\n" -}}
{{- else if ne .Site.Params.version $VERSION -}}
{{- errorf (printf "Compatibility Error 兼容性错误\n\n%v -> %v:\nYou have an incompatible update. See https://github.com/dillonzq/LoveIt/releases\n你进行了一次不兼容的更新. 参考 https://github.com/dillonzq/LoveIt/releases\n" .Site.Params.version $VERSION) -}}
{{- end -}}
{{- end -}}

{{- $params := .Params | merge .Site.Params.page -}}

{{- if eq hugo.Environment "production" -}}
Expand Down
Loading

0 comments on commit c878a74

Please sign in to comment.