Support twitter card

feature/cover-image
nodejh 7 years ago
parent b9a199180f
commit 8b2647b4f3

@ -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`.

@ -1,5 +1,7 @@
# Hogu Theme Cactus Plus # 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). Cactus Plus is a minimalistic theme for bloggers based on the theme named [Cactus](https://github.com/digitalcraftsman/hugo-cactus-theme).
**Features** **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** + **[Disqus](https://disqus.com/) comment-system**
+ **Both Google Analytics and Baidu Analytics for site analytics.** + **Both Google Analytics and Baidu Analytics for site analytics.**
+ **Table of Content** + **Table of Content**
+ **Twitter Card**
Here's the link to online demo: [http://nodejh.com](http://nodejh.com). 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)
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 --> <!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

@ -1,5 +1,7 @@
# Hugo Theme Cactus Plus # 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) 更改的一个简约主题。 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/) 评论系统** + **集成了 [Disqus](https://disqus.com/) 评论系统**
+ **提供了 Google Analytics 和百度统计** + **提供了 Google Analytics 和百度统计**
+ **文章目录** + **文章目录**
+ **Twitter Card**
示例网站: [http://nodejh.com](http://nodejh.com)。 示例网站: [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)
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 --> <!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

@ -1,39 +1,40 @@
# Site settings # Site settings
baseurl = "http://nodejh.com/" baseurl = "your_site_url_address"
languageCode = "zh-cn" languageCode = "en"
title = "nodejh" title = "site title"
theme = "hugo-theme-cactus-plus" theme = "hugo-theme-cactus-plus"
# Enter your tracking code to enable Google Analytics googleAnalytics = "your_google_analytics_id"
googleAnalytics = "UA-84989670-1" # Set the value to true if your site include CJK (Chinese, Japanese, and Korean languages) characters
hasCJKLanguage = true hasCJKLanguage = false
[params] [params]
name = "nodejh" author = "site_author"
description = "My Blog" description = "Site Description"
bio = "Web Developer" bio = "author biography"
enableRSS = true twitter = "your_twitter_id"
facebook = "your_facebook_id"
# Table of content enableRSS = true
enableToc = true enableToc = true
# Disqus comment
disqusShortname = "nodejh"
# Enable disqus comment, true|false
enableDisqus = true enableDisqus = true
disqusShortname = "your_disqus_short_name"
# Enable summary, true|false
enableSummary = true 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 useDescriptionReplaceSummary = false
# Enable Google Analytics
enableGoogleAnalytics = true 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 enableTwitterCard = true
enableBaiduAnalytics = true # The url for twitter card image, default is avatar.png in static/images directory
# Baidu Analytics Code twitterCardImage = ""
baiduAnalytics = '39843ea392201290bd6f76173d2e1633'
# Add custom assets with their paths relative to the static folder # Add custom assets with their paths relative to the static folder
customCSS = [] customCSS = []
@ -43,36 +44,23 @@ hasCJKLanguage = true
# translate or customize each string of the theme. # translate or customize each string of the theme.
# Navigation links # Navigation links
# Home text, default: 'Home'
home = "" home = ""
# About text, default: 'About'
about = "" about = ""
# Archive text, default: 'Archive'
archive = "" archive = ""
# Subscribe button Text, default: 'Subscribe'
subscribe = "" subscribe = ""
# Pagination links
# default: 'Older Posts'
olderPosts = "" olderPosts = ""
# default: 'Newer Posts'
newerPosts = "" newerPosts = ""
copyright = ""
# show latest posts in single page, true|false # show latest posts in single page
showLatestPosts = false showLatestPosts = false
# Latest posts title, default: 'Read More'
readMore = "" readMore = ""
# default similar to: © Copyright 2017 ❤️ nodejh # Share
# nodejh is site name specified in params.name enableShare = true
copyright = ""
# Enable Share Button at bottom of post, true|false
enableShare = false
# Enter optionally your twitter account
twitterAccount = ""
tweet = "" tweet = ""
facebook = "" share = ""
# 404 page # 404 page
title404 = "" title404 = ""
@ -83,6 +71,7 @@ hasCJKLanguage = true
# The social icons can be styled differently if you use mono as font - circle, rounded, or empty # The social icons can be styled differently if you use mono as font - circle, rounded, or empty
socialIconStyle = "" socialIconStyle = ""
# Add additional social link entries underneath # Add additional social link entries underneath
[social] [social]
facebook-square = "https://www.facebook.com/nodejh" facebook-square = "https://www.facebook.com/nodejh"

@ -1,4 +1,4 @@
{{ partial "head.html" . }} {{ partial "head.html" . }}
<body> <body>
{{ partial "nav.html" . }} {{ partial "nav.html" . }}
{{ partial "profile.html" . }} {{ partial "profile.html" . }}

@ -1,4 +1,4 @@
{{ partial "head.html" . }} {{ partial "head.html" . }}
<body> <body>
{{ partial "nav.html" . }} {{ partial "nav.html" . }}

@ -6,7 +6,7 @@
{{ with .Site.Params.copyright }} {{ with .Site.Params.copyright }}
{{ . | markdownify }} {{ . | markdownify }}
{{ else }} {{ else }}
© Copyright {{ now.Format "2006"}} <i class="fa fa-heart" aria-hidden="true"></i> {{ .Site.Params.name }} © Copyright {{ now.Format "2006"}} <i class="fa fa-heart" aria-hidden="true"></i> {{ .Site.Params.Author }}
{{ end }} {{ end }}
</p> </p>
<p class="small"> <p class="small">

@ -4,16 +4,16 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{{ with .Site.Params.name }}<meta name="author" content="{{ . }}">{{ end }} {{ if .Site.Params.enableTwitterCard }}
{{ partial "twitter-cards.html" . }}
{{ end }}
{{ with .Site.Params.author }}<meta name="author" content="{{ . }}">{{ end }}
{{ with .Site.Params.description }}<meta name="description" content="{{ . }}">{{ end }} {{ with .Site.Params.description }}<meta name="description" content="{{ . }}">{{ end }}
{{ .Hugo.Generator }} {{ .Hugo.Generator }}
<title>{{ if .IsHome }}{{ .Title }}{{ else }}{{ .Title }} &middot; {{ .Site.Title }}{{ end }}</title> <title>{{ if .IsHome }}{{ .Title }}{{ else }}{{ .Title }} &middot; {{ .Site.Title }}{{ end }}</title>
<link rel="shortcut icon" href="{{ .Site.BaseURL }}images/favicon.ico"> <link rel="shortcut icon" href="{{ .Site.BaseURL }}images/favicon.ico">
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css"> <link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css">
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/highlight.css"> <link rel="stylesheet" href="{{ .Site.BaseURL }}css/highlight.css">
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ $.Site.BaseURL }}{{ . }}">
{{ end }}
{{ if eq .Site.Params.iconFont "font-awesome" }} {{ if eq .Site.Params.iconFont "font-awesome" }}
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/font-awesome.min.css"> <link rel="stylesheet" href="{{ .Site.BaseURL }}css/font-awesome.min.css">
@ -24,4 +24,8 @@
{{ if .Site.Params.enableRSS }} {{ if .Site.Params.enableRSS }}
<link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" /> <link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ end }} {{ end }}
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ $.Site.BaseURL }}{{ . }}">
{{ end }}
</head> </head>

@ -1,11 +1,11 @@
<ul id="post-list" class="archive readmore"> <ul id="post-list" class="archive readmore">
<h3>{{ with .Site.Params.readMore }}{{ . }}{{ else }}Read more{{ end }}</h3> <h3>{{ .Site.Params.readMore | default "Read more" }}</h3>
{{ range first 10 (where .Site.Pages "Params.hidden" "ne" "true") }}
{{ $url := replace .Permalink .Site.BaseURL "" }} {{ $kind := where .Site.RegularPages "Section" "!=" "" }}
{{ if and (ne $url "about/") }} {{ $othr := where $kind "URL" "!=" .URL }}
{{ range first 10 $othr }}
<li> <li>
<a href="{{ .Permalink }}">{{ .Title }}<aside class="dates">{{ .Date.Format "Jan 2" }}</aside></a> <a href="{{ .URL }}">{{ .LinkTitle }}<aside class="dates">{{ .Date.Format "Jan 2 2006" }}</aside></a>
</li> </li>
{{ end }} {{ end }}
{{ end }} </ul>
</ul>

@ -4,7 +4,7 @@
<a href='{{ .Site.BaseURL }}about'> <a href='{{ .Site.BaseURL }}about'>
<img id="avatar" class="2x" src="{{ .Site.BaseURL }}images/avatar.png"/> <img id="avatar" class="2x" src="{{ .Site.BaseURL }}images/avatar.png"/>
</a> </a>
<h1>{{ .Site.Params.name }}</h1> <h1>{{ .Site.Title }}</h1>
{{ with .Site.Params.bio }}<h2>{{ . | markdownify }}</h2>{{ end }} {{ with .Site.Params.bio }}<h2>{{ . | markdownify }}</h2>{{ end }}
</header> </header>
</section> </section>

@ -0,0 +1,46 @@
{{ if .IsPage }}
{{ with .Params.images }}
<!-- Twitter summary card with large image must be at least 280x150px -->
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image:src" content="{{ index . 0 | absURL }}"/>
{{ else }}
<meta name="twitter:card" content="summary"/>
{{ if .Site.Params.twitterCardImage }}
<meta name="twitter:image" content="{{ .Site.Params.twitterCardImage | absURL }}" />
{{ else }}
<meta name="twitter:image" content="{{ .Site.BaseURL }}images/avatar.png" />
{{ end }}
{{ end }}
<!-- Twitter Card data -->
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"/>
{{ with .Site.Params.twitter }}
<meta name="twitter:site" content="@{{ . }}"/>
{{ end }}
{{ range .Site.Authors }}
{{ with .twitter }}
<meta name="twitter:creator" content="@{{ . }}"/>
{{ end }}
{{ end }}
<!-- no post authors, show site author -->
{{ if eq (len .Site.Authors) 0 }}
<meta name="twitter:creator" content="@{{ .Site.Params.author }}"/>
{{ end }}
{{ else }}
<meta name="twitter:card" content="summary" />
{{ with .Site.Params.twitter }}
<meta name="twitter:site" content="@{{ . }}"/>
{{ end }}
{{ with .Site.Params.author }}
<meta name="twitter:creator" content="@{{ . }}"/>
{{ end }}
<meta name="twitter:title" content="{{ .Site.Title }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"/>
{{ if .Site.Params.twitterCardImage }}
<meta name="twitter:image" content="{{ .Site.Params.twitterCardImage | absURL }}" />
{{ else }}
<meta name="twitter:image" content="{{ .Site.BaseURL }}images/avatar.png" />
{{ end }}
{{ end }}

@ -12,12 +12,6 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if .Site.Params.enableDuoshuo }}
{{ if ne .Params.disableduoshuo "true" }}
{{ partial "duoshuo.html" . }}
{{ end }}
{{ end }}
{{ partial "footer.html" . }} {{ partial "footer.html" . }}
</section> </section>

@ -696,9 +696,11 @@ h2.month {
} }
#post-list.archive.readmore { #post-list.archive.readmore {
margin-top: 100px; margin-top: 70px;
}
#post-list.archive.readmore li {
margin-bottom: 0px;
} }
#post-list.archive.readmore h3 { #post-list.archive.readmore h3 {
font: 400 20px "Helvetica Neue", Helvetica, Arial, sans-serif; font: 400 20px "Helvetica Neue", Helvetica, Arial, sans-serif;
margin-bottom: 30px; margin-bottom: 30px;

@ -2,10 +2,10 @@ name = "Cactus Plus"
license = "MIT" license = "MIT"
licenselink = "https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/LICENSE.md" licenselink = "https://github.com/nodejh/hugo-theme-cactus-plus/blob/master/LICENSE.md"
description = "A minimalistic and responsive theme for bloggers." 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"] tags = ["blog", "beautiful", "disqus", "rss", "syntax highlighting", "tags"]
features = ["blog", "beautiful", "disqus", "rss", "syntax highlighting", "tags"] features = ["blog", "beautiful", "disqus", "rss", "syntax highlighting", "tags"]
min_version = 0.18 min_version = 0.20
[author] [author]
name = "nodejh" name = "nodejh"

Loading…
Cancel
Save