Skip to content

Commit

Permalink
内置主题
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Jul 9, 2024
1 parent 0bfe98d commit ed701aa
Show file tree
Hide file tree
Showing 172 changed files with 14,656 additions and 7 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source "https://rubygems.org/"
gem "jekyll-remote-theme"
gem "webrick"
gem "csv"

Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.9.1)
faraday (2.9.2)
faraday (2.10.0)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-net_http (3.1.0)
net-http
ffi (1.17.0-aarch64-linux-gnu)
Expand Down Expand Up @@ -223,6 +224,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
mercenary (0.3.6)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
Expand Down
6 changes: 3 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ lang: zh-Hans
description: 《明日方舟》长草助手

plugins:
- jekyll-remote-theme

remote_theme: ArkMowers/jekyll-rtd-theme
- jemoji
- jekyll-avatar
- jekyll-mentions

readme_index:
with_frontmatter: true
Expand Down
9 changes: 9 additions & 0 deletions _includes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Document Statement

## templates

Template files for this theme

## common

Some common variables and code snippets are designed to be shared by multiple themes
3 changes: 3 additions & 0 deletions _includes/common/assets/data.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- include common/rest/site_pages.liquid -%}

{{- site_pages | jsonify -}}
4 changes: 4 additions & 0 deletions _includes/common/assets/robots.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: {{ "sitemap.xml" | absolute_url }}
11 changes: 11 additions & 0 deletions _includes/common/assets/sitemap.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- include common/rest/site_pages.liquid -%}

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for page in site_pages -%}
<url>
<loc>{{ page.url | absolute_url | xml_escape }}</loc>
<priority>{{ page.content | size | divided_by: 2048.0 | times: 10 | ceil | divided_by: 10.0 | at_least: 0.1 | at_most: 1.0 }}</priority>
</url>
{%- endfor %}
</urlset>
39 changes: 39 additions & 0 deletions _includes/common/assets/sw.caches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
self.addEventListener("activate", function (event) {
const current = ["{{ theme_alias }}"];

event.waitUntil(
caches.keys().then(function (keyList) {
return Promise.all(
keyList.map(function (key) {
if (current.indexOf(key) === -1) {
return caches.delete(key);
}
})
);
})
);
});

self.addEventListener("fetch", function (e) {
if (e.request.url.match("{{ theme_alias }}")) {
e.respondWith(
caches.match(e.request).then(function (resp) {
if (resp !== undefined) {
return resp;
} else {
return fetch(e.request, {
cache: "no-store",
})
.then(function (resp) {
let clone = resp.clone();
caches.open("{{ theme_alias }}").then(function (cache) {
cache.put(e.request, clone);
});
return resp;
})
.catch(console.log);
}
})
);
}
});
15 changes: 15 additions & 0 deletions _includes/common/core/_list.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{%- include common/rest/site_pages.liquid -%}
{%- include common/rest/workdir.liquid -%}

{%- assign base = page.dir | append: "temp/" | split: "/" | size -%}
{%- assign size = workdir_level | minus: base -%}
{%- assign size_p1 = size | plus: 1 -%}

{%- assign dir = site_pages | where: "url", workdir | first %}
{% include common/rest/tabs.liquid size=size %}- [{{ dir.title | default: dir.url }}]({{ dir.url | relative_url }})

{%- for item in workdir_files %}
{% include common/rest/tabs.liquid size=size_p1 %}- [{{ item.title | default: item.name }}]({{ item.url | relative_url }})
{%- endfor -%}

{%- for workdir in workdir_dirs %}{% include common/core/_list.liquid %}{% endfor -%}
10 changes: 10 additions & 0 deletions _includes/common/core/list.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{%- include common/rest/site_pages.liquid -%}
{%- include common/rest/workdir.liquid workdir=page.dir -%}

{%- for item in workdir_files %}
- [{{ item.title | default: item.name }}]({{ item.url | relative_url }})
{%- endfor -%}

{%- if include.all -%}
{%- for workdir in workdir_dirs %}{% include common/core/_list.liquid %}{% endfor -%}
{%- endif -%}
3 changes: 3 additions & 0 deletions _includes/common/google_adsense.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if site.google.adsense -%}
<script data-ad-client="{{ site.google.adsense }}" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
{%- endif -%}
11 changes: 11 additions & 0 deletions _includes/common/google_gtag.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- if site.google.gtag -%}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google.gtag }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "{{ site.google.gtag }}");
</script>
{%- endif -%}
26 changes: 26 additions & 0 deletions _includes/common/links.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{%- comment %} dns-prefetch {% endcomment %}
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net">

{%- comment %} canonical link {% endcomment -%}
{%- if prev -%}
<link rel="prev" href="{{ prev.url | absolute_url }}">
{%- endif -%}

{%- if next -%}
<link rel="next" href="{{ next.url | absolute_url }}">
{%- endif -%}

<link rel="canonical" href="{{ schema_surl }}">

{%- comment %} favicon icon {% endcomment -%}
<link rel="icon" type="image/svg+xml" href="{{ site.baseurl }}/assets/images/favicon.svg">
{%- comment %} alternate {% endcomment -%}
<link rel="icon" type="image/png" href="{{ site.baseurl }}/assets/images/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="{{ site.baseurl }}/assets/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="{{ site.baseurl }}/assets/images/favicon-96x96.png" sizes="96x96">

{%- comment %} safari {% endcomment -%}
<link rel="mask-icon" href="{{ site.baseurl }}/assets/images/favicon.svg" color="{{ theme_color }}">

{%- comment %} apple-touch-icon {% endcomment -%}
<link rel="apple-touch-icon" href="{{ site.baseurl }}/assets/images/apple-touch-icon-300x300.jpg">
6 changes: 6 additions & 0 deletions _includes/common/mathjax.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%- if page.content contains "$$" -%}
<script>
window.MathJax = {% if site.mathjax %}{{ site.mathjax | jsonify }}{% else %}{}{% endif %};
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax/es5/tex-svg-full.js"></script>
{%- endif %}
10 changes: 10 additions & 0 deletions _includes/common/mermaid.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{%- if content contains '<code class="language-mermaid">' -%}
{%- if site.mermaid.custom -%}
<script src="{{ site.mermaid.custom }}"></script>
{%- else -%}
<script src="{{ base }}/assets/js/mermaid.min.js"></script>
{%- endif %}
<script>
mermaid.initialize({% if site.mermaid.initialize %}{{ site.mermaid.initialize | jsonify }}{% else %}{}{% endif %});
</script>
{%- endif %}
12 changes: 12 additions & 0 deletions _includes/common/metadata.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, user-scalable=no">
<meta name="description" content="{{ description }}">
<meta name="revised" content="{{ docs.build_revision }}">
<meta name="author" content="{{ author }}">
<meta name="generator" content="{{ generator }} v{{ version }}">

{%- for meta in site.meta -%}
<meta name="{{ meta.first }}" content="{{ meta.last }}">
{%- endfor -%}

<meta name="theme-color" content="{{ theme_color }}">
6 changes: 6 additions & 0 deletions _includes/common/opengraph.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<meta property="og:title" content="{{ title }}">
<meta property="og:description" content="{{ description }}">
<meta property="og:locale" content="{{ lang }}">
<meta property="og:url" content="{{ schema_surl }}">
<meta property="og:type" content="article">
<meta property="article:author" content="{{ author }}">
6 changes: 6 additions & 0 deletions _includes/common/rest/content.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%- assign content = content
| replace: "’", "'"
| replace: "“", '"'
| replace: "”", '"'
| replace: "<script", '<script async'
| replace: "highlighter-rouge", "highlighter-rouge notranslate" -%}
7 changes: 7 additions & 0 deletions _includes/common/rest/defaults.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{%- include common/rest/site_pages.liquid -%}
{%- include common/rest/i18n.liquid -%}
{%- include common/rest/variables.liquid -%}
{%- include common/rest/content.liquid -%}
{%- include common/rest/nav.liquid -%}
{%- include common/rest/title.liquid -%}
{%- include common/rest/description.liquid -%}
6 changes: 6 additions & 0 deletions _includes/common/rest/description.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%- assign description = content
| strip_html
| split: " "
| join: " "
| escape
| truncate: 150 -%}
1 change: 1 addition & 0 deletions _includes/common/rest/i18n.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{%- assign __ = site.translate | default: site.data.translate -%}
20 changes: 20 additions & 0 deletions _includes/common/rest/nav.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{%- include common/rest/workdir.liquid workdir=page.dir -%}

{% comment %} prev and next {% endcomment %}
{%- assign index = 0 -%}
{%- for item in workdir_files %}
{%- if item.url == page.url %}
{%- assign index = forloop.index -%}
{%- endif %}
{%- endfor -%}

{%- for item in workdir_files -%}
{%- assign index_prev = index | minus: 1 -%}
{%- assign index_next = index | plus: 1 -%}
{%- if forloop.index == index_prev -%}
{%- assign prev = item -%}
{%- endif %}
{%- if forloop.index == index_next -%}
{%- assign next = item -%}
{%- endif %}
{%- endfor -%}
8 changes: 8 additions & 0 deletions _includes/common/rest/site_pages.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- assign site_pages = site.html_pages
| sort: "path"
| sort: "sort"
| where_exp: "item", "item.url != '/404.html'"
| where_exp: "item", "item.url != '/search.html'" -%}

{%- assign site_dirs = site_pages | where_exp: "item", "item.dir == item.url" -%}
{%- assign site_files = site_pages | where_exp: "item", "item.dir != item.url" -%}
2 changes: 2 additions & 0 deletions _includes/common/rest/tabs.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- assign tab = " " -%}
{%- for temp in (1..include.size) %}{{ tab }}{% endfor -%}
18 changes: 18 additions & 0 deletions _includes/common/rest/title.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{%- case page.url -%}
{%- when "/" -%}
{%- assign title = site.title
| append: " · "
| append: site.description | truncate: 110 -%}
{%- when "/search.html" -%}
{%- assign title = __.search | default: "Search"
| append: " · "
| append: site.title | truncate: 110 -%}
{%- when "/404.html" -%}
{%- assign title = "404"
| append: " · "
| append: site.title | truncate: 110 -%}
{%- else -%}
{%- assign title = page.title | default: page.name
| append: " · "
| append: site.title | truncate: 110 -%}
{%- endcase -%}
39 changes: 39 additions & 0 deletions _includes/common/rest/variables.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{%- comment %} variables {% endcomment -%}
{%- assign version = theme_alias | split: "@" | last -%}
{%- assign docs = site.github -%}
{%- assign rest = docs.public_repositories | where: "html_url", docs.repository_url | first -%}

{%- assign rest_created_at = rest.created_at | default: site.time -%}
{%- assign rest_updated_at = rest.updated_at | default: site.time -%}

{%- comment %} defaults {% endcomment -%}
{%- assign direction = site.direction | default: "auto" -%}
{%- assign lang = site.lang | default: "en" -%}
{%- assign author = docs.owner.name | default: docs.owner_name -%}

{%- capture generator -%}
{%- if site.remote_theme -%}
{{- theme_alias | split: "@" | first -}}
{%- else -%}
{{- theme_alias | split: "@" | first | split: "/" | last -}}
{%- endif -%}
{%- endcapture -%}

{%- comment %} schema {% endcomment -%}
{%- assign schema_surl = page.url | absolute_url | xml_escape -%}

{% comment %} debug {% endcomment %}
{%- if site.debug -%}
{%- assign base = site.baseurl -%}
{%- else -%}
{%- assign base = "https://cdn.jsdelivr.net/gh/" | append: theme_alias -%}
{%- endif -%}

{% comment %} extra {% endcomment %}
{%- capture extra_scss -%}
{%- include extra/styles.scss -%} {{- site.scss -}}
{%- endcapture -%}

{%- capture extra_script -%}
{%- include extra/script.js -%} {{- site.script -}}
{%- endcapture -%}
19 changes: 19 additions & 0 deletions _includes/common/rest/workdir.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- assign workdir = include.workdir | default: "/" -%}

{%- assign workdir_level = workdir | append: "temp" | replace_first: "/", "" | split: "/" | size -%}
{%- assign workdir_files = site_files | where_exp: "item", "item.dir == workdir" -%}

{%- capture items -%}
{%- for item in site_dirs -%}
{%- assign current_m1 = item.dir | append: "temp" | replace_first: "/", "" | split: "/" | size | minus: 1 -%}
{%- if workdir_level == current_m1 -%}
{%- assign temp = workdir | append: "@@" -%}
{%- assign dir = item.dir | replace: workdir, temp | split: "@@" | first -%}
{% comment %} In the current subdirectory {% endcomment %}
{%- if workdir == dir -%}
{{ item.dir }}|
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endcapture -%}
{%- assign workdir_dirs = items | split: "|" -%}
25 changes: 25 additions & 0 deletions _includes/common/schema.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ schema_surl }}"
},
"headline": "{{ title }}",
"image": [{% for image in page.images %}"{{ image }}"{% unless forloop.last %},{% endunless %}{% endfor %}],
"author": {
"@type": "Person",
"name": "{{ author }}"
},
"publisher": {
"@type": "{{ docs.owner.type }}",
"name": "{{ author }}",
"logo": {
"@type": "ImageObject",
"url": "{{ docs.owner.avatar_url }}"
}
},
"description": "{{ description }}"
}
</script>
11 changes: 11 additions & 0 deletions _includes/common/script.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
window.ui = {
title: "{{ site.title }}",
baseurl: "{{ site.baseurl }}",
i18n: {
search_results: "{{ __.search_results | default: 'Search Results' }}",
search_results_found: "{{ __.search_results_found | default: 'Search finished, found # page(s) matching the search query.' }}",
search_results_not_found: "{{ __.search_results_not_found | default: 'Your search did not match any documents, please make sure that all characters are spelled correctly!' }}"
}
};
</script>
1 change: 1 addition & 0 deletions _includes/common/title.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<title>{{ title }}</title>
6 changes: 6 additions & 0 deletions _includes/common/twitter_cards.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<meta name="twitter:title" content="{{ title }}">
<meta name="twitter:description" content="{{ description }}">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@{{ author }}">
<meta name="twitter:url" content="{{ schema_surl }}">
<meta name="twitter:creator" content="@{{ generator }} v{{ version }}">
Loading

0 comments on commit ed701aa

Please sign in to comment.