feat(home): improve default behavior of hiddenFromHomePage

This commit is contained in:
Dillon
2020-02-17 12:44:04 +08:00
parent dd78d80fef
commit a276661f0a
12 changed files with 73 additions and 102 deletions

View File

@@ -1,25 +1,24 @@
--- ---
author: ""
author_link: ""
title: "{{ replace .TranslationBaseName "-" " " | title }}" title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }} date: {{ .Date }}
lastmod: {{ .Date }} lastmod: {{ .Date }}
draft: true draft: true
author: ""
authorLink: ""
description: "" description: ""
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [] tags: []
categories: [] categories: []
hiddenFromHomePage: false
featured_image: "" featuredImage: ""
featured_image_preview: "" featuredImagePreview: ""
comment: true
toc: false toc: false
auto_collapse_toc: true autoCollapseToc: true
math: false math: false
comment: true
--- ---
<!--more--> <!--more-->

View File

@@ -151,6 +151,8 @@ dateFormatToUse = "2006-01-02"
enable = true enable = true
# special amount of posts in each home posts page # special amount of posts in each home posts page
paginate = 6 paginate = 6
# default behavior when you don't set "hiddenFromHomePage" in front matter
defaultHiddenFromHomePage = false
# Social Info in home page # Social Info in home page
[params.social] [params.social]

View File

@@ -1,29 +1,24 @@
--- ---
author: "Hugo Authors"
author_link: "https://gohugo.io/"
title: "Emoji Support" title: "Emoji Support"
date: 2019-10-01T17:55:28+08:00 date: 2019-10-01T17:55:28+08:00
lastmod: 2019-10-01T17:55:28+08:00 lastmod: 2019-10-01T17:55:28+08:00
draft: false draft: false
author: "Hugo Authors"
authorLink: "https://gohugo.io/"
description: "Guide to emoji usage in Hugo" description: "Guide to emoji usage in Hugo"
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [ tags: ["emoji"]
"emoji", categories: ["theme"]
] hiddenFromHomePage: false
categories: [
"theme",
]
featured_image: /images/emoji.jpg featuredImage: /images/emoji.jpg
featured_image_preview: "" featuredImagePreview: ""
comment: true
toc: false toc: false
auto_collapse_toc: true autoCollapseToc: true
math: false math: false
comment: true
--- ---
Emoji can be enabled in a Hugo project in a number of ways. Emoji can be enabled in a Hugo project in a number of ways.

View File

@@ -1,31 +1,24 @@
--- ---
author: "Hugo Authors"
author_link: "https://gohugo.io/"
title: "Markdown Syntax Guide" title: "Markdown Syntax Guide"
date: 2019-12-01T21:57:40+08:00 date: 2019-12-01T21:57:40+08:00
lastmod: 2020-01-01T16:45:40+08:00 lastmod: 2020-01-01T16:45:40+08:00
draft: false draft: false
author: "Hugo Authors"
authorLink: "https://gohugo.io/"
description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements." description: "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [ tags: ["markdown", "css", "html"]
"markdown", categories: ["theme"]
"css", hiddenFromHomePage: false
"html",
]
categories: [
"theme",
]
featured_image: /images/markdown.png featuredImage: /images/markdown.png
featured_image_preview: "" featuredImagePreview: ""
comment: true
toc: true toc: true
auto_collapse_toc: true autoCollapseToc: true
math: true math: true
comment: true
--- ---
This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme. This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.

View File

@@ -1,30 +1,24 @@
--- ---
author: "Hugo Authors"
author_link: "https://gohugo.io/"
title: "Placeholder Text" title: "Placeholder Text"
date: 2019-08-01T18:02:41+08:00 date: 2019-08-01T18:02:41+08:00
lastmod: 2019-08-01T18:02:41+08:00 lastmod: 2019-08-01T18:02:41+08:00
draft: false draft: false
author: "Hugo Authors"
authorLink: "https://gohugo.io/"
description: "Lorem Ipsum Dolor Si Amet" description: "Lorem Ipsum Dolor Si Amet"
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [ tags: ["markdown", "text"]
"markdown", categories: ["theme"]
"text", hiddenFromHomePage: false
]
categories: [
"theme",
]
featured_image: "" featuredImage: ""
featured_image_preview: "" featuredImagePreview: ""
comment: true
toc: false toc: false
auto_collapse_toc: true autoCollapseToc: true
math: false math: false
comment: true
--- ---
Lorem est tota propiore conpellat pectoribus de Lorem est tota propiore conpellat pectoribus de

View File

@@ -1,30 +1,24 @@
--- ---
author: "Hugo Authors"
author_link: "https://gohugo.io/"
title: "Rich Content" title: "Rich Content"
date: 2019-09-01T18:06:32+08:00 date: 2019-09-01T18:06:32+08:00
lastmod: 2019-09-01T18:06:32+08:00 lastmod: 2019-09-01T18:06:32+08:00
draft: false draft: false
author: "Hugo Authors"
authorLink: "https://gohugo.io/"
description: "A brief description of Hugo Shortcodes" description: "A brief description of Hugo Shortcodes"
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [ tags: ["shortcodes", "privacy"]
"shortcodes", categories: ["theme"]
"privacy", hiddenFromHomePage: false
]
categories: [
"theme",
]
featured_image: /images/hugo.png featuredImage: /images/hugo.png
featured_image_preview: "" featuredImagePreview: ""
comment: true
toc: false toc: false
auto_collapse_toc: true autoCollapseToc: true
math: false math: false
comment: true
--- ---
Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugo-s-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds. Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugo-s-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds.

View File

@@ -151,6 +151,8 @@ dateFormatToUse = "2006-01-02"
enable = true enable = true
# 主页每页显示文章数量 # 主页每页显示文章数量
paginate = 6 paginate = 6
# 当你没有在文章前面设置 "hiddenFromHomePage" 时的默认行为
defaultHiddenFromHomePage = false
# 主页的社交信息设置 # 主页的社交信息设置
[params.social] [params.social]

View File

@@ -1,30 +1,24 @@
--- ---
author: ""
author_link: ""
title: "Markdown 基本语法预览" title: "Markdown 基本语法预览"
date: 2019-08-25T16:22:42+08:00 date: 2019-08-25T16:22:42+08:00
lastmod: 2019-08-25T16:22:42+08:00 lastmod: 2019-08-25T16:22:42+08:00
draft: false draft: false
author: ""
authorLink: ""
description: "这是一篇用于预览 Markdown 基本语法的文章。" description: "这是一篇用于预览 Markdown 基本语法的文章。"
show_in_homepage: true
description_as_summary: false
license: "" license: ""
tags: [ tags: ["Hugo", "主题"]
"Hugo", categories: ["预览"]
"主题",
]
categories: [
"预览",
]
featured_image: "" featuredImage: ""
featured_image_preview: "" featuredImagePreview: ""
hiddenFromHomePage: false
comment: true
toc: true toc: true
auto_collapse_toc: true autoCollapseToc: true
math: true math: true
comment: true
--- ---
这是一篇用于预览 :(fab fa-markdown): Markdown 基本语法的文章。 这是一篇用于预览 :(fab fa-markdown): Markdown 基本语法的文章。

View File

@@ -1,8 +1,8 @@
<article class="single summary" itemscope itemtype="http://schema.org/Article"> <article class="single summary" itemscope itemtype="http://schema.org/Article">
{{- /* Featured image */ -}} {{- /* Featured image */ -}}
{{- with .Params.featured_image -}} {{- with .Params.featuredImage -}}
<div class="featured-image-preview"> <div class="featured-image-preview">
{{- $image := $.Params.featured_image_preview | default . -}} {{- $image := $.Params.featuredImagePreview | default . -}}
{{- partial "hook/image" $image -}} {{- partial "hook/image" $image -}}
</div> </div>
{{- end -}} {{- end -}}
@@ -15,8 +15,8 @@
{{- /* Meta */ -}} {{- /* Meta */ -}}
<div class="meta"> <div class="meta">
{{- $author := .Params.author | default .Site.Author.name -}} {{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}} {{- $authorLink := .Params.authorLink | default .Site.Author.link | default .Site.BaseURL -}}
<a class="author" href="{{ $author_link }}" rel="author" target="_blank"> <a class="author" href="{{ $authorLink }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }} <i class="fas fa-user-circle fa-fw"></i>{{ $author }}
</a> </a>
@@ -39,13 +39,7 @@
{{- /* Summary content */ -}} {{- /* Summary content */ -}}
<div class="content"> <div class="content">
{{- if .Params.description_as_summary -}} {{- partial "hook/content.html" .Summary | safeHTML -}}
<p>
{{- .Params.description -}}
</p>
{{- else -}}
{{- partial "hook/content.html" .Summary | safeHTML -}}
{{- end -}}
</div> </div>
{{- /* Footer */ -}} {{- /* Footer */ -}}

View File

@@ -9,7 +9,11 @@
{{- if .Site.Params.home.posts.enable -}} {{- if .Site.Params.home.posts.enable -}}
{{- /* Paginate */ -}} {{- /* Paginate */ -}}
{{- $paginator := where .Site.RegularPages "Type" "posts" -}} {{- $paginator := where .Site.RegularPages "Type" "posts" -}}
{{- $paginator = where $paginator "Params.show_in_homepage" "!=" false -}} {{- if ne .Site.Params.home.posts.mode.defaultHiddenFromHomePage false -}}
{{- $paginator = where $paginator "Params.hiddenfromhomepage" "!=" true -}}
{{- else -}}
{{- $paginator = where $paginator "Params.hiddenfromhomepage" false -}}
{{- end -}}
{{- with .Site.Params.home.posts.paginate -}} {{- with .Site.Params.home.posts.paginate -}}
{{- $paginator = $.Paginate $paginator . -}} {{- $paginator = $.Paginate $paginator . -}}
{{- else -}} {{- else -}}

View File

@@ -64,7 +64,7 @@
{{- /* Share on Weibo */ -}} {{- /* Share on Weibo */ -}}
{{- if .Params.Share.Weibo | default .Site.Params.Share.Weibo | eq true -}} {{- if .Params.Share.Weibo | default .Site.Params.Share.Weibo | eq true -}}
<a href="//service.weibo.com/share/share.php?url={{ .Permalink }}&amp;appkey=&amp;title={{ .Title }}{{ with $.Params.featured_image }}&amp;pic={{ . }}{{- end -}}" target="_blank" title="{{ T "share" }} Weibo"> <a href="//service.weibo.com/share/share.php?url={{ .Permalink }}&amp;appkey=&amp;title={{ .Title }}{{ with $.Params.featuredImage }}&amp;pic={{ . }}{{- end -}}" target="_blank" title="{{ T "share" }} Weibo">
<i class="fab fa-weibo fa-fw"></i> <i class="fab fa-weibo fa-fw"></i>
</a> </a>
{{- end -}} {{- end -}}

View File

@@ -9,8 +9,8 @@
<div class="meta"> <div class="meta">
<div class="meta-line"> <div class="meta-line">
{{- $author := .Params.author | default .Site.Author.name -}} {{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}} {{- $authorLink := .Params.authorLink | default .Site.Author.link | default .Site.BaseURL -}}
<a class="author" href="{{ $author_link }}" rel="author" target="_blank"> <a class="author" href="{{ $authorLink }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }} <i class="fas fa-user-circle fa-fw"></i>{{ $author }}
</a>&nbsp; </a>&nbsp;
{{- with .Params.categories -}} {{- with .Params.categories -}}
@@ -39,7 +39,7 @@
</div> </div>
{{- /* Featured image */ -}} {{- /* Featured image */ -}}
{{- with .Params.featured_image -}} {{- with .Params.featuredImage -}}
<div class="featured-image"> <div class="featured-image">
{{- partial "hook/image" . -}} {{- partial "hook/image" . -}}
</div> </div>
@@ -49,8 +49,8 @@
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}} {{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="post-toc" id="post-toc"> <div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2> <h2 class="post-toc-title">{{ T "toc" }}</h2>
{{- $globalAutoCollapseToc := .Site.Params.auto_collapse_toc | default true }} {{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.auto_collapse_toc false)) }} always-active{{ end }}"> <div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}">
{{- .TableOfContents -}} {{- .TableOfContents -}}
</div> </div>
</div> </div>