mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 13:44:15 +00:00
Compare commits
26 Commits
v7.1.0
...
3acd27abd6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3acd27abd6 | ||
|
|
cafc76e940 | ||
|
|
65f960c31a | ||
|
|
d51345e297 | ||
|
|
2f844978aa | ||
|
|
42dea8ee29 | ||
|
|
86b13c917f | ||
|
|
4ef3cd8efc | ||
|
|
c7f967529c | ||
|
|
74ed06321c | ||
|
|
d4f7f39ece | ||
|
|
c1bd9eb9ee | ||
|
|
6f461132c0 | ||
|
|
03e302cbf6 | ||
|
|
8a064a5e5a | ||
|
|
740bd84c51 | ||
|
|
93f616b25d | ||
|
|
e6b87d2811 | ||
|
|
73749067c5 | ||
|
|
fd0df8320f | ||
|
|
fbcdf8ce85 | ||
|
|
fac6116af1 | ||
|
|
5a63244721 | ||
|
|
3ab3b844d2 | ||
|
|
367262e74d | ||
|
|
cbc93193e1 |
7
.github/workflows/cd.yml
vendored
7
.github/workflows/cd.yml
vendored
@@ -2,13 +2,12 @@ name: CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- production
|
||||
tags-ignore:
|
||||
- "**"
|
||||
branches: [production]
|
||||
tags-ignore: ["**"]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
if: ${{ ! startsWith(github.event.head_commit.message, 'chore(release)') }}
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@@ -1,17 +1,25 @@
|
||||
name: "CI"
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
- "hotfix/**"
|
||||
- master
|
||||
- "hotfix/*"
|
||||
paths-ignore:
|
||||
- ".github/**"
|
||||
- "!.github/workflows/ci.yml"
|
||||
- ".gitignore"
|
||||
- .gitignore
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
- "LICENSE"
|
||||
- README.md
|
||||
- LICENSE
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- ".github/**"
|
||||
- "!.github/workflows/ci.yml"
|
||||
- .gitignore
|
||||
- "docs/**"
|
||||
- README.md
|
||||
- LICENSE
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
8
.github/workflows/commitlint.yml
vendored
8
.github/workflows/commitlint.yml
vendored
@@ -1,5 +1,11 @@
|
||||
name: Lint Commit Messages
|
||||
on: pull_request
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- "hotfix/*"
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
commitlint:
|
||||
|
||||
25
.github/workflows/pr-filter.yml
vendored
Normal file
25
.github/workflows/pr-filter.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: PR Filter
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened]
|
||||
|
||||
jobs:
|
||||
check-template:
|
||||
if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check PR Content
|
||||
id: intercept
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const script = require('.github/workflows/scripts/pr-filter.js');
|
||||
await script({ github, context, core });
|
||||
1
.github/workflows/publish.yml
vendored
1
.github/workflows/publish.yml
vendored
@@ -10,6 +10,7 @@ on:
|
||||
required: true
|
||||
BUILDER:
|
||||
required: true
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
launch:
|
||||
|
||||
36
.github/workflows/scripts/pr-filter.js
vendored
Normal file
36
.github/workflows/scripts/pr-filter.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
function hasTypes(markdown) {
|
||||
return /## Type of change/.test(markdown) && /-\s\[x\]/i.test(markdown);
|
||||
}
|
||||
|
||||
function hasDescription(markdown) {
|
||||
return (
|
||||
/## Description/.test(markdown) &&
|
||||
!/## Description\s*\n\s*(##|\s*$)/.test(markdown)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = async ({ github, context, core }) => {
|
||||
const pr = context.payload.pull_request;
|
||||
const body = pr.body === null ? '' : pr.body;
|
||||
const markdown = body.replace(/<!--[\s\S]*?-->/g, '');
|
||||
const action = context.payload.action;
|
||||
|
||||
const isValid =
|
||||
markdown !== '' && hasTypes(markdown) && hasDescription(markdown);
|
||||
|
||||
if (!isValid) {
|
||||
await github.rest.pulls.update({
|
||||
...context.repo,
|
||||
pull_number: pr.number,
|
||||
state: 'closed'
|
||||
});
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: pr.number,
|
||||
body: `Oops, it seems you've ${action} an invalid pull request. No worries, we'll close it for you.`
|
||||
});
|
||||
|
||||
core.setFailed('PR content does not meet template requirements.');
|
||||
}
|
||||
};
|
||||
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -9,7 +9,7 @@ permissions:
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
STALE_LABEL: stale
|
||||
STALE_LABEL: inactive
|
||||
EXEMPT_LABELS: "pending,planning,in progress"
|
||||
MESSAGE: >
|
||||
This conversation has been automatically marked as stale because it has not had recent activity.
|
||||
|
||||
6
.github/workflows/style-lint.yml
vendored
6
.github/workflows/style-lint.yml
vendored
@@ -1,8 +1,10 @@
|
||||
name: "Style Lint"
|
||||
name: Style Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master", "hotfix/**"]
|
||||
branches:
|
||||
- master
|
||||
- "hotfix/*"
|
||||
paths: ["_sass/**/*.scss"]
|
||||
pull_request:
|
||||
paths: ["_sass/**/*.scss"]
|
||||
|
||||
2
Gemfile
2
Gemfile
@@ -11,4 +11,4 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do
|
||||
gem "tzinfo-data"
|
||||
end
|
||||
|
||||
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
|
||||
gem "wdm", "~> 0.2.0", :platforms => [:mingw, :x64_mingw, :mswin]
|
||||
|
||||
@@ -14,7 +14,7 @@ tabs:
|
||||
categories: Catégories
|
||||
tags: Tags
|
||||
archives: Archives
|
||||
about: A propos de
|
||||
about: À propos
|
||||
|
||||
# the text displayed in the search bar & search results
|
||||
search:
|
||||
@@ -32,12 +32,12 @@ copyright:
|
||||
license:
|
||||
template: Cet article est sous licence :LICENSE_NAME par l'auteur.
|
||||
name: CC BY 4.0
|
||||
link: https://creativecommons.org/licenses/by/4.0/
|
||||
link: https://creativecommons.org/licenses/by/4.0/deed.fr
|
||||
|
||||
# Displayed in the footer
|
||||
brief: Certains droits réservés.
|
||||
verbose: >-
|
||||
Sauf mention contraire, les articles de ce site sont publiés sous licence
|
||||
Sauf mention contraire, les articles de ce site sont publiés
|
||||
sous la licence Creative Commons Attribution 4.0 International (CC BY 4.0) par l'auteur.
|
||||
|
||||
meta: Propulsé par :PLATFORM avec le thème :THEME
|
||||
|
||||
@@ -14,24 +14,23 @@ tabs:
|
||||
categories: Kategóriák
|
||||
tags: Címkék
|
||||
archives: Archívum
|
||||
about: Rólam
|
||||
about: Bemutatkozás
|
||||
|
||||
# the text displayed in the search bar & search results
|
||||
search:
|
||||
hint: keresés
|
||||
cancel: Mégse
|
||||
no_results: Oops! Nincs találat a keresésre.
|
||||
no_results: Hoppá! Nincs találat a keresésre.
|
||||
|
||||
panel:
|
||||
lastmod: Legutóbb frissítve
|
||||
trending_tags: Népszerű Címkék
|
||||
toc: Tartalom
|
||||
links: Blog linkek
|
||||
|
||||
copyright:
|
||||
# Shown at the bottom of the post
|
||||
license:
|
||||
template: A bejegyzés :LICENSE_NAME licenccel rendelkezik.
|
||||
template: A bejegyzést a szerző :LICENSE_NAME licenc alatt engedélyezte.
|
||||
name: CC BY 4.0
|
||||
link: https://creativecommons.org/licenses/by/4.0/
|
||||
|
||||
@@ -42,7 +41,7 @@ copyright:
|
||||
Creative Commons Attribution 4.0 International (CC BY 4.0) licenccel rendelkeznek,
|
||||
hacsak másképp nincs jelezve.
|
||||
|
||||
meta: Készítve :PLATFORM motorral :THEME témával
|
||||
meta: Készítve :THEME témával a :PLATFORM platformra.
|
||||
|
||||
not_found:
|
||||
statement: Sajnáljuk, az URL-t rosszul helyeztük el, vagy valami nem létezőre mutat.
|
||||
@@ -73,7 +72,21 @@ post:
|
||||
title: Link másolása
|
||||
succeed: Link sikeresen másolva!
|
||||
|
||||
# Date time format.
|
||||
# See: <http://strftime.net/>, <https://day.js.org/docs/en/display/format>
|
||||
df:
|
||||
post:
|
||||
strftime: "%Y. %B. %e."
|
||||
dayjs: "YYYY. MMMM D."
|
||||
archives:
|
||||
strftime: "%B"
|
||||
dayjs: "MMM"
|
||||
|
||||
# categories page
|
||||
categories:
|
||||
category_measure: kategória
|
||||
post_measure: bejegyzés
|
||||
category_measure:
|
||||
singular: kategória
|
||||
plural: kategória
|
||||
post_measure:
|
||||
singular: bejegyzés
|
||||
plural: bejegyzés
|
||||
|
||||
@@ -4,4 +4,3 @@
|
||||
src="https://static.cloudflareinsights.com/beacon.min.js"
|
||||
data-cf-beacon='{"token": "{{ site.analytics.cloudflare.id }}"}'
|
||||
></script>
|
||||
<!-- End Cloudflare Web Analytics -->
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
<script
|
||||
src="https://cdn.usefathom.com/script.js"
|
||||
data-site="{{ site.analytics.fathom.id }}"
|
||||
defer>
|
||||
</script>
|
||||
<!-- End Fathom Code -->
|
||||
defer
|
||||
></script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script defer src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.id }}"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function (event) {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<!-- Matomo -->
|
||||
<script type="text/javascript">
|
||||
var _paq = window._paq = window._paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var _paq = (window._paq = window._paq || []);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
var u="//{{ site.analytics.matomo.domain }}/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', {{ site.analytics.matomo.id }}]);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
});
|
||||
</script>
|
||||
<!-- End Matomo Code -->
|
||||
|
||||
@@ -1,38 +1,25 @@
|
||||
<!-- The Disqus lazy loading. -->
|
||||
|
||||
<div id="disqus_thread">
|
||||
<p class="text-center text-muted small">Comments powered by <a href="https://disqus.com/">Disqus</a>.</p>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
var disqus_config = function () {
|
||||
this.page.url = '{{ page.url | absolute_url }}';
|
||||
this.page.identifier = '{{ page.url }}';
|
||||
};
|
||||
|
||||
{%- comment -%} Lazy loading {%- endcomment -%}
|
||||
var disqus_observer = new IntersectionObserver(
|
||||
function (entries) {
|
||||
if (entries[0].isIntersecting) {
|
||||
(function () {
|
||||
var d = document,
|
||||
s = d.createElement('script');
|
||||
s.src = 'https://{{ site.comments.disqus.shortname }}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
function addDisqus() {
|
||||
let disqusThread = document.createElement('div');
|
||||
let paragraph = document.createElement('p');
|
||||
|
||||
disqus_observer.disconnect();
|
||||
}
|
||||
},
|
||||
{ threshold: [0] }
|
||||
);
|
||||
disqusThread.id = 'disqus_thread';
|
||||
paragraph.className = 'text-center text-muted small';
|
||||
paragraph.innerHTML = 'Comments powered by <a href="https://disqus.com/">Disqus</a>.';
|
||||
disqusThread.appendChild(paragraph);
|
||||
|
||||
disqus_observer.observe(document.getElementById('disqus_thread'));
|
||||
const footer = document.querySelector('footer');
|
||||
footer.insertAdjacentElement("beforebegin", disqusThread);
|
||||
}
|
||||
|
||||
{%- comment -%} Auto switch theme {%- endcomment -%}
|
||||
function reloadDisqus() {
|
||||
if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
|
||||
function reloadDisqus(event) {
|
||||
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
||||
{%- comment -%} Disqus hasn't been loaded {%- endcomment -%}
|
||||
if (typeof DISQUS === 'undefined') {
|
||||
return;
|
||||
@@ -44,7 +31,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById('mode-toggle')) {
|
||||
window.addEventListener('message', reloadDisqus);
|
||||
addDisqus();
|
||||
|
||||
if (Theme.switchable) {
|
||||
addEventListener('message', reloadDisqus);
|
||||
}
|
||||
|
||||
{%- comment -%} Lazy loading {%- endcomment -%}
|
||||
var disqusObserver = new IntersectionObserver(
|
||||
function (entries) {
|
||||
if (entries[0].isIntersecting) {
|
||||
var d = document,
|
||||
s = d.createElement('script');
|
||||
s.src = 'https://{{ site.comments.disqus.shortname }}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
|
||||
disqusObserver.disconnect();
|
||||
}
|
||||
},
|
||||
{ threshold: [0] }
|
||||
);
|
||||
|
||||
disqusObserver.observe(document.getElementById('disqus_thread'));
|
||||
</script>
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
<!-- https://giscus.app/ -->
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
(function () {
|
||||
const origin = 'https://giscus.app';
|
||||
const lightTheme = 'light';
|
||||
const darkTheme = 'dark_dimmed';
|
||||
|
||||
let initTheme = lightTheme;
|
||||
const html = document.documentElement;
|
||||
|
||||
if (
|
||||
(html.hasAttribute('data-mode') &&
|
||||
html.getAttribute('data-mode') === 'dark') ||
|
||||
(!html.hasAttribute('data-mode') &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
initTheme = darkTheme;
|
||||
}
|
||||
const themeMapper = Theme.getThemeMapper('light', 'dark_dimmed');
|
||||
const initTheme = themeMapper[Theme.visualState];
|
||||
|
||||
let lang = '{{ site.comments.giscus.lang | default: lang }}';
|
||||
{%- comment -%} https://github.com/giscus/giscus/tree/main/locales {%- endcomment -%}
|
||||
@@ -41,30 +28,27 @@
|
||||
async: ''
|
||||
};
|
||||
|
||||
let giscusScript = document.createElement('script');
|
||||
let giscusNode = document.createElement('script');
|
||||
Object.entries(giscusAttributes).forEach(([key, value]) =>
|
||||
giscusScript.setAttribute(key, value)
|
||||
giscusNode.setAttribute(key, value)
|
||||
);
|
||||
document.getElementById('tail-wrapper').appendChild(giscusScript);
|
||||
|
||||
const $footer = document.querySelector('footer');
|
||||
$footer.insertAdjacentElement("beforebegin", giscusNode);
|
||||
|
||||
addEventListener('message', (event) => {
|
||||
if (
|
||||
event.source === window &&
|
||||
event.data &&
|
||||
event.data.direction === ModeToggle.ID
|
||||
) {
|
||||
{%- comment -%} global theme mode changed {%- endcomment -%}
|
||||
const mode = event.data.message;
|
||||
const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
||||
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
||||
const newTheme = themeMapper[Theme.visualState];
|
||||
|
||||
const message = {
|
||||
setConfig: {
|
||||
theme: theme
|
||||
theme: newTheme
|
||||
}
|
||||
};
|
||||
|
||||
const giscus = document.getElementsByClassName('giscus-frame')[0].contentWindow;
|
||||
giscus.postMessage({ giscus: message }, origin);
|
||||
const giscus =
|
||||
document.getElementsByClassName('giscus-frame')[0].contentWindow;
|
||||
giscus.postMessage({ giscus: message }, 'https://giscus.app');
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,49 +1,38 @@
|
||||
<!-- https://utteranc.es/ -->
|
||||
<script
|
||||
src="https://utteranc.es/client.js"
|
||||
repo="{{ site.comments.utterances.repo }}"
|
||||
issue-term="{{ site.comments.utterances.issue_term }}"
|
||||
crossorigin="anonymous"
|
||||
async
|
||||
></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
(function () {
|
||||
const origin = 'https://utteranc.es';
|
||||
const lightTheme = 'github-light';
|
||||
const darkTheme = 'github-dark';
|
||||
let initTheme = lightTheme;
|
||||
const html = document.documentElement;
|
||||
const themeMapper = Theme.getThemeMapper('github-light', 'github-dark');
|
||||
const initTheme = themeMapper[Theme.visualState];
|
||||
|
||||
if (
|
||||
(html.hasAttribute('data-mode') && html.getAttribute('data-mode') === 'dark') ||
|
||||
(!html.hasAttribute('data-mode') && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
initTheme = darkTheme;
|
||||
}
|
||||
let script = document.createElement('script');
|
||||
script.src = 'https://utteranc.es/client.js';
|
||||
script.setAttribute('repo', '{{ site.comments.utterances.repo }}');
|
||||
script.setAttribute('issue-term', '{{ site.comments.utterances.issue_term }}');
|
||||
script.setAttribute('theme', initTheme);
|
||||
script.crossOrigin = 'anonymous';
|
||||
script.async = true;
|
||||
|
||||
const $footer = document.querySelector('footer');
|
||||
$footer.insertAdjacentElement('beforebegin', script);
|
||||
|
||||
addEventListener('message', (event) => {
|
||||
let theme;
|
||||
let newTheme;
|
||||
|
||||
{%- comment -%} credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> {%- endcomment -%}
|
||||
if (event.origin === origin) {
|
||||
{%- comment -%} page initial {%- endcomment -%}
|
||||
theme = initTheme;
|
||||
} else if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
|
||||
{%- comment -%} global theme mode changed {%- endcomment -%}
|
||||
const mode = event.data.message;
|
||||
theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
|
||||
} else {
|
||||
return;
|
||||
{%- comment -%}
|
||||
Credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347>
|
||||
{%- endcomment -%}
|
||||
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
||||
newTheme = themeMapper[Theme.visualState];
|
||||
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: newTheme
|
||||
};
|
||||
|
||||
const utterances = document.querySelector('.utterances-frame').contentWindow;
|
||||
utterances.postMessage(message, origin);
|
||||
}
|
||||
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: theme
|
||||
};
|
||||
|
||||
const utterances = document.getElementsByClassName('utterances-frame')[0].contentWindow;
|
||||
utterances.postMessage(message, origin);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1b1e">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta
|
||||
name="viewport"
|
||||
@@ -97,11 +97,32 @@
|
||||
<link rel="stylesheet" href="{{ site.data.origin[type].glightbox.css | relative_url }}">
|
||||
{% endif %}
|
||||
|
||||
<!-- JavaScript -->
|
||||
<!-- Scripts -->
|
||||
|
||||
{% unless site.theme_mode %}
|
||||
{% include mode-toggle.html %}
|
||||
<script src="{{ '/assets/js/dist/theme.min.js' | relative_url }}"></script>
|
||||
{% endunless %}
|
||||
|
||||
{% include js-selector.html lang=lang %}
|
||||
|
||||
{% if jekyll.environment == 'production' %}
|
||||
<!-- PWA -->
|
||||
{% if site.pwa.enabled %}
|
||||
<script
|
||||
defer
|
||||
src="{{ '/app.min.js' | relative_url }}?baseurl={{ site.baseurl | default: '' }}®ister={{ site.pwa.cache.enabled }}"
|
||||
></script>
|
||||
{% endif %}
|
||||
|
||||
<!-- Web Analytics -->
|
||||
{% for analytics in site.analytics %}
|
||||
{% capture str %}{{ analytics }}{% endcapture %}
|
||||
{% assign platform = str | split: '{' | first %}
|
||||
{% if site.analytics[platform].id and site.analytics[platform].id != empty %}
|
||||
{% include analytics/{{ platform }}.html %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% include metadata-hook.html %}
|
||||
</head>
|
||||
|
||||
@@ -62,12 +62,12 @@
|
||||
|
||||
{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}
|
||||
|
||||
<script src="{{ script | relative_url }}"></script>
|
||||
<script defer src="{{ script | relative_url }}"></script>
|
||||
|
||||
{% if page.math %}
|
||||
<!-- MathJax -->
|
||||
<script src="{{ '/assets/js/data/mathjax.js' | relative_url }}"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
|
||||
<script async src="{{ '/assets/js/data/mathjax.js' | relative_url }}"></script>
|
||||
<script async src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
|
||||
<script id="MathJax-script" async src="{{ site.data.origin[type].mathjax.js | relative_url }}"></script>
|
||||
{% endif %}
|
||||
|
||||
@@ -84,23 +84,3 @@
|
||||
{% endcase %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.mermaid %}
|
||||
{% include mermaid.html %}
|
||||
{% endif %}
|
||||
|
||||
{% if jekyll.environment == 'production' %}
|
||||
<!-- PWA -->
|
||||
{% if site.pwa.enabled %}
|
||||
<script defer src="{{ 'app.min.js' | relative_url }}"></script>
|
||||
{% endif %}
|
||||
|
||||
<!-- Web Analytics -->
|
||||
{% for analytics in site.analytics %}
|
||||
{% capture str %}{{ analytics }}{% endcapture %}
|
||||
{% assign type = str | split: '{' | first %}
|
||||
{% if site.analytics[type].id and site.analytics[type].id != empty %}
|
||||
{% include analytics/{{ type }}.html %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% assign urls = include.urls | split: ',' %}
|
||||
|
||||
{% assign combined_urls = nil %}
|
||||
{% assign combined_urls = null %}
|
||||
|
||||
{% assign domain = 'https://cdn.jsdelivr.net/' %}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
{% endif %}
|
||||
|
||||
{% elsif url contains '//' %}
|
||||
<script src="{{ url }}"></script>
|
||||
<script defer src="{{ url }}"></script>
|
||||
{% else %}
|
||||
<script src="{{ url | relative_url }}"></script>
|
||||
<script defer src="{{ url | relative_url }}"></script>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if combined_urls %}
|
||||
<script src="{{ combined_urls }}"></script>
|
||||
<script defer src="{{ combined_urls }}"></script>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<!-- mermaid-js loader -->
|
||||
<script type="text/javascript">
|
||||
function updateMermaid(event) {
|
||||
if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
|
||||
const mode = event.data.message;
|
||||
|
||||
if (typeof mermaid === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default';
|
||||
let config = { theme: expectedTheme };
|
||||
|
||||
{%- comment -%}
|
||||
Re-render the SVG › <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344>
|
||||
{%- endcomment -%}
|
||||
const mermaidList = document.getElementsByClassName('mermaid');
|
||||
|
||||
[...mermaidList].forEach((elem) => {
|
||||
const svgCode = elem.previousSibling.children.item(0).innerHTML;
|
||||
elem.innerHTML = svgCode;
|
||||
elem.removeAttribute('data-processed');
|
||||
});
|
||||
|
||||
mermaid.initialize(config);
|
||||
mermaid.init(undefined, '.mermaid');
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
let initTheme = 'default';
|
||||
const html = document.documentElement;
|
||||
|
||||
if (
|
||||
(html.hasAttribute('data-mode') && html.getAttribute('data-mode') === 'dark') ||
|
||||
(!html.hasAttribute('data-mode') && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
initTheme = 'dark';
|
||||
}
|
||||
|
||||
let mermaidConf = {
|
||||
theme: initTheme {%- comment -%} <default | dark | forest | neutral> {%- endcomment -%}
|
||||
};
|
||||
|
||||
{%- comment -%} Create mermaid tag {%- endcomment -%}
|
||||
const basicList = document.getElementsByClassName('language-mermaid');
|
||||
[...basicList].forEach((elem) => {
|
||||
const svgCode = elem.textContent;
|
||||
const backup = elem.parentElement;
|
||||
backup.classList.add('d-none');
|
||||
{%- comment -%} create mermaid node {%- endcomment -%}
|
||||
let mermaid = document.createElement('pre');
|
||||
mermaid.classList.add('mermaid');
|
||||
const text = document.createTextNode(svgCode);
|
||||
mermaid.appendChild(text);
|
||||
backup.after(mermaid);
|
||||
});
|
||||
|
||||
mermaid.initialize(mermaidConf);
|
||||
window.addEventListener('message', updateMermaid);
|
||||
})();
|
||||
</script>
|
||||
@@ -1,116 +0,0 @@
|
||||
<!-- Switch the mode between dark and light. -->
|
||||
|
||||
<script type="text/javascript">
|
||||
class ModeToggle {
|
||||
static get MODE_KEY() {
|
||||
return 'mode';
|
||||
}
|
||||
static get MODE_ATTR() {
|
||||
return 'data-mode';
|
||||
}
|
||||
static get DARK_MODE() {
|
||||
return 'dark';
|
||||
}
|
||||
static get LIGHT_MODE() {
|
||||
return 'light';
|
||||
}
|
||||
static get ID() {
|
||||
return 'mode-toggle';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
let self = this;
|
||||
|
||||
{%- comment -%} always follow the system prefers {%- endcomment -%}
|
||||
this.sysDarkPrefers.addEventListener('change', () => {
|
||||
if (self.hasMode) {
|
||||
self.clearMode();
|
||||
}
|
||||
self.notify();
|
||||
});
|
||||
|
||||
if (!this.hasMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isDarkMode) {
|
||||
this.setDark();
|
||||
} else {
|
||||
this.setLight();
|
||||
}
|
||||
}
|
||||
|
||||
get sysDarkPrefers() {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)');
|
||||
}
|
||||
|
||||
get isPreferDark() {
|
||||
return this.sysDarkPrefers.matches;
|
||||
}
|
||||
|
||||
get isDarkMode() {
|
||||
return this.mode === ModeToggle.DARK_MODE;
|
||||
}
|
||||
|
||||
get hasMode() {
|
||||
return this.mode != null;
|
||||
}
|
||||
|
||||
get mode() {
|
||||
return sessionStorage.getItem(ModeToggle.MODE_KEY);
|
||||
}
|
||||
|
||||
{%- comment -%} get the current mode on screen {%- endcomment -%}
|
||||
get modeStatus() {
|
||||
if (this.hasMode) {
|
||||
return this.mode;
|
||||
} else {
|
||||
return this.isPreferDark ? ModeToggle.DARK_MODE : ModeToggle.LIGHT_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
setDark() {
|
||||
document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.DARK_MODE);
|
||||
sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.DARK_MODE);
|
||||
}
|
||||
|
||||
setLight() {
|
||||
document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.LIGHT_MODE);
|
||||
sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.LIGHT_MODE);
|
||||
}
|
||||
|
||||
clearMode() {
|
||||
document.documentElement.removeAttribute(ModeToggle.MODE_ATTR);
|
||||
sessionStorage.removeItem(ModeToggle.MODE_KEY);
|
||||
}
|
||||
|
||||
{%- comment -%}
|
||||
Notify another plugins that the theme mode has changed
|
||||
{%- endcomment -%}
|
||||
notify() {
|
||||
window.postMessage(
|
||||
{
|
||||
direction: ModeToggle.ID,
|
||||
message: this.modeStatus
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
|
||||
flipMode() {
|
||||
if (this.hasMode) {
|
||||
this.clearMode();
|
||||
} else {
|
||||
if (this.isPreferDark) {
|
||||
this.setLight();
|
||||
} else {
|
||||
this.setDark();
|
||||
}
|
||||
}
|
||||
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
|
||||
const modeToggle = new ModeToggle();
|
||||
</script>
|
||||
@@ -19,29 +19,31 @@
|
||||
{% capture not_found %}<p class="mt-5">{{ site.data.locales[include.lang].search.no_results }}</p>{% endcapture %}
|
||||
|
||||
<script>
|
||||
{%- comment -%} Note: dependent library will be loaded in `js-selector.html` {%- endcomment -%}
|
||||
SimpleJekyllSearch({
|
||||
searchInput: document.getElementById('search-input'),
|
||||
resultsContainer: document.getElementById('search-results'),
|
||||
json: '{{ '/assets/js/data/search.json' | relative_url }}',
|
||||
searchResultTemplate: '{{ result_elem | strip_newlines }}',
|
||||
noResultsText: '{{ not_found }}',
|
||||
templateMiddleware: function(prop, value, template) {
|
||||
if (prop === 'categories') {
|
||||
if (value === '') {
|
||||
return `${value}`;
|
||||
} else {
|
||||
return `<div class="me-sm-4"><i class="far fa-folder fa-fw"></i>${value}</div>`;
|
||||
{% comment %} Note: dependent library will be loaded in `js-selector.html` {% endcomment %}
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
SimpleJekyllSearch({
|
||||
searchInput: document.getElementById('search-input'),
|
||||
resultsContainer: document.getElementById('search-results'),
|
||||
json: '{{ '/assets/js/data/search.json' | relative_url }}',
|
||||
searchResultTemplate: '{{ result_elem | strip_newlines }}',
|
||||
noResultsText: '{{ not_found }}',
|
||||
templateMiddleware: function(prop, value, template) {
|
||||
if (prop === 'categories') {
|
||||
if (value === '') {
|
||||
return `${value}`;
|
||||
} else {
|
||||
return `<div class="me-sm-4"><i class="far fa-folder fa-fw"></i>${value}</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prop === 'tags') {
|
||||
if (value === '') {
|
||||
return `${value}`;
|
||||
} else {
|
||||
return `<div><i class="fa fa-tag fa-fw"></i>${value}</div>`;
|
||||
if (prop === 'tags') {
|
||||
if (value === '') {
|
||||
return `${value}`;
|
||||
} else {
|
||||
return `<div><i class="fa fa-tag fa-fw"></i>${value}</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
{%- endif -%}
|
||||
</a>
|
||||
|
||||
<h1 class="site-title">
|
||||
<a href="{{ '/' | relative_url }}">{{ site.title }}</a>
|
||||
</h1>
|
||||
<a class="site-title d-block" href="{{ '/' | relative_url }}">{{ site.title }}</a>
|
||||
<p class="site-subtitle fst-italic mb-0">{{ site.tagline }}</p>
|
||||
</header>
|
||||
<!-- .profile-wrapper -->
|
||||
|
||||
10
_includes/toc-status.html
Normal file
10
_includes/toc-status.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% comment %}
|
||||
Determine TOC state and return it through variable "enable_toc"
|
||||
{% endcomment %}
|
||||
|
||||
{% assign enable_toc = false %}
|
||||
{% if site.toc and page.toc %}
|
||||
{% if page.content contains '<h2' or page.content contains '<h3' %}
|
||||
{% assign enable_toc = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -1,12 +1,7 @@
|
||||
{% assign enable_toc = false %}
|
||||
{% if site.toc and page.toc %}
|
||||
{% if page.content contains '<h2' or page.content contains '<h3' %}
|
||||
{% assign enable_toc = true %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% include toc-status.html %}
|
||||
|
||||
{% if enable_toc %}
|
||||
<section id="toc-wrapper" class="d-none ps-0 pe-4">
|
||||
<section id="toc-wrapper" class="ps-0 pe-4">
|
||||
<h2 class="panel-heading ps-3 mb-2">{{- site.data.locales[include.lang].panel.toc -}}</h2>
|
||||
<nav id="toc"></nav>
|
||||
</section>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { basic, initSidebar, initTopbar } from './modules/layouts';
|
||||
import { categoryCollapse } from './modules/plugins';
|
||||
import { categoryCollapse } from './modules/components';
|
||||
|
||||
basic();
|
||||
initSidebar();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { basic, initSidebar, initTopbar } from './modules/layouts';
|
||||
import { initLocaleDatetime, loadImg } from './modules/plugins';
|
||||
import { initLocaleDatetime, loadImg } from './modules/components';
|
||||
|
||||
loadImg();
|
||||
initLocaleDatetime();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { basic, initSidebar, initTopbar } from './modules/layouts';
|
||||
import { initLocaleDatetime } from './modules/plugins';
|
||||
import { initLocaleDatetime } from './modules/components';
|
||||
|
||||
initSidebar();
|
||||
initTopbar();
|
||||
|
||||
@@ -3,4 +3,8 @@ export { initClipboard } from './components/clipboard';
|
||||
export { loadImg } from './components/img-loading';
|
||||
export { imgPopup } from './components/img-popup';
|
||||
export { initLocaleDatetime } from './components/locale-datetime';
|
||||
export { toc } from './components/toc';
|
||||
export { initToc } from './components/toc';
|
||||
export { loadMermaid } from './components/mermaid';
|
||||
export { modeWatcher } from './components/mode-toggle';
|
||||
export { back2top } from './components/back-to-top';
|
||||
export { loadTooptip } from './components/tooltip-loader';
|
||||
@@ -4,7 +4,6 @@
|
||||
* Dependencies: https://github.com/biati-digital/glightbox
|
||||
*/
|
||||
|
||||
const html = document.documentElement;
|
||||
const lightImages = '.popup:not(.dark)';
|
||||
const darkImages = '.popup:not(.light)';
|
||||
let selector = lightImages;
|
||||
@@ -33,26 +32,17 @@ export function imgPopup() {
|
||||
document.querySelector('.popup.dark') === null
|
||||
);
|
||||
|
||||
if (
|
||||
(html.hasAttribute('data-mode') &&
|
||||
html.getAttribute('data-mode') === 'dark') ||
|
||||
(!html.hasAttribute('data-mode') &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
) {
|
||||
if (Theme.visualState === Theme.DARK) {
|
||||
selector = darkImages;
|
||||
}
|
||||
|
||||
let current = GLightbox({ selector: `${selector}` });
|
||||
|
||||
if (hasDualImages && document.getElementById('mode-toggle')) {
|
||||
if (hasDualImages && Theme.switchable) {
|
||||
let reverse = null;
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (
|
||||
event.source === window &&
|
||||
event.data &&
|
||||
event.data.direction === ModeToggle.ID
|
||||
) {
|
||||
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
||||
updateImages(current, reverse);
|
||||
}
|
||||
});
|
||||
|
||||
60
_javascript/modules/components/mermaid.js
Normal file
60
_javascript/modules/components/mermaid.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Mermaid-js loader
|
||||
*/
|
||||
|
||||
const MERMAID = 'mermaid';
|
||||
const themeMapper = Theme.getThemeMapper('default', 'dark');
|
||||
|
||||
function refreshTheme(event) {
|
||||
if (event.source === window && event.data && event.data.id === Theme.ID) {
|
||||
// Re-render the SVG › <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344>
|
||||
const mermaidList = document.getElementsByClassName(MERMAID);
|
||||
|
||||
[...mermaidList].forEach((elem) => {
|
||||
const svgCode = elem.previousSibling.children.item(0).innerHTML;
|
||||
elem.textContent = svgCode;
|
||||
elem.removeAttribute('data-processed');
|
||||
});
|
||||
|
||||
const newTheme = themeMapper[Theme.visualState];
|
||||
|
||||
mermaid.initialize({ theme: newTheme });
|
||||
mermaid.init(null, `.${MERMAID}`);
|
||||
}
|
||||
}
|
||||
|
||||
function setNode(elem) {
|
||||
const svgCode = elem.textContent;
|
||||
const backup = elem.parentElement;
|
||||
backup.classList.add('d-none');
|
||||
// Create mermaid node
|
||||
const mermaid = document.createElement('pre');
|
||||
mermaid.classList.add(MERMAID);
|
||||
const text = document.createTextNode(svgCode);
|
||||
mermaid.appendChild(text);
|
||||
backup.after(mermaid);
|
||||
}
|
||||
|
||||
export function loadMermaid() {
|
||||
if (
|
||||
typeof mermaid === 'undefined' ||
|
||||
typeof mermaid.initialize !== 'function'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const initTheme = themeMapper[Theme.visualState];
|
||||
|
||||
let mermaidConf = {
|
||||
theme: initTheme
|
||||
};
|
||||
|
||||
const basicList = document.getElementsByClassName('language-mermaid');
|
||||
[...basicList].forEach(setNode);
|
||||
|
||||
mermaid.initialize(mermaidConf);
|
||||
|
||||
if (Theme.switchable) {
|
||||
window.addEventListener('message', refreshTheme);
|
||||
}
|
||||
}
|
||||
15
_javascript/modules/components/mode-toggle.js
Normal file
15
_javascript/modules/components/mode-toggle.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Add listener for theme mode toggle
|
||||
*/
|
||||
|
||||
const $toggle = document.getElementById('mode-toggle');
|
||||
|
||||
export function modeWatcher() {
|
||||
if (!$toggle) {
|
||||
return;
|
||||
}
|
||||
|
||||
$toggle.addEventListener('click', () => {
|
||||
Theme.flip();
|
||||
});
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Add listener for theme mode toggle
|
||||
*/
|
||||
const toggle = document.getElementById('mode-toggle');
|
||||
|
||||
export function modeWatcher() {
|
||||
if (!toggle) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggle.addEventListener('click', () => {
|
||||
modeToggle.flipMode();
|
||||
});
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Expand or close the sidebar in mobile screens.
|
||||
*/
|
||||
|
||||
const ATTR_DISPLAY = 'sidebar-display';
|
||||
|
||||
class SidebarUtil {
|
||||
static isExpanded = false;
|
||||
|
||||
static toggle() {
|
||||
if (SidebarUtil.isExpanded === false) {
|
||||
document.body.setAttribute(ATTR_DISPLAY, '');
|
||||
} else {
|
||||
document.body.removeAttribute(ATTR_DISPLAY);
|
||||
}
|
||||
|
||||
SidebarUtil.isExpanded = !SidebarUtil.isExpanded;
|
||||
}
|
||||
}
|
||||
|
||||
export function sidebarExpand() {
|
||||
document
|
||||
.getElementById('sidebar-trigger')
|
||||
.addEventListener('click', SidebarUtil.toggle);
|
||||
|
||||
document.getElementById('mask').addEventListener('click', SidebarUtil.toggle);
|
||||
}
|
||||
@@ -1,15 +1,33 @@
|
||||
export function toc() {
|
||||
if (document.querySelector('main h2, main h3')) {
|
||||
// see: https://github.com/tscanlin/tocbot#usage
|
||||
tocbot.init({
|
||||
tocSelector: '#toc',
|
||||
contentSelector: '.content',
|
||||
ignoreSelector: '[data-toc-skip]',
|
||||
headingSelector: 'h2, h3, h4',
|
||||
orderedList: false,
|
||||
scrollSmooth: false
|
||||
});
|
||||
import { TocMobile as mobile } from './toc/toc-mobile';
|
||||
import { TocDesktop as desktop } from './toc/toc-desktop';
|
||||
|
||||
document.getElementById('toc-wrapper').classList.remove('d-none');
|
||||
const desktopMode = matchMedia('(min-width: 1200px)');
|
||||
|
||||
function refresh(e) {
|
||||
if (e.matches) {
|
||||
if (mobile.popupOpened) {
|
||||
mobile.hidePopup();
|
||||
}
|
||||
|
||||
desktop.refresh();
|
||||
} else {
|
||||
mobile.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (document.querySelector('main>article[data-toc="true"]') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid create multiple instances of Tocbot. Ref: <https://github.com/tscanlin/tocbot/issues/203>
|
||||
if (desktopMode.matches) {
|
||||
desktop.init();
|
||||
} else {
|
||||
mobile.init();
|
||||
}
|
||||
|
||||
desktopMode.onchange = refresh;
|
||||
}
|
||||
|
||||
export { init as initToc };
|
||||
|
||||
22
_javascript/modules/components/toc/toc-desktop.js
Normal file
22
_javascript/modules/components/toc/toc-desktop.js
Normal file
@@ -0,0 +1,22 @@
|
||||
export class TocDesktop {
|
||||
/* Tocbot options Ref: https://github.com/tscanlin/tocbot#usage */
|
||||
static options = {
|
||||
tocSelector: '#toc',
|
||||
contentSelector: '.content',
|
||||
ignoreSelector: '[data-toc-skip]',
|
||||
headingSelector: 'h2, h3, h4',
|
||||
orderedList: false,
|
||||
scrollSmooth: false,
|
||||
headingsOffset: 16 * 2 // 2rem
|
||||
};
|
||||
|
||||
static refresh() {
|
||||
tocbot.refresh(this.options);
|
||||
}
|
||||
|
||||
static init() {
|
||||
if (document.getElementById('toc-wrapper')) {
|
||||
tocbot.init(this.options);
|
||||
}
|
||||
}
|
||||
}
|
||||
125
_javascript/modules/components/toc/toc-mobile.js
Normal file
125
_javascript/modules/components/toc/toc-mobile.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* TOC button, topbar and popup for mobile devices
|
||||
*/
|
||||
|
||||
const $tocBar = document.getElementById('toc-bar');
|
||||
const $soloTrigger = document.getElementById('toc-solo-trigger');
|
||||
const $triggers = document.getElementsByClassName('toc-trigger');
|
||||
const $popup = document.getElementById('toc-popup');
|
||||
const $btnClose = document.getElementById('toc-popup-close');
|
||||
|
||||
const SCROLL_LOCK = 'overflow-hidden';
|
||||
const CLOSING = 'closing';
|
||||
|
||||
export class TocMobile {
|
||||
static #invisible = true;
|
||||
static #barHeight = 16 * 3; // 3rem
|
||||
|
||||
static options = {
|
||||
tocSelector: '#toc-popup-content',
|
||||
contentSelector: '.content',
|
||||
ignoreSelector: '[data-toc-skip]',
|
||||
headingSelector: 'h2, h3, h4',
|
||||
orderedList: false,
|
||||
scrollSmooth: false,
|
||||
collapseDepth: 4,
|
||||
headingsOffset: this.#barHeight
|
||||
};
|
||||
|
||||
static initBar() {
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry) => {
|
||||
$tocBar.classList.toggle('invisible', entry.isIntersecting);
|
||||
});
|
||||
},
|
||||
{ rootMargin: `-${this.#barHeight}px 0px 0px 0px` }
|
||||
);
|
||||
|
||||
observer.observe($soloTrigger);
|
||||
this.#invisible = false;
|
||||
}
|
||||
|
||||
static listenAnchors() {
|
||||
const $anchors = document.getElementsByClassName('toc-link');
|
||||
[...$anchors].forEach((anchor) => {
|
||||
anchor.onclick = () => this.hidePopup();
|
||||
});
|
||||
}
|
||||
|
||||
static refresh() {
|
||||
if (this.#invisible) {
|
||||
this.initComponents();
|
||||
}
|
||||
tocbot.refresh(this.options);
|
||||
this.listenAnchors();
|
||||
}
|
||||
|
||||
static get popupOpened() {
|
||||
return $popup.open;
|
||||
}
|
||||
|
||||
static showPopup() {
|
||||
this.lockScroll(true);
|
||||
$popup.showModal();
|
||||
const activeItem = $popup.querySelector('li.is-active-li');
|
||||
activeItem.scrollIntoView({ block: 'center' });
|
||||
}
|
||||
|
||||
static hidePopup() {
|
||||
$popup.toggleAttribute(CLOSING);
|
||||
|
||||
$popup.addEventListener(
|
||||
'animationend',
|
||||
() => {
|
||||
$popup.toggleAttribute(CLOSING);
|
||||
$popup.close();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
||||
this.lockScroll(false);
|
||||
}
|
||||
|
||||
static lockScroll(enable) {
|
||||
document.documentElement.classList.toggle(SCROLL_LOCK, enable);
|
||||
document.body.classList.toggle(SCROLL_LOCK, enable);
|
||||
}
|
||||
|
||||
static clickBackdrop(event) {
|
||||
if ($popup.hasAttribute(CLOSING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = event.target.getBoundingClientRect();
|
||||
if (
|
||||
event.clientX < rect.left ||
|
||||
event.clientX > rect.right ||
|
||||
event.clientY < rect.top ||
|
||||
event.clientY > rect.bottom
|
||||
) {
|
||||
this.hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
static initComponents() {
|
||||
this.initBar();
|
||||
|
||||
[...$triggers].forEach((trigger) => {
|
||||
trigger.onclick = () => this.showPopup();
|
||||
});
|
||||
|
||||
$popup.onclick = (e) => this.clickBackdrop(e);
|
||||
$btnClose.onclick = () => this.hidePopup();
|
||||
$popup.oncancel = (e) => {
|
||||
e.preventDefault();
|
||||
this.hidePopup();
|
||||
};
|
||||
}
|
||||
|
||||
static init() {
|
||||
tocbot.init(this.options);
|
||||
this.listenAnchors();
|
||||
this.initComponents();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { back2top } from '../components/back-to-top';
|
||||
import { loadTooptip } from '../components/tooltip-loader';
|
||||
import { back2top, loadTooptip, modeWatcher } from '../components';
|
||||
|
||||
export function basic() {
|
||||
modeWatcher();
|
||||
back2top();
|
||||
loadTooptip();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
import { modeWatcher } from '../components/mode-watcher';
|
||||
import { sidebarExpand } from '../components/sidebar';
|
||||
const ATTR_DISPLAY = 'sidebar-display';
|
||||
const $sidebar = document.getElementById('sidebar');
|
||||
const $trigger = document.getElementById('sidebar-trigger');
|
||||
const $mask = document.getElementById('mask');
|
||||
|
||||
class SidebarUtil {
|
||||
static #isExpanded = false;
|
||||
|
||||
static toggle() {
|
||||
this.#isExpanded = !this.#isExpanded;
|
||||
document.body.toggleAttribute(ATTR_DISPLAY, this.#isExpanded);
|
||||
$sidebar.classList.toggle('z-2', this.#isExpanded);
|
||||
$mask.classList.toggle('d-none', !this.#isExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
export function initSidebar() {
|
||||
modeWatcher();
|
||||
sidebarExpand();
|
||||
$trigger.onclick = $mask.onclick = () => SidebarUtil.toggle();
|
||||
}
|
||||
|
||||
135
_javascript/modules/theme.js
Normal file
135
_javascript/modules/theme.js
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* Theme management class
|
||||
*
|
||||
* To reduce flickering during page load, this script should be loaded synchronously.
|
||||
*/
|
||||
class Theme {
|
||||
static #modeKey = 'mode';
|
||||
static #modeAttr = 'data-mode';
|
||||
static #darkMedia = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
static switchable = !document.documentElement.hasAttribute(this.#modeAttr);
|
||||
|
||||
static get DARK() {
|
||||
return 'dark';
|
||||
}
|
||||
|
||||
static get LIGHT() {
|
||||
return 'light';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} Theme mode identifier
|
||||
*/
|
||||
static get ID() {
|
||||
return 'theme-mode';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current visual state of the theme.
|
||||
*
|
||||
* @returns {string} The current visual state, either the mode if it exists,
|
||||
* or the system dark mode state ('dark' or 'light').
|
||||
*/
|
||||
static get visualState() {
|
||||
if (this.#hasMode) {
|
||||
return this.#mode;
|
||||
} else {
|
||||
return this.#sysDark ? this.DARK : this.LIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
static get #mode() {
|
||||
return sessionStorage.getItem(this.#modeKey);
|
||||
}
|
||||
|
||||
static get #isDarkMode() {
|
||||
return this.#mode === this.DARK;
|
||||
}
|
||||
|
||||
static get #hasMode() {
|
||||
return this.#mode !== null;
|
||||
}
|
||||
|
||||
static get #sysDark() {
|
||||
return this.#darkMedia.matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps theme modes to provided values
|
||||
* @param {string} light Value for light mode
|
||||
* @param {string} dark Value for dark mode
|
||||
* @returns {Object} Mapped values
|
||||
*/
|
||||
static getThemeMapper(light, dark) {
|
||||
return {
|
||||
[this.LIGHT]: light,
|
||||
[this.DARK]: dark
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the theme based on system preferences or stored mode
|
||||
*/
|
||||
static init() {
|
||||
if (!this.switchable) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#darkMedia.addEventListener('change', () => {
|
||||
const lastMode = this.#mode;
|
||||
this.#clearMode();
|
||||
|
||||
if (lastMode !== this.visualState) {
|
||||
this.#notify();
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.#hasMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.#isDarkMode) {
|
||||
this.#setDark();
|
||||
} else {
|
||||
this.#setLight();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips the current theme mode
|
||||
*/
|
||||
static flip() {
|
||||
if (this.#hasMode) {
|
||||
this.#clearMode();
|
||||
} else {
|
||||
this.#sysDark ? this.#setLight() : this.#setDark();
|
||||
}
|
||||
this.#notify();
|
||||
}
|
||||
|
||||
static #setDark() {
|
||||
document.documentElement.setAttribute(this.#modeAttr, this.DARK);
|
||||
sessionStorage.setItem(this.#modeKey, this.DARK);
|
||||
}
|
||||
|
||||
static #setLight() {
|
||||
document.documentElement.setAttribute(this.#modeAttr, this.LIGHT);
|
||||
sessionStorage.setItem(this.#modeKey, this.LIGHT);
|
||||
}
|
||||
|
||||
static #clearMode() {
|
||||
document.documentElement.removeAttribute(this.#modeAttr);
|
||||
sessionStorage.removeItem(this.#modeKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies other plugins that the theme mode has changed
|
||||
*/
|
||||
static #notify() {
|
||||
window.postMessage({ id: this.ID }, '*');
|
||||
}
|
||||
}
|
||||
|
||||
Theme.init();
|
||||
|
||||
export default Theme;
|
||||
@@ -1,9 +1,15 @@
|
||||
import { basic, initSidebar, initTopbar } from './modules/layouts';
|
||||
import { loadImg, imgPopup, initClipboard } from './modules/plugins';
|
||||
import {
|
||||
loadImg,
|
||||
imgPopup,
|
||||
initClipboard,
|
||||
loadMermaid
|
||||
} from './modules/components';
|
||||
|
||||
loadImg();
|
||||
imgPopup();
|
||||
initSidebar();
|
||||
initTopbar();
|
||||
initClipboard();
|
||||
loadMermaid();
|
||||
basic();
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { basic, initSidebar, initTopbar } from './modules/layouts';
|
||||
import { basic, initTopbar, initSidebar } from './modules/layouts';
|
||||
|
||||
import {
|
||||
loadImg,
|
||||
imgPopup,
|
||||
initLocaleDatetime,
|
||||
initClipboard,
|
||||
toc
|
||||
} from './modules/plugins';
|
||||
initToc,
|
||||
loadMermaid
|
||||
} from './modules/components';
|
||||
|
||||
loadImg();
|
||||
toc();
|
||||
initToc();
|
||||
imgPopup();
|
||||
initSidebar();
|
||||
initLocaleDatetime();
|
||||
initClipboard();
|
||||
initTopbar();
|
||||
loadMermaid();
|
||||
basic();
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import { pwa, baseurl } from '../../_config.yml';
|
||||
import Toast from 'bootstrap/js/src/toast';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
if (pwa.enabled) {
|
||||
const swUrl = `${baseurl}/sw.min.js`;
|
||||
// Get Jekyll config from URL parameters
|
||||
const src = new URL(document.currentScript.src);
|
||||
const register = src.searchParams.get('register');
|
||||
const baseUrl = src.searchParams.get('baseurl');
|
||||
|
||||
if (register) {
|
||||
const swUrl = `${baseUrl}/sw.min.js`;
|
||||
const notification = document.getElementById('notification');
|
||||
const btnRefresh = notification.querySelector('.toast-body>button');
|
||||
const popupWindow = Toast.getOrCreateInstance(notification);
|
||||
|
||||
navigator.serviceWorker.register(swUrl).then((registration) => {
|
||||
// In case the user ignores the notification
|
||||
// Restore the update window that was last manually closed by the user
|
||||
if (registration.waiting) {
|
||||
popupWindow.show();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { baseurl } from '../../_config.yml';
|
||||
|
||||
importScripts(`${baseurl}/assets/js/data/swconf.js`);
|
||||
importScripts('./assets/js/data/swconf.js');
|
||||
|
||||
const purge = swconf.purge;
|
||||
const interceptor = swconf.interceptor;
|
||||
|
||||
@@ -68,14 +68,18 @@ layout: compress
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div id="mask"></div>
|
||||
<div id="mask" class="d-none position-fixed w-100 h-100 z-1"></div>
|
||||
|
||||
{% if site.pwa.enabled %}
|
||||
{% include_cached notification.html lang=lang %}
|
||||
{% endif %}
|
||||
|
||||
<!-- JavaScripts -->
|
||||
{% include js-selector.html lang=lang %}
|
||||
<!-- Embedded scripts -->
|
||||
|
||||
{% for _include in layout.script_includes %}
|
||||
{% assign _include_path = _include | append: '.html' %}
|
||||
{% include {{ _include_path }} %}
|
||||
{% endfor %}
|
||||
|
||||
{% include_cached search-loader.html lang=lang %}
|
||||
</body>
|
||||
|
||||
@@ -5,38 +5,45 @@ refactor: true
|
||||
|
||||
{% include lang.html %}
|
||||
|
||||
{% assign pinned = site.posts | where: 'pin', 'true' %}
|
||||
{% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
|
||||
{% assign all_pinned = site.posts | where: 'pin', 'true' %}
|
||||
{% assign all_normal = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
|
||||
|
||||
{% assign posts = '' | split: '' %}
|
||||
|
||||
<!-- Get pinned posts -->
|
||||
<!-- Get pinned posts on current page -->
|
||||
|
||||
{% assign offset = paginator.page | minus: 1 | times: paginator.per_page %}
|
||||
{% assign pinned_num = pinned.size | minus: offset %}
|
||||
{% assign visible_start = paginator.page | minus: 1 | times: paginator.per_page %}
|
||||
{% assign visible_end = visible_start | plus: paginator.per_page %}
|
||||
|
||||
{% if pinned_num > 0 %}
|
||||
{% for i in (offset..pinned.size) limit: pinned_num %}
|
||||
{% assign posts = posts | push: pinned[i] %}
|
||||
{% if all_pinned.size > visible_start %}
|
||||
{% if all_pinned.size > visible_end %}
|
||||
{% assign pinned_size = paginator.per_page %}
|
||||
{% else %}
|
||||
{% assign pinned_size = all_pinned.size | minus: visible_start %}
|
||||
{% endif %}
|
||||
|
||||
{% for i in (visible_start..all_pinned.size) limit: pinned_size %}
|
||||
{% assign posts = posts | push: all_pinned[i] %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% assign pinned_num = 0 %}
|
||||
{% assign pinned_size = 0 %}
|
||||
{% endif %}
|
||||
|
||||
<!-- Get default posts -->
|
||||
<!-- Get normal posts on current page -->
|
||||
|
||||
{% assign default_beg = offset | minus: pinned.size %}
|
||||
{% assign normal_size = paginator.posts | size | minus: pinned_size %}
|
||||
|
||||
{% if default_beg < 0 %}
|
||||
{% assign default_beg = 0 %}
|
||||
{% endif %}
|
||||
{% if normal_size > 0 %}
|
||||
{% if pinned_size > 0 %}
|
||||
{% assign normal_start = 0 %}
|
||||
{% else %}
|
||||
{% assign normal_start = visible_start | minus: all_pinned.size %}
|
||||
{% endif %}
|
||||
|
||||
{% assign default_num = paginator.posts | size | minus: pinned_num %}
|
||||
{% assign default_end = default_beg | plus: default_num | minus: 1 %}
|
||||
{% assign normal_end = normal_start | plus: normal_size | minus: 1 %}
|
||||
|
||||
{% if default_num > 0 %}
|
||||
{% for i in (default_beg..default_end) %}
|
||||
{% assign posts = posts | push: default[i] %}
|
||||
{% for i in (normal_start..normal_end) %}
|
||||
{% assign posts = posts | push: all_normal[i] %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@ panel_includes:
|
||||
tail_includes:
|
||||
- related-posts
|
||||
- post-nav
|
||||
- comments
|
||||
script_includes:
|
||||
- comment
|
||||
---
|
||||
|
||||
{% include lang.html %}
|
||||
|
||||
<article class="px-1">
|
||||
{% include toc-status.html %}
|
||||
|
||||
<article class="px-1" data-toc="{{ enable_toc }}">
|
||||
<header>
|
||||
<h1 data-toc-skip>{{ page.title }}</h1>
|
||||
{% if page.description %}
|
||||
@@ -42,12 +45,15 @@ tail_includes:
|
||||
{%- capture lqip -%}lqip="{{ page.image.lqip }}"{%- endcapture -%}
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-3 mb-3">
|
||||
<img {{ src }} {{ class }} {{ alt }} w="1200" h="630" {{ lqip }}>
|
||||
{%- if page.image.alt -%}
|
||||
<figcaption class="text-center pt-2 pb-2">{{ page.image.alt }}</figcaption>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% if page.image.show_image_in_post != false %}
|
||||
<div class="mt-3 mb-3">
|
||||
<img {{ src }} {{ class }} {{ alt }} w="1200" h="630" {{ lqip }}>
|
||||
{%- if page.image.alt -%}
|
||||
<figcaption class="text-center pt-2 pb-2">{{ page.image.alt }}</figcaption>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
@@ -95,6 +101,30 @@ tail_includes:
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{% if enable_toc %}
|
||||
<div id="toc-bar" class="d-flex align-items-center justify-content-between invisible">
|
||||
<span class="label text-truncate">{{ page.title }}</span>
|
||||
<button type="button" class="toc-trigger btn me-1">
|
||||
<i class="fa-solid fa-list-ul fa-fw"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button id="toc-solo-trigger" type="button" class="toc-trigger btn btn-outline-secondary btn-sm">
|
||||
<span class="label ps-2 pe-1">{{- site.data.locales[lang].panel.toc -}}</span>
|
||||
<i class="fa-solid fa-angle-right fa-fw"></i>
|
||||
</button>
|
||||
|
||||
<dialog id="toc-popup" class="p-0">
|
||||
<div class="header d-flex flex-row align-items-center justify-content-between">
|
||||
<div class="label text-truncate py-2 ms-4">{{- page.title -}}</div>
|
||||
<button id="toc-popup-close" type="button" class="btn mx-1 my-1 opacity-75">
|
||||
<i class="fas fa-close"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="toc-popup-content" class="px-4 py-3 pb-4"></div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
|
||||
<div class="content">
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
@@ -227,6 +227,7 @@ image:
|
||||
```
|
||||
|
||||
Note that the [`media_subpath`](#url-prefix) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name.
|
||||
Additionally, `image.show_image_in_post` can be added and set to `false` which will hide the image from being displayed at the top of the post. However, the image will still be displayed on the homepage next to the post and whenever sharing the post in social media. `image.show_image_in_post` is `true` by default.
|
||||
|
||||
For simple use, you can also just use `image` to define the path.
|
||||
|
||||
|
||||
@@ -251,8 +251,8 @@ i {
|
||||
|
||||
> p {
|
||||
margin-left: 0.25em;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
|
||||
@include mt-mb(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -688,7 +688,6 @@ $btn-mb: 0.5rem;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
width: $sidebar-width;
|
||||
z-index: 99;
|
||||
background: var(--sidebar-bg);
|
||||
border-right: 1px solid var(--sidebar-border-color);
|
||||
|
||||
@@ -738,6 +737,9 @@ $btn-mb: 0.5rem;
|
||||
}
|
||||
|
||||
.site-title {
|
||||
@extend %clickable-transition;
|
||||
@extend %sidebar-link-hover;
|
||||
|
||||
font-family: inherit;
|
||||
font-weight: 900;
|
||||
font-size: 1.75rem;
|
||||
@@ -745,13 +747,8 @@ $btn-mb: 0.5rem;
|
||||
letter-spacing: 0.25px;
|
||||
margin-top: 1.25rem;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
a {
|
||||
@extend %clickable-transition;
|
||||
@extend %sidebar-link-hover;
|
||||
|
||||
color: var(--site-title-color);
|
||||
}
|
||||
width: fit-content;
|
||||
color: var(--site-title-color);
|
||||
}
|
||||
|
||||
.site-subtitle {
|
||||
@@ -771,8 +768,8 @@ $btn-mb: 0.5rem;
|
||||
li.nav-item {
|
||||
opacity: 0.9;
|
||||
width: 100%;
|
||||
padding-left: 1.5rem;
|
||||
padding-right: 1.5rem;
|
||||
|
||||
@include pl-pr(1.5rem);
|
||||
|
||||
a.nav-link {
|
||||
@include pt-pb(0.6rem);
|
||||
@@ -910,9 +907,7 @@ $btn-mb: 0.5rem;
|
||||
}
|
||||
|
||||
#topbar {
|
||||
button i {
|
||||
color: #999999;
|
||||
}
|
||||
@extend %btn-color;
|
||||
|
||||
#breadcrumb {
|
||||
font-size: 1rem;
|
||||
@@ -1047,7 +1042,7 @@ search {
|
||||
|
||||
a {
|
||||
font-size: 1.4rem;
|
||||
line-height: 2.5rem;
|
||||
line-height: 1.5rem;
|
||||
|
||||
&:hover {
|
||||
@extend %link-hover;
|
||||
@@ -1073,8 +1068,9 @@ search {
|
||||
}
|
||||
|
||||
> p {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@extend %text-ellipsis;
|
||||
|
||||
white-space: break-spaces;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
@@ -1090,23 +1086,11 @@ search {
|
||||
color: var(--topbar-text-color);
|
||||
text-align: center;
|
||||
width: 70%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
word-break: keep-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#mask {
|
||||
display: none;
|
||||
position: fixed;
|
||||
inset: 0 0 0 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
|
||||
@at-root [#{$sidebar-display}] & {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- basic wrappers --- */
|
||||
@@ -1496,8 +1480,8 @@ search {
|
||||
|
||||
#main-wrapper > .container {
|
||||
max-width: $main-content-max-width;
|
||||
padding-left: 1.75rem !important;
|
||||
padding-right: 1.75rem !important;
|
||||
|
||||
@include pl-pr(1.75rem, true);
|
||||
}
|
||||
|
||||
main.col-12,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
color: var(--heading-color);
|
||||
font-weight: 400;
|
||||
font-family: $font-family-heading;
|
||||
scroll-margin-top: 3.5rem;
|
||||
}
|
||||
|
||||
%anchor {
|
||||
@@ -111,6 +112,16 @@
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
@mixin text-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
%text-ellipsis {
|
||||
@include text-ellipsis;
|
||||
}
|
||||
|
||||
%text-highlight {
|
||||
color: var(--text-muted-highlight-color);
|
||||
font-weight: 600;
|
||||
@@ -134,6 +145,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
%btn-color {
|
||||
button i {
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- scss mixin --------- */
|
||||
|
||||
@mixin mt-mb($value) {
|
||||
@@ -151,9 +168,14 @@
|
||||
padding-bottom: $val;
|
||||
}
|
||||
|
||||
@mixin pl-pr($val) {
|
||||
padding-left: $val;
|
||||
padding-right: $val;
|
||||
@mixin pl-pr($val, $important: false) {
|
||||
@if $important {
|
||||
padding-left: $val !important;
|
||||
padding-right: $val !important;
|
||||
} @else {
|
||||
padding-left: $val;
|
||||
padding-right: $val;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin placeholder {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
--btn-border-color: #2e2f31;
|
||||
--btn-backtotop-color: var(--text-color);
|
||||
--btn-backtotop-border-color: #212122;
|
||||
--btn-box-shadow: var(--main-bg);
|
||||
--card-header-bg: #292929;
|
||||
--checkbox-color: rgb(118, 120, 121);
|
||||
--checkbox-checked-color: var(--link-color);
|
||||
@@ -60,6 +59,7 @@
|
||||
|
||||
/* Posts */
|
||||
--toc-highlight: rgb(116, 178, 243);
|
||||
--toc-popup-border-color: #373737;
|
||||
--tag-hover: rgb(43, 56, 62);
|
||||
--tb-odd-bg: #252526; /* odd rows of the posts' table */
|
||||
--tb-even-bg: rgb(31, 31, 34); /* even rows of the posts' table */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
--btn-border-color: #e9ecef;
|
||||
--btn-backtotop-color: #686868;
|
||||
--btn-backtotop-border-color: #f1f1f1;
|
||||
--btn-box-shadow: #eaeaea;
|
||||
--checkbox-color: #c5c5c5;
|
||||
--checkbox-checked-color: #07a8f7;
|
||||
--img-bg: radial-gradient(
|
||||
@@ -63,6 +62,7 @@
|
||||
|
||||
/* Posts */
|
||||
--toc-highlight: #0550ae;
|
||||
--toc-popup-border-color: lightgray;
|
||||
--btn-share-color: gray;
|
||||
--btn-share-hover-color: #0d6efd;
|
||||
--card-bg: white;
|
||||
|
||||
@@ -58,9 +58,8 @@
|
||||
li {
|
||||
font-size: 1.1rem;
|
||||
line-height: 3rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@extend %text-ellipsis;
|
||||
|
||||
&:nth-child(odd) {
|
||||
background-color: var(--main-bg, #ffffff);
|
||||
|
||||
@@ -63,9 +63,7 @@
|
||||
}
|
||||
|
||||
> a {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@include text-ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,8 @@
|
||||
|
||||
> div:first-child {
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@extend %text-ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Post-specific style
|
||||
*/
|
||||
/**
|
||||
* Post-specific styles
|
||||
*/
|
||||
|
||||
%btn-post-nav {
|
||||
width: 50%;
|
||||
@@ -97,7 +97,7 @@ header {
|
||||
|
||||
&:hover {
|
||||
i {
|
||||
@extend %btn-share-hovor;
|
||||
@extend %btn-share-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,7 @@ header {
|
||||
}
|
||||
}
|
||||
|
||||
/* TOC panel */
|
||||
#toc-wrapper {
|
||||
border-left: 1px solid rgba(158, 158, 158, 0.17);
|
||||
position: -webkit-sticky;
|
||||
@@ -257,9 +258,8 @@ header {
|
||||
|
||||
.toc-link {
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@extend %text-ellipsis;
|
||||
|
||||
&:hover {
|
||||
color: var(--toc-highlight);
|
||||
@@ -290,6 +290,209 @@ header {
|
||||
}
|
||||
}
|
||||
|
||||
/* --- TOC button, bar and popup in mobile/tablet --- */
|
||||
|
||||
#toc-bar {
|
||||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
margin: 0 -1rem;
|
||||
height: $topbar-height;
|
||||
background: var(--main-bg);
|
||||
border-bottom: 1px solid var(--main-border-color);
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
@extend %btn-color;
|
||||
|
||||
.label {
|
||||
@extend %heading;
|
||||
|
||||
margin-left: 0.25rem;
|
||||
padding: 0 0.75rem;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
&.invisible {
|
||||
top: -$topbar-height;
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
#toc-solo-trigger {
|
||||
color: var(--text-muted-color);
|
||||
border-color: var(--btn-border-color);
|
||||
border-radius: $radius-lg;
|
||||
|
||||
.label {
|
||||
font-size: 1rem;
|
||||
font-family: $font-family-heading;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
box-shadow: none;
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin slide-in {
|
||||
from {
|
||||
opacity: 0.7;
|
||||
transform: translateY(-$topbar-height);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@mixin slide-out {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(-$topbar-height);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes slide-in {
|
||||
@include slide-in;
|
||||
}
|
||||
|
||||
@keyframes slide-in {
|
||||
@include slide-in;
|
||||
}
|
||||
|
||||
@-webkit-keyframes slide-out {
|
||||
@include slide-out;
|
||||
}
|
||||
|
||||
@keyframes slide-out {
|
||||
@include slide-out;
|
||||
}
|
||||
|
||||
#toc-popup {
|
||||
$slide-in: slide-in 0.3s ease-out;
|
||||
$slide-out: slide-out 0.3s ease-out;
|
||||
$curtain-height: 2rem;
|
||||
$backdrop: blur(5px);
|
||||
|
||||
border-color: var(--toc-popup-border-color);
|
||||
border-width: 1px;
|
||||
border-radius: $radius-lg;
|
||||
color: var(--text-color);
|
||||
background: var(--card-bg);
|
||||
margin-top: $topbar-height;
|
||||
min-width: 20rem;
|
||||
font-size: 1.05rem;
|
||||
|
||||
@media all and (min-width: 576px) {
|
||||
max-width: 32rem;
|
||||
}
|
||||
|
||||
&[open] {
|
||||
-webkit-animation: $slide-in;
|
||||
animation: $slide-in;
|
||||
}
|
||||
|
||||
&[closing] {
|
||||
-webkit-animation: $slide-out;
|
||||
animation: $slide-out;
|
||||
}
|
||||
|
||||
@media all and (min-width: 850px) {
|
||||
left: $sidebar-width;
|
||||
}
|
||||
|
||||
.header {
|
||||
@extend %btn-color;
|
||||
|
||||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: inherit;
|
||||
border-bottom: 1px solid var(--main-border-color);
|
||||
|
||||
.label {
|
||||
font-family: $font-family-heading;
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
> i {
|
||||
font-size: 1.25rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
|
||||
li {
|
||||
ul,
|
||||
& + li {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
line-height: 1.5;
|
||||
padding: 0.375rem 0;
|
||||
padding-right: 1.125rem;
|
||||
|
||||
&.toc-link::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@for $i from 2 through 4 {
|
||||
.node-name--H#{$i} {
|
||||
padding-left: 1.125rem * ($i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
.is-active-link {
|
||||
color: var(--toc-highlight) !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&::-webkit-backdrop {
|
||||
-webkit-backdrop-filter: $backdrop;
|
||||
backdrop-filter: $backdrop;
|
||||
}
|
||||
|
||||
&::backdrop {
|
||||
-webkit-backdrop-filter: $backdrop;
|
||||
backdrop-filter: $backdrop;
|
||||
}
|
||||
|
||||
&::after {
|
||||
display: flex;
|
||||
content: '';
|
||||
position: relative;
|
||||
background: linear-gradient(transparent, var(--card-bg) 70%);
|
||||
height: $curtain-height;
|
||||
}
|
||||
|
||||
#toc-popup-content {
|
||||
overflow: auto;
|
||||
max-height: calc(100vh - 4 * $topbar-height);
|
||||
font-family: $font-family-heading;
|
||||
margin-bottom: -$curtain-height;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Related Posts --- */
|
||||
|
||||
#related-posts {
|
||||
@@ -305,10 +508,11 @@ header {
|
||||
}
|
||||
|
||||
p {
|
||||
@extend %text-ellipsis;
|
||||
|
||||
font-size: 0.9rem;
|
||||
margin-bottom: 0.5rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: break-spaces;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
@@ -328,9 +532,10 @@ header {
|
||||
|
||||
.utterances {
|
||||
max-width: 100%;
|
||||
min-height: 269px;
|
||||
}
|
||||
|
||||
%btn-share-hovor {
|
||||
%btn-share-hover {
|
||||
color: var(--btn-share-hover-color) !important;
|
||||
}
|
||||
|
||||
@@ -362,9 +567,20 @@ header {
|
||||
/* Hide SideBar and TOC */
|
||||
@media all and (max-width: 849px) {
|
||||
.post-navigation {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
margin-left: -0.5rem;
|
||||
margin-right: -0.5rem;
|
||||
@include pl-pr(0);
|
||||
@include ml-mr(-0.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (min-width: 1200px) {
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
scroll-margin-top: 2rem;
|
||||
}
|
||||
|
||||
#toc-bar,
|
||||
#toc-solo-trigger {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ permalink: /feed.xml
|
||||
<updated>{{ post.date | date_to_xmlschema }}</updated>
|
||||
{% endif %}
|
||||
<id>{{ post_absolute_url }}</id>
|
||||
<content src="{{ post_absolute_url }}" />
|
||||
<content type="text/html" src="{{ post_absolute_url }}" />
|
||||
<author>
|
||||
<name>{{ post.author | default: site.social.name }}</name>
|
||||
</author>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [7.1.1](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v7.1.0...v7.1.1) (2024-09-23)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **i18n:** correct fr-FR translations ([#1949](https://github.com/cotes2020/jekyll-theme-chirpy/issues/1949)) ([367262e](https://github.com/cotes2020/jekyll-theme-chirpy/commit/367262e74d1005bddf1328bb2b3a2b9e152c0086))
|
||||
* **pwa:** site baseurl not passed to `app.js` ([#1955](https://github.com/cotes2020/jekyll-theme-chirpy/issues/1955)) ([5a63244](https://github.com/cotes2020/jekyll-theme-chirpy/commit/5a63244721d21b1ad3a0ae83420723a2f0379e8b))
|
||||
|
||||
## [7.1.0](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v7.0.1...v7.1.0) (2024-08-27)
|
||||
|
||||
### Features
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "jekyll-theme-chirpy"
|
||||
spec.version = "7.1.0"
|
||||
spec.version = "7.1.1"
|
||||
spec.authors = ["Cotes Chung"]
|
||||
spec.email = ["cotes.chung@gmail.com"]
|
||||
|
||||
|
||||
18
package.json
18
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jekyll-theme-chirpy",
|
||||
"version": "7.1.0",
|
||||
"version": "7.1.1",
|
||||
"description": "A minimal, responsive, and feature-rich Jekyll theme for technical writing.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -30,23 +30,23 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/plugin-transform-class-properties": "^7.25.4",
|
||||
"@babel/plugin-transform-private-methods": "^7.25.7",
|
||||
"@babel/preset-env": "^7.25.4",
|
||||
"@commitlint/cli": "^19.4.0",
|
||||
"@commitlint/config-conventional": "^19.2.2",
|
||||
"@commitlint/cli": "^19.5.0",
|
||||
"@commitlint/config-conventional": "^19.5.0",
|
||||
"@rollup/plugin-babel": "^6.0.4",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-yaml": "^4.1.2",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"concurrently": "^8.2.2",
|
||||
"concurrently": "^9.0.1",
|
||||
"conventional-changelog-conventionalcommits": "^8.0.0",
|
||||
"husky": "^9.1.5",
|
||||
"husky": "^9.1.6",
|
||||
"purgecss": "^6.0.0",
|
||||
"rollup": "^4.21.0",
|
||||
"semantic-release": "^24.1.0",
|
||||
"stylelint": "^16.8.2",
|
||||
"rollup": "^4.21.3",
|
||||
"semantic-release": "^24.1.1",
|
||||
"stylelint": "^16.9.0",
|
||||
"stylelint-config-standard-scss": "^13.1.0"
|
||||
},
|
||||
"prettier": {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import babel from '@rollup/plugin-babel';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import yaml from '@rollup/plugin-yaml';
|
||||
import fs from 'fs';
|
||||
import pkg from './package.json';
|
||||
|
||||
@@ -35,27 +34,34 @@ function insertFrontmatter() {
|
||||
};
|
||||
}
|
||||
|
||||
function build(filename, { src = SRC_DEFAULT, jekyll = false } = {}) {
|
||||
function build(
|
||||
filename,
|
||||
{ src = SRC_DEFAULT, jekyll = false, outputName = null } = {}
|
||||
) {
|
||||
const input = `${src}/${filename}.js`;
|
||||
|
||||
return {
|
||||
input: `${src}/${filename}.js`,
|
||||
input,
|
||||
output: {
|
||||
file: `${DIST}/${filename}.min.js`,
|
||||
format: 'iife',
|
||||
name: 'Chirpy',
|
||||
...(outputName !== null && { name: outputName }),
|
||||
banner,
|
||||
sourcemap: !isProd
|
||||
sourcemap: !isProd && !jekyll
|
||||
},
|
||||
watch: {
|
||||
include: `${src}/**`
|
||||
include: input
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
presets: ['@babel/env'],
|
||||
plugins: ['@babel/plugin-transform-class-properties']
|
||||
plugins: [
|
||||
'@babel/plugin-transform-class-properties',
|
||||
'@babel/plugin-transform-private-methods'
|
||||
]
|
||||
}),
|
||||
nodeResolve(),
|
||||
yaml(),
|
||||
isProd && terser(),
|
||||
jekyll && insertFrontmatter()
|
||||
]
|
||||
@@ -71,6 +77,7 @@ export default [
|
||||
build('page'),
|
||||
build('post'),
|
||||
build('misc'),
|
||||
build('theme', { src: `${SRC_DEFAULT}/modules`, outputName: 'Theme' }),
|
||||
build('app', { src: SRC_PWA, jekyll: true }),
|
||||
build('sw', { src: SRC_PWA, jekyll: true })
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user