Skip to content

Commit

Permalink
🚧 optimization some module design.
Browse files Browse the repository at this point in the history
  • Loading branch information
elkan1788 committed Jul 2, 2022
1 parent a758a6b commit a2f2966
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hugo theme of NexT
# Hugo NexT

![hugo-next-primary](https://lisenhui.gitee.io/imgs/hugo-next/logo/hugo-next-primary.png)

Expand Down
25 changes: 12 additions & 13 deletions exampleSite/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ params:
serverURL: #<your waline server url>

# Artalk 评论插件
# 更多配置信息请参考:
# 更多配置信息请参考:https://artalk.js.org
# Artalk comments system
# More info see: https://artalk.js.org
artalk:
Expand Down Expand Up @@ -801,16 +801,16 @@ params:
giscus:
# Github 仓库地址,格式:用户名/仓库名称
# Github repository owner and name
repo: hugo-next/hugo-theme-next
repo: username/repo_name
# Giscus 生成的仓库 Id
# Generate repository Id from Giscus
repoId: R_kgDOHRjXGA
repoId: #<repo_id>
# 讨论区的分类名称
# Github discussions category
category: Comments
category: Announcements
# 讨论区分类 ID
# Generate category Id from Giscus
categoryId: DIC_kwDOHRjXGM4CP8S4
categoryId: #<category_id>
# 讨论区帖子标题,可选值: pathname | url | title | og:title | 自定义
# Available values: pathname | url | title | og:title | custom
mapping: title
Expand Down Expand Up @@ -848,11 +848,12 @@ params:
# Statistics and Analytics
# ---------------------------------------------------------------

# 51La站点统计
# 更多信息请参考:https://invite.51.la/1NUfGTS1?target=V6
# 51La Analytics
# See: https://invite.51.la/1NUfGTS1?target=V6
laId: # <app_id>
analytics:
# 51La 站点统计
# 更多信息请参考:https://invite.51.la/1NUfGTS1?target=V6
# 51La Analytics
# See: https://invite.51.la/1NUfGTS1?target=V6
laId: #<anaytics_id>

# TODO
# Show Views / Visitors of the website / page with busuanzi.
Expand Down Expand Up @@ -1029,6 +1030,4 @@ params:
# The js option is only valid when vendors.internal is local.
css: css
js: js
images: imgs


images: imgs
2 changes: 1 addition & 1 deletion exampleSite/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ next() {
██║ ╚████║███████╗██╔╝ ██╗ ██║
╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝
========================================
NexT version $1
Hugo NexT version $1
Documentation: https://hugo-next.eu.org
========================================
EOT
Expand Down
20 changes: 3 additions & 17 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
{{- .Scratch.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) -}}
{{- .Scratch.Set "catsCount" (len .Site.Taxonomies.categories) -}}
{{- .Scratch.Set "tagsCount" (len .Site.Taxonomies.tags) -}}
{{- $vendors := .Site.Data.resources.vendors -}}
{{- $pluginVen := .Site.Params.vendors.plugins -}}
{{- $pluginCDN := index $vendors $pluginVen -}}
{{- .Scratch.Set "pluginCDN" $pluginCDN -}}
{{- partial "init.html" . -}}
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
{{ hugo.Generator }}
<link rel="shortcut icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon.small }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ .Site.Params.favicon.medium }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ .Site.Params.favicon.appleTouchIcon }}">
{{- partial "head.html" . }}
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
<noscript>
Expand Down Expand Up @@ -48,11 +34,11 @@
</main>
<footer class="footer">
<div class="footer-inner">
{{- partial "footer" . }}
{{- partial "footer.html" . }}
</div>
</footer>

{{- partial "scripts" . }}
{{- partialCached "scripts.html" . }}
</body>

</html>
4 changes: 1 addition & 3 deletions layouts/partials/_thirdparty/analytics/51la.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
{{- with .Site.Params.laId }}
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
<script charset="UTF-8" id="LA_COLLECT" src="https://sdk.51.la/js-sdk-pro.min.js"></script>
<script>LA.init({id: "{{ . }}",ck: "{{ . }}",autoTrack:true})</script>
{{- end }}
6 changes: 3 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
{{- partial "head/twitter.html" . }}
{{- partial "head/googleplus.html" . }}
{{- partial "head/facebook.html" . }}
{{ partial "head/verify.html" . }}
{{- partial "head/style.html" . }}
{{- partial "head/analytics.html" . }}
{{- partial "head/verify.html" . }}
{{- partialCached "head/style.html" . }}
{{- partialCached "head/analytics.html" . }}
6 changes: 5 additions & 1 deletion layouts/partials/head/analytics.html
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{{- partial "_thirdparty/analytics/51la.html" . }}
{{- with .Site.Params.analytics }}
{{- if isset . "laid" }}
{{ partial "_thirdparty/analytics/51la.html" .laId }}
{{- end }}
{{- end }}
18 changes: 13 additions & 5 deletions layouts/partials/head/meta.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
{{- if .Site.Params.darkmode }}
<meta name="theme-color" content="{{ .Site.Params.themeColor.dark }}" media="(prefers-color-scheme: dark)" />
{{- else }}
<meta name="theme-color" content="{{ .Site.Params.themeColor.light }}" media="(prefers-color-scheme: light)" />
{{- end }}
{{ hugo.Generator }}
<link rel="shortcut icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon.small }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ .Site.Params.favicon.medium }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ .Site.Params.favicon.appleTouchIcon }}">
<meta itemprop="name" content="{{ .Title }}" />
<meta itemprop="description" content="{{ .Description | default .Site.Params.description }}" />
{{- if .IsPage }}
Expand All @@ -15,8 +28,3 @@
{{- .Scratch.Set "metaImg" $img }}
<meta itemprop="image" content="{{ $img | absURL }}" />
<meta itemprop="keywords" content="{{ if and .IsPage (isset .Params "tags")}}{{ delimit .Params.tags "," }}{{ else }}{{ .Site.Params.keywords }}{{ end }}" />
{{- if .Site.Params.darkmode }}
<meta name="theme-color" content="{{ .Site.Params.themeColor.dark }}" media="(prefers-color-scheme: dark)" />
{{- else }}
<meta name="theme-color" content="{{ .Site.Params.themeColor.light }}" media="(prefers-color-scheme: light)" />
{{- end }}
3 changes: 3 additions & 0 deletions layouts/partials/head/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
{{- $scss := resources.Get "css/main.scss" }}
{{- $scss = $scss | resources.ExecuteAsTemplate "main.scss" . }}
{{- $css := $scss | toCSS (dict "targetPath" "/css/main.css" "outputStyle" "expanded") }}
{{- if hugo.IsProduction }}
{{- $css = $css | minify | fingerprint }}
{{- end }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
{{- if .IsPage }}
<style type="text/css">
Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/init.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* Use to defind global variables */}}

{{- if not hugo.IsExtended }}
{{- warnf "Hugo NexT 主题使用了 SCSS 框架,请到官方地址下载 Hugo Extended 版本:https://github.com/gohugoio/hugo/releases" -}}
{{- errorf "Because that use SCSS framework in Hugo NexT, Please download Hugo extended version on offical site: https://github.com/gohugoio/hugo/releases" -}}
{{- end }}

{{- .Scratch.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) -}}
{{- .Scratch.Set "catsCount" (len .Site.Taxonomies.categories) -}}
{{- .Scratch.Set "tagsCount" (len .Site.Taxonomies.tags) -}}
{{- $vendors := .Site.Data.resources.vendors -}}
{{- $pluginVen := .Site.Params.vendors.plugins -}}
{{- $pluginCDN := index $vendors $pluginVen -}}
{{- .Scratch.Set "pluginCDN" $pluginCDN -}}
3 changes: 3 additions & 0 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@
{{- $nextjs = $nextjs | append $pjaxjs }}
{{- end }}
{{- $nextjs = $nextjs | resources.Concat "js/hugo-next.js"}}
{{ if hugo.IsProduction }}
{{- $nextjs = $nextjs | minify | fingerprint }}
{{ end }}
<script type="text/javascript" src="{{ $nextjs.RelPermalink }}" defer></script>
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ homepage = "https://github.com/hugo-next/hugo-theme-next"
tags = ["blog", "simple", "dark", "personal", "fast", "theme"]
features = ["some", "awesome", "features"]
min_version = "0.86.0"
demosite = "https://lisenhui.cn"
demosite = "https://preview.hugo-next.eu.org"

[author]
name = "lisenhui"
Expand Down

0 comments on commit a2f2966

Please sign in to comment.