Skip to content

Commit 456c27c

Browse files
committed
copy from official jekyll-theme-chirpy github
1 parent d85e03a commit 456c27c

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed

_includes/search-loader.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!--
2+
Jekyll Simple Search loader
3+
See: <https://github.com/christian-fei/Simple-Jekyll-Search>
4+
-->
5+
6+
{% capture result_elem %}
7+
<article class="px-1 px-sm-2 px-lg-4 px-xl-0">
8+
<header>
9+
<h2><a href="{url}">{title}</a></h2>
10+
<div class="post-meta d-flex flex-column flex-sm-row text-muted mt-1 mb-1">
11+
{categories}
12+
{tags}
13+
</div>
14+
</header>
15+
<p>{content}</p>
16+
</article>
17+
{% endcapture %}
18+
19+
{% capture not_found %}<p class="mt-5">{{ site.data.locales[include.lang].search.no_results }}</p>{% endcapture %}
20+
21+
<script>
22+
{% comment %} Note: dependent library will be loaded in `js-selector.html` {% endcomment %}
23+
document.addEventListener('DOMContentLoaded', () => {
24+
SimpleJekyllSearch({
25+
searchInput: document.getElementById('search-input'),
26+
resultsContainer: document.getElementById('search-results'),
27+
json: '{{ '/assets/js/data/search.json' | relative_url }}',
28+
searchResultTemplate: '{{ result_elem | strip_newlines }}',
29+
noResultsText: '{{ not_found }}',
30+
templateMiddleware: function(prop, value, template) {
31+
if (prop === 'categories') {
32+
if (value === '') {
33+
return `${value}`;
34+
} else {
35+
return `<div class="me-sm-4"><i class="far fa-folder fa-fw"></i>${value}</div>`;
36+
}
37+
}
38+
39+
if (prop === 'tags') {
40+
if (value === '') {
41+
return `${value}`;
42+
} else {
43+
return `<div><i class="fa fa-tag fa-fw"></i>${value}</div>`;
44+
}
45+
}
46+
}
47+
});
48+
});
49+
</script>

_includes/search-results.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- The Search results -->
2+
3+
<div id="search-result-wrapper" class="d-flex justify-content-center d-none">
4+
<div class="col-11 content">
5+
<div id="search-hints">
6+
{% include_cached trending-tags.html lang=include.lang %}
7+
</div>
8+
<div id="search-results" class="d-flex flex-wrap justify-content-center text-muted mt-3"></div>
9+
</div>
10+
</div>

assets/js/data/mathjax.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: compress
3+
# WARNING: Don't use '//' to comment out code, use '{% comment %}' and '{% endcomment %}' instead.
4+
---
5+
6+
{%- comment -%}
7+
See: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options>
8+
{%- endcomment -%}
9+
10+
MathJax = {
11+
tex: {
12+
{%- comment -%} start/end delimiter pairs for in-line math {%- endcomment -%}
13+
inlineMath: [
14+
['$', '$'],
15+
['\\(', '\\)']
16+
],
17+
{%- comment -%} start/end delimiter pairs for display math {%- endcomment -%}
18+
displayMath: [
19+
['$$', '$$'],
20+
['\\[', '\\]']
21+
],
22+
{%- comment -%} equation numbering {%- endcomment -%}
23+
tags: 'ams'
24+
}
25+
};

assets/js/data/search.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: compress
3+
swcache: true
4+
---
5+
6+
[
7+
{% for post in site.posts %}
8+
{%- capture description -%}
9+
{% include post-description.html %}
10+
{%- endcapture -%}
11+
{
12+
"title": {{ post.title | jsonify }},
13+
"url": {{ post.url | relative_url | jsonify }},
14+
"categories": {{ post.categories | join: ', ' | jsonify }},
15+
"tags": {{ post.tags | join: ', ' | jsonify }},
16+
"date": "{{ post.date }}",
17+
"content": "{{ description }}"
18+
}{% unless forloop.last %},{% endunless %}
19+
{% endfor %}
20+
]

assets/js/data/swconf.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
layout: compress
3+
permalink: '/:path/swconf.js'
4+
# Note that this file will be fetched by the ServiceWorker, so it will not be cached.
5+
---
6+
7+
const swconf = {
8+
{% if site.pwa.cache.enabled %}
9+
cacheName: 'chirpy-{{ "now" | date: "%s" }}',
10+
11+
{%- comment -%} Resources added to the cache during PWA installation. {%- endcomment -%}
12+
resources: [
13+
'{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}',
14+
'{{ "/" | relative_url }}',
15+
{% for tab in site.tabs %}
16+
'{{- tab.url | relative_url -}}',
17+
{% endfor %}
18+
19+
{% assign cache_list = site.static_files | where: 'swcache', true %}
20+
{% for file in cache_list %}
21+
'{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
22+
{% endfor %}
23+
],
24+
25+
interceptor: {
26+
{%- comment -%} URLs containing the following paths will not be cached. {%- endcomment -%}
27+
paths: [
28+
{% for path in site.pwa.cache.deny_paths %}
29+
{% unless path == empty %}
30+
'{{ path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
31+
{% endunless %}
32+
{% endfor %}
33+
],
34+
35+
{%- comment -%} URLs containing the following prefixes will not be cached. {%- endcomment -%}
36+
urlPrefixes: [
37+
{% if site.analytics.goatcounter.id != nil and site.pageviews.provider == 'goatcounter' %}
38+
'https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/'
39+
{% endif %}
40+
]
41+
},
42+
43+
purge: false
44+
{% else %}
45+
purge: true
46+
{% endif %}
47+
};

0 commit comments

Comments
 (0)