diff options
author | Y4er <45418382@qq.com> | 2019-10-08 18:30:16 +0300 |
---|---|---|
committer | Y4er <45418382@qq.com> | 2019-10-08 18:30:16 +0300 |
commit | 99638c226200fffd98a89b9d51c36cd3fefd34a6 (patch) | |
tree | cc43fa913463b0f7a386b5239402356aa54605a2 | |
parent | ab362c446853420d5913173580bf6b65793bf0c6 (diff) |
fix category list && add shortcode
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | README.MD | 25 | ||||
-rw-r--r-- | README_EN.MD | 42 | ||||
-rw-r--r-- | exampleSite/config.toml | 48 | ||||
-rw-r--r-- | images/screenshot.png | bin | 0 -> 51502 bytes | |||
-rw-r--r-- | images/tn.png | bin | 0 -> 31629 bytes | |||
-rw-r--r-- | layouts/404.html | 10 | ||||
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | layouts/_default/list.html | 13 | ||||
-rw-r--r-- | layouts/_default/single.html | 2 | ||||
-rw-r--r-- | layouts/index.html | 5 | ||||
-rw-r--r-- | layouts/partials/footer.html | 2 | ||||
-rw-r--r-- | layouts/partials/head.html | 4 | ||||
-rw-r--r-- | layouts/partials/header.html | 2 | ||||
-rw-r--r-- | layouts/partials/prevnext.html | 24 | ||||
-rw-r--r-- | layouts/partials/script.html | 2 | ||||
-rw-r--r-- | layouts/shortcodes/music.html | 62 | ||||
-rw-r--r-- | theme.toml | 8 |
19 files changed, 207 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4032ec6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.git/
\ No newline at end of file @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 YOUR_NAME_HERE +Copyright (c) 2019 Y4er Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -1,6 +1,8 @@ # EasyBook -EasyBook是一个移植自[jekyll-theme-EasyBook](https://github.com/laobubu/jekyll-theme-EasyBook)的一个hugo主题。 -# 使用 +EasyBook移植自[jekyll-theme-EasyBook](https://github.com/laobubu/jekyll-theme-EasyBook),简洁但强大。 +[Demo](http://Y4er.com) [English Document](./README_EN.MD) +# 开始 +开始前请参考[官方文档](https://gohugo.io/getting-started/quick-start/) ``` hugo new site myblog cd myblog @@ -9,14 +11,25 @@ cp themes/easybook/exampleSite/config.toml config.toml hugo new post\helloworld.md hugo server ``` + # 功能 - 最近文章 -- 懒加载 +- 图片懒加载 - 灯箱 -- 百度谷歌统计 -- TOC -- utteranc评论 +- 百度推送统计 +- 谷歌统计 +- 自动目录 +- 多个评论系统 - 代码高亮 +- 😁表情 +- 自定义js、css +- shortcode + +# 鸣谢 +本仓库参考多个开源主题,在此鸣谢。 +- [jekyll-theme-EasyBook](https://github.com/laobubu/jekyll-theme-EasyBook) +- [hugo-theme-even](https://github.com/olOwOlo/hugo-theme-even) +开发过程中多次参考[官方主题开发文档](https://gohugo.io/templates/) # LICENSE [The MIT License (MIT)](https://github.com/Y4er/hugo-theme-easybook/blob/master/LICENSE)
\ No newline at end of file diff --git a/README_EN.MD b/README_EN.MD new file mode 100644 index 0000000..0137011 --- /dev/null +++ b/README_EN.MD @@ -0,0 +1,42 @@ +# EasyBook + +EasyBook is ported from [jekyll-theme-EasyBook] (https://github.com/laobubu/jekyll-theme-EasyBook), simple but powerful. +[Demo](http://Y4er.com) [中文README](./README.MD) + +# Start + +Please refer to [Official Document] before starting (https://gohugo.io/getting-started/quick-start/) + +``` +hugo new site myblog +cd myblog +git clone https://github.com/Y4er/hugo-theme-easybook themes/easybook +cp themes/easybook/exampleSite/config.toml config.toml +hugo new post\helloworld.md +hugo server +``` + +# Features + +- Recent articles +- Image lazy loading +- Lightbox +- Baidu push statistics +- Google stats +- Automatic catalog +- Multiple comment systems +- Code highlighting +- 😁 expression +- Custom js, css +- Shortcode + +# THINKS + +This warehouse is based on a number of open source topics, and I would like to thank you. +- [jekyll-theme-EasyBook] (https://github.com/laobubu/jekyll-theme-EasyBook) +- [hugo-theme-even](https://github.com/olOwOlo/hugo-theme-even) +Many references to the [Official Theme Development Document](https://gohugo.io/templates/) during development + +# LICENSE + +[The MIT License (MIT)] (https://github.com/Y4er/hugo-theme-easybook/blob/master/LICENSE)
\ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 0e691ec..46fe9f6 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -7,8 +7,8 @@ pygmentsCodefences = true pygmentsUseClasses = true pygmentsCodefencesGuessSyntax = true -paginate = 8 # 首页每页显示的文章数 -googleAnalytics = "UA-131218098-1" # UA-XXXXXXXX-X +paginate = 8 # 首页每页显示的文章数 +googleAnalytics = "UA-XXXXXXXX-X" # UA-XXXXXXXX-X # 右上角菜单 [[menu.main]] name = "Home" @@ -31,7 +31,7 @@ googleAnalytics = "UA-131218098-1" # UA-XXXXXXXX-X weight = 50 url = "http://www.chabug.org" -# 站点信息 +# site info [params] author = "Y4er" whoami = "哀吾生之须臾,羡长江之无穷." @@ -41,14 +41,42 @@ googleAnalytics = "UA-131218098-1" # UA-XXXXXXXX-X [params.social] GitHub = "http://github.com/Y4er" - Email = "admin@chabug.org" + Email = "mailto:admin@chabug.org" [params.utterances] # https://utteranc.es/ - owner = "Y4er" # Your GitHub ID - repo = "Y4er.com" # The repo to store comments - baiduPush = true # baidu push # 百度 - baiduAnalytics = "150ef5faf0461b9f83612d60d72b86b1" # Baidu Analytics - baiduVerification = "PsCl6huhUk" # Baidu Verification - googleVerification = "gPHyyln9EbiXF7wv-nBpX50vJcwJbi1KKbUyFOxuVkA" # Google Verification # 谷歌 + owner = "Y4er" # Your GitHub ID + repo = "Y4er.com" # The repo to store comments + [params.gitment] # Gitment is a comment system based on GitHub issues. see https://github.com/imsun/gitment + owner = "" # Your GitHub ID + repo = "" # The repo to store comments + clientId = "" # Your client ID + clientSecret = "" # Your client secret + [params.gitalk] # Gitalk is a comment system based on GitHub issues. see https://github.com/gitalk/gitalk + owner = "" # Your GitHub ID + repo = "" # The repo to store comments + clientId = "" # Your client ID + clientSecret = "" # Your client secret + # Valine. + # You can get your appid and appkey from https://leancloud.cn + # more info please open https://valine.js.org + [params.valine] + enable = false + appId = 'appId' + appKey = 'appKey' + notify = false # mail notifier , https://github.com/xCss/Valine/wiki + verify = false # Verification code + avatar = 'mm' + placeholder = '说点什么吧...' + visitor = false + + changyanAppid = "" # Changyan app id # 畅言 + changyanAppkey = "" # Changyan app key + + livereUID = "" # LiveRe UID # 来必力 + + baiduPush = true # baidu push # 百度 + baiduAnalytics = "" # Baidu Analytics + baiduVerification = "" # Baidu Verification + googleVerification = "" # Google Verification # 谷歌 # Link custom CSS and JS assets # (relative to /static/css and /static/js respectively) diff --git a/images/screenshot.png b/images/screenshot.png Binary files differnew file mode 100644 index 0000000..d28c4cf --- /dev/null +++ b/images/screenshot.png diff --git a/images/tn.png b/images/tn.png Binary files differnew file mode 100644 index 0000000..634a355 --- /dev/null +++ b/images/tn.png diff --git a/layouts/404.html b/layouts/404.html index 2f76a33..0720ffd 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,5 +1,13 @@ {{- define "title" }}404 page not found - {{ .Site.Title }}{{ end -}} {{- define "content" -}} -404 +<div class="post"> + <!-- post --> + <header class="post-header"> + <h1 class="post-title">Page Not Found</h1> + </header> + <article class="post-content"> + <p>Seems disappeared :(</p> + </article> +</div> {{- end -}} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 603ca39..0380c8b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -8,11 +8,9 @@ <body> <div class="header-placeholder"></div> {{/* header */}} - {{ if not .Params.hideHeaderAndFooter -}} <header class="header"> {{ partial "header.html" . }} </header> - {{- end }} {{/* body */}} <div class="page-content"> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 5370520..053d60b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,13 +1,20 @@ {{- define "content" }} <div class="home"> <h1 class="page-heading">Category</h1> + <div class="tags"> + <ol> + {{ range $key,$value := .Site.Taxonomies.categories }} + <a href="#{{upper $key}}">{{ upper $key }}[{{ len $value }}]</a> + {{ end }} + </ol> + </div> <ul class="post-list"> - {{/* range $key,$value := .Site.Taxonomies.tags */}} + {{/* {{ range $key,$value := .Site.Taxonomies.tags }} */}} {{ range $key,$value := .Site.Taxonomies.categories }} - <h2 class="category" id="{{ $key }}">{{ $key }}</h2> + <h2 class="category" id="{{ upper $key }}">{{ upper $key }}</h2> <ul> {{ range $value }} - <li><span>{{.Date.Format "Jan 2, 2006"}}</span> » <a href="{{ .Permalink }}">{{ title .Title}}</a></li> + <li><span>{{ .Date.Format "Jan 02" }}</span> » <a href="{{ .Permalink }}">{{ title .Title }}</a></li> {{ end }} </ul> {{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 9d28259..aa90b0d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -3,7 +3,7 @@ <!-- post --> <header class="post-header"> <h1 class="post-title">{{ title .Title}}</h1> - <p class="post-meta">{{.Date.Format "Jan 2, 2006"}}</p> + <p class="post-meta">{{ .Date.Format "Jan 02, 2006" }}</p> </header> <article class="post-content"> {{ $reAltIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" />" }} diff --git a/layouts/index.html b/layouts/index.html index 7606dcd..cc19c44 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,6 +1,7 @@ {{- define "content" -}} <div class="home"> - <a class="rss-link" href="/sitemap.xml">SITEMAP</a> + <a class="rss-link" href="{{ "index.xml" | absURL }}">RSS</a> + <a class="rss-link" href="{{ "sitemap.xml" | absURL }}">SITEMAP</a> <h1 class="page-heading">Articles</h1> {{/* content */}} <ul class="post-list"> @@ -9,7 +10,7 @@ {{ range $paginator.Pages }} <li> <h2><a href="{{ .Permalink }}">{{ title .Title | safeHTML }}</a></h2> - <div class="post-meta">{{ .Date.Format "Jan 2, 2006" }}</div> + <div class="post-meta">{{ .Date.Format "Jan 02, 2006" }}</div> <div class="post-excerpt"> {{ .Summary | safeHTML }} </div> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index d99fc77..02000db 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,3 +1,3 @@ <div class="wrapper"> - © {{.Date.Format "2006"}} <a href="/">{{ .Site.Params.author }}</a> + © {{ .Date.Format "2006" }} <a href="{{ "" | absURL }}">{{ .Site.Params.author }}</a> </div>
\ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index c79f1e0..5bb6830 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -24,7 +24,7 @@ {{- if .Keywords -}} {{ $length := len .Keywords | add -1 -}} <meta name="keywords" - content="{{ range $index, $element := .Keywords }}{{ $element | safeHTML }}{{if ne $index $length }}, {{ end }}{{ end }}" /> + content="{{ range $index, $element := .Keywords }}{{ $element | safeHTML }}{{ if ne $index $length }}, {{ end }}{{ end }}" /> {{- else if .Site.Params.keywords -}} {{ $length := len .Site.Params.keywords | add -1 -}} <meta name="keywords" @@ -32,7 +32,7 @@ {{- end }} {{/* theme css */}} -<link rel="stylesheet" href="/css/main.css"> +<link rel="stylesheet" href="{{ "css/main.css" | absURL }}"> <!-- lightgallery css --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.12/src/css/lightgallery.css"> diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 8818f6b..bfc2944 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,7 +1,7 @@ <div class="wrapper"> <div id="sidebar-toggle">TOC</div> {{/* 首页左上角作者名 */}} - <a class="site-title" href="/">{{ .Site.Params.author }}</a> + <a class="site-title" href="{{ "" | absURL }}">{{ .Site.Params.author }}</a> {{/* 右上角导航 */}} <nav class="site-nav"> {{ range .Site.Menus.main -}} diff --git a/layouts/partials/prevnext.html b/layouts/partials/prevnext.html index 9a1faee..adeca21 100644 --- a/layouts/partials/prevnext.html +++ b/layouts/partials/prevnext.html @@ -1,21 +1,21 @@ -{{$prev := .PrevInSection}} -{{$next := .NextInSection}} +{{ $prev := .PrevInSection }} +{{ $next := .NextInSection }} -{{if or $prev $next}} +{{ if or $prev $next }} <ul class="prevnext"> - {{if $prev}} + {{ if $prev }} <li>上一篇: - <a href="{{$prev.Permalink}}"> - {{title $prev.Title}} + <a href="{{ $prev.Permalink }}"> + {{ title $prev.Title }} </a> </li> - {{end}} - {{if $next}} + {{ end }} + {{ if $next }} <li>下一篇: - <a href="{{$next.Permalink}}"> - {{title $next.Title}} + <a href="{{ $next.Permalink }}"> + {{ title $next.Title }} </a> </li> - {{end}} + {{ end }} </ul> -{{end}}
\ No newline at end of file +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/script.html b/layouts/partials/script.html index ba0b08b..998372e 100644 --- a/layouts/partials/script.html +++ b/layouts/partials/script.html @@ -47,5 +47,5 @@ <!-- custom js --> {{ range .Site.Params.customJS -}} -<script src="{{ "/js/" | relURL }}{{ . }}"></script> +<script src="{{ "js/" | relURL }}{{ . }}"></script> {{ end }}
\ No newline at end of file diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html new file mode 100644 index 0000000..4591cc1 --- /dev/null +++ b/layouts/shortcodes/music.html @@ -0,0 +1,62 @@ + + {{/* + ## Music 163 + + ### Params: + + - `id` + + required param + you can extract from music url + url format "http://music.163.com/#/song?id=3950552" + + - Fiddle `auto` + + optional param + default value 0 + you can overwrite it with 1 + + ### Examples: + + - Simple + + {{% music "3950552" %}} + {{% music "3950552" "1" %}} + + - Named Params + + {{% music id="3950552" %}} + {{% music id="3950552" auto="1" %}} + + */}} + + {{- /* DEFAULTS */ -}} + {{ $auto := "0" }} + + {{- if .IsNamedParams -}} + + <iframe style="max-width: 100%" + class="music163" + frameborder="no" + border="0" + marginwidth="0" + marginheight="0" + width="330" + height="86" + src="//music.163.com/outchain/player?type=2&id={{ .Get "id" }}&auto={{ or (.Get "auto") $auto }}&height=66"> + </iframe> + + {{- else -}} + + <iframe style="max-width: 100%" + class="music163" + frameborder="no" + border="0" + marginwidth="0" + marginheight="0" + width="330" + height="86" + src="//music.163.com/outchain/player?type=2&id={{ .Get 0 }}&auto={{ if isset .Params 1 }}{{ .Get 1 }}{{ else }}{{ $auto }}{{ end }}&height=66"> + </iframe> + + {{- end -}}
\ No newline at end of file @@ -8,7 +8,7 @@ description = "Easybook is a simple hugo theme." homepage = "http://Y4er.com/" tags = ['hugo','simple'] features = ['simple'] -min_version = "0.41" +min_version = "0.52" [author] name = "Y4er" @@ -16,6 +16,6 @@ min_version = "0.41" # If porting an existing theme [original] - name = "" - homepage = "" - repo = "" + name = "jekyll-theme-EasyBook" + homepage = "http://laobubu.net/jekyll-theme-EasyBook/" + repo = "https://github.com/laobubu/jekyll-theme-EasyBook" |