From 8b2647b4f3e67ef2afa5106db9a6cd9fc4857f61 Mon Sep 17 00:00:00 2001
From: nodejh
Date: Thu, 7 Dec 2017 17:59:08 +0800
Subject: [PATCH] Support twitter card
---
CHANGELOG | 5 +++
README.md | 4 +-
README_zh-cn.md | 5 ++-
exampleSite/config.toml | 67 ++++++++++++-----------------
layouts/_default/list.html | 2 +-
layouts/_default/single.html | 2 +-
layouts/partials/footer.html | 2 +-
layouts/partials/head.html | 12 ++++--
layouts/partials/latest-posts.html | 16 +++----
layouts/partials/profile.html | 2 +-
layouts/partials/twitter-cards.html | 46 ++++++++++++++++++++
layouts/section/about.html | 6 ---
static/css/style.css | 6 ++-
theme.toml | 4 +-
14 files changed, 112 insertions(+), 67 deletions(-)
create mode 100644 CHANGELOG
create mode 100644 layouts/partials/twitter-cards.html
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..c962b4c
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,5 @@
+## 2017.12.09 Version 1.0
+
+- [x] Support twitter card.
+- [x] Remove name in `.Site.Params`. It's duplicate with `.Site.title`.
+- [x] Add `author` in `.Site.Params`.
diff --git a/README.md b/README.md
index 5bdfa63..e7d268b 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# Hogu Theme Cactus Plus
+[English Document](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
+
Cactus Plus is a minimalistic theme for bloggers based on the theme named [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme).
**Features**
@@ -10,10 +12,10 @@ Cactus Plus is a minimalistic theme for bloggers based on the theme named [Cactu
+ **[Disqus](https://disqus.com/) comment-system**
+ **Both Google Analytics and Baidu Analytics for site analytics.**
+ **Table of Content**
++ **Twitter Card**
Here's the link to online demo: [http://nodejh.com](http://nodejh.com).
-[English Document](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
diff --git a/README_zh-cn.md b/README_zh-cn.md
index b6f4dd8..17c982a 100644
--- a/README_zh-cn.md
+++ b/README_zh-cn.md
@@ -1,5 +1,7 @@
# Hugo Theme Cactus Plus
+[English Document](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
+
Cactus Plus 是在 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme) 更改的一个简约主题。
**特点**
@@ -10,10 +12,11 @@ Cactus Plus 是在 [Cactus](https://github.com/digitalcraftsman/hugo-cactus-them
+ **集成了 [Disqus](https://disqus.com/) 评论系统**
+ **提供了 Google Analytics 和百度统计**
+ **文章目录**
++ **Twitter Card**
示例网站: [http://nodejh.com](http://nodejh.com)。
-[English Document](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README.md) | [中文文档](https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/README_zh-cn.md)
+
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 0c66b4e..72a08c4 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -1,39 +1,40 @@
# Site settings
-baseurl = "http://nodejh.com/"
-languageCode = "zh-cn"
-title = "nodejh"
+baseurl = "your_site_url_address"
+languageCode = "en"
+title = "site title"
theme = "hugo-theme-cactus-plus"
-# Enter your tracking code to enable Google Analytics
-googleAnalytics = "UA-84989670-1"
-hasCJKLanguage = true
+googleAnalytics = "your_google_analytics_id"
+# Set the value to true if your site include CJK (Chinese, Japanese, and Korean languages) characters
+hasCJKLanguage = false
[params]
- name = "nodejh"
- description = "My Blog"
- bio = "Web Developer"
+ author = "site_author"
+ description = "Site Description"
+ bio = "author biography"
- enableRSS = true
+ twitter = "your_twitter_id"
+ facebook = "your_facebook_id"
- # Table of content
+ enableRSS = true
enableToc = true
- # Disqus comment
- disqusShortname = "nodejh"
- # Enable disqus comment, true|false
enableDisqus = true
+ disqusShortname = "your_disqus_short_name"
+
- # Enable summary, true|false
enableSummary = true
- # Use posts' front matter description replace summary, true|false
+ # Set the value to true if use description in post front matter replace content summary
useDescriptionReplaceSummary = false
- # Enable Google Analytics
+
enableGoogleAnalytics = true
+ enableBaiduAnalytics = false
+ # Set the value to your baidu analysis code if you want to use baidu analytics
+ baiduAnalytics = 'your_baidu_analysis_code'
- # Enable Baidu Analytics
- enableBaiduAnalytics = true
- # Baidu Analytics Code
- baiduAnalytics = '39843ea392201290bd6f76173d2e1633'
+ enableTwitterCard = true
+ # The url for twitter card image, default is avatar.png in static/images directory
+ twitterCardImage = ""
# Add custom assets with their paths relative to the static folder
customCSS = []
@@ -43,36 +44,23 @@ hasCJKLanguage = true
# translate or customize each string of the theme.
# Navigation links
- # Home text, default: 'Home'
home = ""
- # About text, default: 'About'
about = ""
- # Archive text, default: 'Archive'
archive = ""
- # Subscribe button Text, default: 'Subscribe'
subscribe = ""
- # Pagination links
- # default: 'Older Posts'
olderPosts = ""
- # default: 'Newer Posts'
newerPosts = ""
+ copyright = ""
- # show latest posts in single page, true|false
+ # show latest posts in single page
showLatestPosts = false
- # Latest posts title, default: 'Read More'
readMore = ""
- # default similar to: © Copyright 2017 ❤️ nodejh
- # nodejh is site name specified in params.name
- copyright = ""
-
- # Enable Share Button at bottom of post, true|false
- enableShare = false
- # Enter optionally your twitter account
- twitterAccount = ""
+ # Share
+ enableShare = true
tweet = ""
- facebook = ""
+ share = ""
# 404 page
title404 = ""
@@ -83,6 +71,7 @@ hasCJKLanguage = true
# The social icons can be styled differently if you use mono as font - circle, rounded, or empty
socialIconStyle = ""
+
# Add additional social link entries underneath
[social]
facebook-square = "https://www.facebook.com/nodejh"
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 1dbd8c2..29b95c9 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -1,4 +1,4 @@
- {{ partial "head.html" . }}
+{{ partial "head.html" . }}
{{ partial "nav.html" . }}
{{ partial "profile.html" . }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index ff10768..0bd5424 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -1,4 +1,4 @@
- {{ partial "head.html" . }}
+{{ partial "head.html" . }}
{{ partial "nav.html" . }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index c6826f0..8c8a7c4 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -6,7 +6,7 @@
{{ with .Site.Params.copyright }}
{{ . | markdownify }}
{{ else }}
- © Copyright {{ now.Format "2006"}} {{ .Site.Params.name }}
+ © Copyright {{ now.Format "2006"}} {{ .Site.Params.Author }}
{{ end }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index b701eb3..74e5e49 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -4,16 +4,16 @@
- {{ with .Site.Params.name }} {{ end }}
+ {{ if .Site.Params.enableTwitterCard }}
+ {{ partial "twitter-cards.html" . }}
+ {{ end }}
+ {{ with .Site.Params.author }} {{ end }}
{{ with .Site.Params.description }} {{ end }}
{{ .Hugo.Generator }}
{{ if .IsHome }}{{ .Title }}{{ else }}{{ .Title }} · {{ .Site.Title }}{{ end }}
- {{ range .Site.Params.customCSS }}
-
- {{ end }}
{{ if eq .Site.Params.iconFont "font-awesome" }}
@@ -24,4 +24,8 @@
{{ if .Site.Params.enableRSS }}
{{ end }}
+
+ {{ range .Site.Params.customCSS }}
+
+ {{ end }}
diff --git a/layouts/partials/latest-posts.html b/layouts/partials/latest-posts.html
index 64b49e9..344518f 100644
--- a/layouts/partials/latest-posts.html
+++ b/layouts/partials/latest-posts.html
@@ -1,11 +1,11 @@
- {{ with .Site.Params.readMore }}{{ . }}{{ else }}Read more{{ end }}
- {{ range first 10 (where .Site.Pages "Params.hidden" "ne" "true") }}
- {{ $url := replace .Permalink .Site.BaseURL "" }}
- {{ if and (ne $url "about/") }}
+ {{ .Site.Params.readMore | default "Read more" }}
+
+ {{ $kind := where .Site.RegularPages "Section" "!=" "" }}
+ {{ $othr := where $kind "URL" "!=" .URL }}
+ {{ range first 10 $othr }}
- {{ .Title }}{{ .Date.Format "Jan 2" }}
+ {{ .LinkTitle }}{{ .Date.Format "Jan 2 2006" }}
- {{ end }}
- {{ end }}
-
\ No newline at end of file
+ {{ end }}
+
diff --git a/layouts/partials/profile.html b/layouts/partials/profile.html
index 2ab115c..3d69c71 100644
--- a/layouts/partials/profile.html
+++ b/layouts/partials/profile.html
@@ -4,7 +4,7 @@
- {{ .Site.Params.name }}
+ {{ .Site.Title }}
{{ with .Site.Params.bio }}{{ . | markdownify }} {{ end }}
diff --git a/layouts/partials/twitter-cards.html b/layouts/partials/twitter-cards.html
new file mode 100644
index 0000000..1e9c078
--- /dev/null
+++ b/layouts/partials/twitter-cards.html
@@ -0,0 +1,46 @@
+{{ if .IsPage }}
+ {{ with .Params.images }}
+
+
+
+ {{ else }}
+
+ {{ if .Site.Params.twitterCardImage }}
+
+ {{ else }}
+
+ {{ end }}
+ {{ end }}
+
+
+
+ {{ with .Site.Params.twitter }}
+
+ {{ end }}
+ {{ range .Site.Authors }}
+ {{ with .twitter }}
+
+ {{ end }}
+ {{ end }}
+
+ {{ if eq (len .Site.Authors) 0 }}
+
+ {{ end }}
+
+{{ else }}
+
+
+ {{ with .Site.Params.twitter }}
+
+ {{ end }}
+ {{ with .Site.Params.author }}
+
+ {{ end }}
+
+
+ {{ if .Site.Params.twitterCardImage }}
+
+ {{ else }}
+
+ {{ end }}
+{{ end }}
diff --git a/layouts/section/about.html b/layouts/section/about.html
index b601167..c01cd42 100644
--- a/layouts/section/about.html
+++ b/layouts/section/about.html
@@ -12,12 +12,6 @@
{{ end }}
{{ end }}
- {{ if .Site.Params.enableDuoshuo }}
- {{ if ne .Params.disableduoshuo "true" }}
- {{ partial "duoshuo.html" . }}
- {{ end }}
- {{ end }}
-
{{ partial "footer.html" . }}
diff --git a/static/css/style.css b/static/css/style.css
index b8dd1d6..fb6c9e4 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -696,9 +696,11 @@ h2.month {
}
#post-list.archive.readmore {
- margin-top: 100px;
+ margin-top: 70px;
+}
+#post-list.archive.readmore li {
+ margin-bottom: 0px;
}
-
#post-list.archive.readmore h3 {
font: 400 20px "Helvetica Neue", Helvetica, Arial, sans-serif;
margin-bottom: 30px;
diff --git a/theme.toml b/theme.toml
index 8f35133..90852d6 100644
--- a/theme.toml
+++ b/theme.toml
@@ -2,10 +2,10 @@ name = "Cactus Plus"
license = "MIT"
licenselink = "https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/LICENSE.md"
description = "A minimalistic and responsive theme for bloggers."
-homepage = "https://github.com/nodejh/hugo-theme-simple"
+homepage = "https://github.com/nodejh/hugo-theme-cactus-plus"
tags = ["blog", "beautiful", "disqus", "rss", "syntax highlighting", "tags"]
features = ["blog", "beautiful", "disqus", "rss", "syntax highlighting", "tags"]
-min_version = 0.18
+min_version = 0.20
[author]
name = "nodejh"