Skip to content

Commit

Permalink
feat: unify site config and support suffix in SEO title
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Mar 24, 2023
1 parent d8fcdc9 commit e70fa77
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 68 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ group :jekyll_plugins do
gem 'jekyll-feed'
gem 'jekyll-contentblocks'
gem 'jekyll-sitemap'
gem 'jekyll-seo-tag'
gem 'jekyll-tagging'
gem 'jekyll-tagging-related_posts'
gem 'jekyll_version_plugin'
Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ DEPENDENCIES
jekyll-assets
jekyll-contentblocks
jekyll-feed
jekyll-seo-tag
jekyll-sitemap
jekyll-tagging
jekyll-tagging-related_posts
Expand Down
19 changes: 19 additions & 0 deletions man/cookbook/apis/site-config/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ interface Link {

| 属性名 | 值类型/可选值 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `master` | `object` | - | 站长信息,[详见下方](#master) |
| `meta` | `object` | - | 网站信息,[详见下方](#meta) |
| `brand` | `object` | - | 品牌相关配置,主要控制页头左上角的链接与文本,[详见下方](#brand) |
| `copyright` | `object` | - | 网站版权声明,[详见下方](#copyright) |
| `header` | `object` | - | 页面头部,[详见下方](#header) |
| `footer` | `object` | - | 页面底部,[详见下方](#footer) |
| `social` | `object` | - | 社交相关功能的开关与配置,[详见下方](#social) |
| `seo` | `object` | - | SEO 相关配置,[详见下方](#seo) |
| `statistic` | `object` | - | 数据统计相关配置,[详见下方](#statistic) |

## `master`

| 属性名 | 值类型/可选值 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `name` | `string` | `site.author.name` | 站长名称 |

## `meta`

Expand Down Expand Up @@ -103,3 +112,13 @@ interface Link {
### `comment`

待补充。

## `seo`

| 属性名 | 值类型/可选值 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `suffix` | `boolean` | `true` | 是否在 `<title>` 中将站名作为后缀拼接 |

## `statistic`

待补充。
42 changes: 7 additions & 35 deletions src/jekyll/_assets/stylesheets/ksio/components/_page.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./brand";

$headerHeight: 60px;
$headerBorderWidth: 1px;
$footerHeight: 180px;
Expand All @@ -18,41 +20,7 @@ body {
}

.navbar-brand {
font: {
family: Georgia;
weight: bold;
}
text-shadow: 1px 1px #fff;

&,
a {
color: inherit;
}

a {
&:hover,
&:focus {
text-decoration: none;
}

+ a {
position: relative;
margin-left: 1.4em;
font: {
family: Sans-serif;
weight: normal;
}

&:before {
content: $UN-space;
position: absolute;
top: 7px;
bottom: 7px;
left: -.7em;
border-left: 1px solid currentColor;
}
}
}
@include brand-rules;
}

.navbar-toggle {
Expand Down Expand Up @@ -81,6 +49,10 @@ body {
}
}
}

.dropdown-header {
font-size: 12px;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/jekyll/_config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
title: Lime
description: 一个简朴、易读、响应式的网站主题
description: 本主题由欧雷于 2015 年开始设计与开发,并在个人网站「欧雷流」及个人各种开源软件的文档站上使用多年;在设计时以提高阅读体验和保持简洁风格为最高原则,体现个性在其次。适用于博客、个人网站、API 文档站等以内容为主的网站
keywords:
tagline: 一个简朴、易读、响应式的网站主题。

baseurl: /lime

author:
name: Ourai L.
name: 欧雷
email: [email protected]

collections:
Expand Down Expand Up @@ -44,7 +45,6 @@ gems:
- jekyll-feed
- jekyll-contentblocks
- jekyll-sitemap
- jekyll-seo-tag
- jekyll/tagging
- jekyll-tagging-related_posts
- jekyll_version_plugin
Expand Down
2 changes: 1 addition & 1 deletion src/jekyll/_includes/ksio/anti-spider.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
{% assign author = page.author %}
<!-- 爬虫抓取的文章中显示来源 -->
<blockquote class="sr-only">
<p>本文首发于<a href="{{ admin.uri }}">{{ site.title }}</a>,作者是<a href="{{ author.uri | default: admin.uri }}" title="访问{{ author.name | default: admin.name }}的网站">{{ author.name | default: admin.name }}</a>。由于会时不时对文章进行补充、修正或润色,为了保证你所看到的是最新版本,<strong>请阅读<a href="{{ page.url | prepend: site.ourairyu.site.url }}" title="阅读《{{ page.title }}》原文">原文</a></strong></p>
<p>本文首发于<a href="{{ admin.uri }}">{{ site.title }}</a>,作者是<a href="{{ author.uri | default: admin.uri }}" title="访问{{ author.name | default: admin.name }}的网站">{{ author.name | default: admin.name }}</a>。由于会时不时对文章进行补充、修正或润色,为了保证你所看到的是最新版本,<strong>请阅读<a href="{{ page.url | prepend: site.ksio.meta.url }}" title="阅读《{{ page.title }}》原文">原文</a></strong></p>
</blockquote>
13 changes: 8 additions & 5 deletions src/jekyll/_includes/ksio/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
<ul>{% for link in site.ksio.footer.links %}<li>{% include ksio/components/link.html link=link wrap=true utm=utm_params %}</li>{% endfor %}</ul>
</nav>
{% endif %}
<!-- Copyright -->
<div class="Footer-copyright">
<p>{% include ksio/components/copyright.html utm=utm_params %}</p>
{{ site.ksio.copyright.fragments }}
</div>
{% if site.ksio.copyright %}
<!-- Copyright -->
<div class="Footer-copyright">
<p>{% include ksio/components/copyright.html utm=utm_params %}</p>
{% if site.ksio.copyright.provider != false %}<p>本站主题 <a href="https://ourai.github.io/lime/?{{ utm_params }}" target="_blank" rel="external ">Lime</a><a href="https://linxoid.com/ourai/?{{ utm_params }}" target="_blank" rel="external ">欧雷</a> 提供</p>{% endif %}
{{ site.ksio.copyright.fragments }}
</div>
{% endif %}
</div>
</div>
</footer>
2 changes: 1 addition & 1 deletion src/jekyll/_includes/ksio/meta/feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
{% if feed_config %}
<!-- 订阅 -->
{% if feed_config.atom %}{% feed_meta %}{% endif %}
{% if feed_config.rss %}<link type="application/rss+xml" rel="alternate" href="//{{ site.ourairyu.site.domain }}/rss.xml" title="{{ site.title }}">{% endif %}
{% if feed_config.rss %}<link type="application/rss+xml" rel="alternate" href="//{{ site.ksio.meta.url | replace: 'https://', '' | replace: 'http:https://', '' }}/rss.xml" title="{{ site.title }}">{% endif %}
{% endif %}
44 changes: 28 additions & 16 deletions src/jekyll/_includes/ksio/meta/seo.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<!-- SEO -->
{% assign ksio_seo = site.ksio.seo %}
{% assign ksio_meta = site.ksio.meta %}
{% assign ksio_master = site.ksio.master %}
{% if site.url %}
{% assign seo_url = site.url | append: site.baseurl %}
{% endif %}
{% assign seo_url = seo_url | default: site.github.url %}
{% assign seo_url = seo_url | default: ksio_meta.url %}
{% assign seo_site_title = site.title | default: site.name %}
{% assign seo_title_suffix = " - " | append: seo_site_title %}

{% if page.special_title %}
{% assign seo_title = page.special_title %}
{% if page.ksio_seo_title %}
{% assign seo_title = page.ksio_seo_title %}
{% assign seo_page_title = seo_title %}
{% if ksio_seo.suffix != false %}
{% assign seo_title = seo_title | append: seo_title_suffix %}
{% endif %}
{% elsif page.title %}
{% assign seo_title = page.title %}

Expand All @@ -26,6 +33,10 @@
{% endif %}

{% assign seo_page_title = seo_title %}

{% if ksio_seo.suffix != false %}
{% assign seo_title = seo_title | append: seo_title_suffix %}
{% endif %}
{% else %}
{% if page.type == "year" %}
{% assign seo_title = page.date | date: "%Y" | prepend: "发表于 " | append: " 年的文章" %}
Expand Down Expand Up @@ -58,17 +69,17 @@
{% assign seo_description = site.description %}
{% endif %}

{% assign sp_type = page.special_type %}
{% assign site_master = site.data.social.persona[site.ourairyu.site.master] %}
{% if sp_type == "posts" %}
{% assign role_type = page.ksio_seo_role %}
{% assign master_name = ksio_master.name | default: site.author.name %}
{% if role_type == "author" %}
{% assign posts = site.posts %}
{% assign first_post_year = posts.last.date | date: "%Y" %}
{% assign last_post_year = posts.first.date | date: "%Y" %}
{% assign year_diff = last_post_year | minus: first_post_year %}

{% assign seo_description = site_master.name | append: "是一个写作爱好者,从 " | append: first_post_year | append: " 年起 " | append: year_diff | append: " 年间共写了 " | append: posts.size | append: " 篇文章。" %}
{% elsif sp_type == "dev" %}
{% assign seo_description = site_master.name | append: "是一个码农,写了 " | append: site.data.local.github.all.size | append: " 个托管于 GitHub 的开源项目,在 CodePen 上建立了 " | append: site.data.local.codepen.size | append: " 个代码演示。" %}
{% assign seo_description = master_name | append: "是一个写作爱好者,从 " | append: first_post_year | append: " 年起 " | append: year_diff | append: " 年间共写了 " | append: posts.size | append: " 篇文章。" %}
{% elsif role_type == "developer" %}
{% assign seo_description = master_name | append: "是一个码农,写了 " | append: site.data.local.github.all.size | append: " 个托管于 GitHub 的开源项目,在 CodePen 上建立了 " | append: site.data.local.codepen.size | append: " 个代码演示。" %}
{% endif %}

{% if seo_description %}
Expand Down Expand Up @@ -169,9 +180,9 @@
</script>
{% endif %}

{% if site.twitter %}
{% if ksio_master.sns.twitter %}
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@{{ site.twitter.username | replace:'@','' }}">
<meta name="twitter:site" content="@{{ ksio_master.sns.twitter.username | replace:'@','' }}">
<meta name="twitter:title" content="{{ seo_title }}">
<meta name="twitter:description" content="{{ seo_description }}">

Expand All @@ -184,22 +195,23 @@
{% endif %}
{% endif %}

{% if site.facebook %}
<meta property="article:publisher" content="{{ site.facebook.publisher }}">
<meta property="fb:app_id" content="{{ site.facebook.app_id }}">
{% if ksio_master.sns.facebook %}
<meta property="article:publisher" content="{{ ksio_master.sns.facebook.publisher }}">
<meta property="fb:app_id" content="{{ ksio_master.sns.facebook.app_id }}">
{% endif %}

{% if site.google_site_verification %}
<meta name="google-site-verification" content="{{ site.google_site_verification }}">
{% endif %}

{% if site.logo %}
{% assign site_logo = site.ksio.brand.icon | default: "ksio/favicon" %}
{% if site_logo %}
<script type="application/ld+json">
{
"@context": "http:https://schema.org",
"@type": "Organization",
"url": {{ seo_url | jsonify }},
"logo": {{ site.logo | asset_path | prepend: seo_url | jsonify }}
"logo": {{ site_logo | asset_path | replace: site.baseurl, '' | prepend: seo_url | jsonify }}
}
</script>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions src/jekyll/_includes/ksio/widgets/disqus.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<script>
var dsqjs = new DisqusJS({
shortname: '{{ disqus_shortname }}',
siteName: '{{ site.ourairyu.site.name }}',
siteName: '{{ site.title | default: site.name }}',
identifier: '{{ page.url }}',
url: 'http:https://' + location.host + '{{ page.url }}',
title: '{{ page.title }}',
api: '{{ comment_config.api.endpoint }}',
apikey: '{{ comment_config.api.key }}',
admin: '{{ comment_config.username }}',
adminLabel: '鹳狸猿'
adminLabel: '{{ comment_config.label | default: "鹳狸猿" }}'
});
</script>
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion src/jekyll/_layouts/ksio/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% if page.css %}
{% for css in page.css %}{{ css | stylesheet }}{% endfor %}
{% endif %}
{% if jekyll.environment == "production" and site.ourairyu.site.statistic == true and page.statistic != false %}
{% if jekyll.environment == "production" and site.ksio.statistic == true and page.statistic != false %}
{% javascript statistic %}
{% endif %}
{% javascript global %}
Expand Down
4 changes: 2 additions & 2 deletions src/jekyll/_layouts/ksio/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ <h3><a href="/categories/{{ category }}/">{{ postCategory }}</a></h3>
</div>
{% include ksio/components/author.html author=page.author.slug %}
{% assign translation_metadata = page.translation %}
{% assign site_master = site.ourairyu.site.master %}
{% assign site_master = site.ksio.master | default: site.author %}
{% if translation_metadata %}
<div class="Widget">
<div class="Widget-body">
<p><a href="{{ translation_metadata.original.url }}" title="查看原文《{{ translation_metadata.original.title }}》" target="_blank" rel="external ">原文</a>作者是 <a href="{{ translation_metadata.author.homepage }}" target="_blank" rel="external ">{{ translation_metadata.author.name }}</a>。本文由<a href="/people/{{ translation_metadata.translator }}/">{{ site.data.social.persona[translation_metadata.translator].name }}</a>翻译,<a href="https://linxoid.com/{{ site_master }}/" target="_blank" rel="external ">{{ site.data.social.persona[site_master].name }}</a>负责校对与润色。</p>
<p><a href="{{ translation_metadata.original.url }}" title="查看原文《{{ translation_metadata.original.title }}》" target="_blank" rel="external ">原文</a>作者是 <a href="{{ translation_metadata.author.homepage }}" target="_blank" rel="external ">{{ translation_metadata.author.name }}</a>。本文由<a href="/people/{{ translation_metadata.translator }}/">{{ site.data.social.persona[translation_metadata.translator].name }}</a>翻译,<a {% if site_master.sns.linxoid %}href="https://linxoid.com/{{ site_master.sns.linxoid }}/" target="_blank" rel="external "{% else %}href="javascript:void(0);"{% endif %}>{{ site_master.name }}</a>负责校对与润色。</p>
</div>
</div>
{% endif %}
Expand Down

0 comments on commit e70fa77

Please sign in to comment.