Skip to content

Commit

Permalink
refactor: make theme color configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Mar 23, 2023
1 parent 2be1a95 commit fd7561e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions man/cookbook/apis/site-config/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ interface Link {
| 属性名 | 值类型/可选值 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `text` | `string` | `site.title` | 当前网站品牌所要显示的文本,不指定则显示网站标题 |
| `color` | `string` | - | 品牌主题色,详见下方 |
| `parent` | `Link` | - | 当前网站的父品牌,指定后会在当前网站品牌的左边显示 |

### `color`

设置之后,会在 `<head>` 标签内生成 [`<meta name="theme-color" content="指定主题色">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color){:target="_blank"}{:rel="external "}。

## `modules`

| 属性名 | 值类型/可选值 | 默认值 | 说明 |
Expand Down
1 change: 1 addition & 0 deletions man/cookbook/guides/getting-started/entity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 快速上手
11 changes: 11 additions & 0 deletions man/cookbook/guides/getting-started/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## 与静态网站生成器集成

本主题可在一些主流的静态网站生成器中使用,如 Jekyll、Hexo 等。

为了尽量统一用法和便于自动化处理,在封装适配时遵循如下约定:

- 除了个别文件外,主题所提供的和强依赖的资源基本都放在 `ksio` 文件夹下;
- 用于控制主题预置渲染逻辑的配置项都挂在静态网站生成器配置文件中的 `ksio` 下面(详见《[网站配置]({{ site.baseurl }}/apis/site-config/)》);
- 通过 [KnoSys](https://knosysio.github.io/){:target="_blank"}{:rel="external "} 生成的文件都在 `knosys``_knosys` 文件夹下。

### Jekyll
3 changes: 2 additions & 1 deletion src/jekyll/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ feed:
# KnoSys site config
ksio:
brand:
color: "#0871ab"
parent:
text: OOSS
url: https://oss.ourai.ws/
navs:
- text: 指南
- text: 文档
url: /guides/
- text: 博客
url: /posts/
Expand Down
1 change: 1 addition & 0 deletions src/jekyll/_data/local/repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cookbook:
- text: 概述
collection: pages
slug: guides
- slug: getting-started
- text: API
collection: apis
items:
Expand Down
6 changes: 3 additions & 3 deletions src/jekyll/_includes/ksio/components/doc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
{% include ksio/components/doc-toc.html repo=include.repo items=_inc_item.items collection=_inc_collection %}
{% elsif _inc_item.slug %}
{% if _inc_collection == "pages" %}
<a{% if _inc_item.slug == _inc_url_parts[1] and _inc_url_parts.size == 2 %} class="is-selected"{% endif %} href="/{{ _inc_item.slug }}/">{{ _inc_item.text }}</a>
<a{% if _inc_item.slug == _inc_url_parts[1] and _inc_url_parts.size == 2 %} class="is-selected"{% endif %} href="{{_inc_site_url}}/{{ _inc_item.slug }}/">{{ _inc_item.text }}</a>
{% else %}
<a{% if _inc_item.slug == _inc_url_parts[2] %} class="is-selected"{% endif %} href="{{ '/' | append: _inc_collection | append: '/' | append: _inc_item.slug | append: '/' | prepend: _inc_site_url }}">{{ _inc_docs[_inc_item.slug].title }}</a>
<a{% if _inc_item.slug == _inc_url_parts[2] %} class="is-selected"{% endif %} href="{{ _inc_site_url }}/{{ _inc_collection | append: '/' | append: _inc_item.slug }}/">{{ _inc_docs[_inc_item.slug].title }}</a>
{% endif %}
{% else %}
<a{% if _inc_item == _inc_url_parts[2] %} class="is-selected"{% endif %} href="{{ '/' | append: _inc_collection | append: '/' | append: _inc_item | append: '/' | prepend: _inc_site_url }}">{{ _inc_docs[_inc_item].title }}</a>
<a{% if _inc_item == _inc_url_parts[2] %} class="is-selected"{% endif %} href="{{ _inc_site_url }}/{{ _inc_collection | append: '/' | append: _inc_item }}/">{{ _inc_docs[_inc_item].title }}</a>
{% endif %}
</li>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion src/jekyll/_includes/ksio/meta/brand.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<meta name="theme-color" content="#0871ab">
{% if site.ksio.brand.color %}<meta name="theme-color" content="{{ site.ksio.brand.color }}">{% endif %}
<link rel="icon" href="{{ 'favicon' | asset_path }}">
2 changes: 2 additions & 0 deletions src/jekyll/_pages/guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ permalink: /guides/
{% highlight html %}
本站主题 <a href="https://ourai.github.io/lime/" target="_blank" rel="external ">Lime</a> 由 <a href="https://linxoid.com/ourai/" target="_blank" rel="external ">欧雷</a> 提供
{% endhighlight %}

关于主题的使用方式详见《[快速上手]({{ site.baseurl }}/guides/getting-started/)》。

0 comments on commit fd7561e

Please sign in to comment.