Skip to content
Permalink
Browse files

Support twitter card

  • Loading branch information
nodejh committed Dec 7, 2017
1 parent b9a1991 commit 8b2647b4f3e67ef2afa5106db9a6cd9fc4857f61
@@ -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

[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)

<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

@@ -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)



<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
@@ -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"
@@ -1,4 +1,4 @@
{{ partial "head.html" . }}
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}
{{ partial "profile.html" . }}
@@ -1,4 +1,4 @@
{{ partial "head.html" . }}
{{ partial "head.html" . }}
<body>
{{ partial "nav.html" . }}

@@ -6,7 +6,7 @@
{{ with .Site.Params.copyright }}
{{ . | markdownify }}
{{ 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 }}
</p>
<p class="small">
@@ -4,16 +4,16 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=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 }}
{{ .Hugo.Generator }}
<title>{{ if .IsHome }}{{ .Title }}{{ else }}{{ .Title }} &middot; {{ .Site.Title }}{{ end }}</title>
<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/highlight.css">
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ $.Site.BaseURL }}{{ . }}">
{{ end }}

{{ if eq .Site.Params.iconFont "font-awesome" }}
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/font-awesome.min.css">
@@ -24,4 +24,8 @@
{{ if .Site.Params.enableRSS }}
<link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ end }}

{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ $.Site.BaseURL }}{{ . }}">
{{ end }}
</head>
@@ -1,11 +1,11 @@
<ul id="post-list" class="archive readmore">
<h3>{{ with .Site.Params.readMore }}{{ . }}{{ else }}Read more{{ end }}</h3>
{{ range first 10 (where .Site.Pages "Params.hidden" "ne" "true") }}
{{ $url := replace .Permalink .Site.BaseURL "" }}
{{ if and (ne $url "about/") }}
<h3>{{ .Site.Params.readMore | default "Read more" }}</h3>

{{ $kind := where .Site.RegularPages "Section" "!=" "" }}
{{ $othr := where $kind "URL" "!=" .URL }}
{{ range first 10 $othr }}
<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>
{{ end }}
{{ end }}
</ul>
{{ end }}
</ul>
@@ -4,7 +4,7 @@
<a href='{{ .Site.BaseURL }}about'>
<img id="avatar" class="2x" src="{{ .Site.BaseURL }}images/avatar.png"/>
</a>
<h1>{{ .Site.Params.name }}</h1>
<h1>{{ .Site.Title }}</h1>
{{ with .Site.Params.bio }}<h2>{{ . | markdownify }}</h2>{{ end }}
</header>
</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 }}

{{ if .Site.Params.enableDuoshuo }}
{{ if ne .Params.disableduoshuo "true" }}
{{ partial "duoshuo.html" . }}
{{ end }}
{{ end }}

{{ partial "footer.html" . }}
</section>

@@ -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;
@@ -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"

0 comments on commit 8b2647b

Please sign in to comment.
You can’t perform that action at this time.