summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authoramzrk22020-06-01 15:44:04 +0800
committeramzrk22020-06-01 15:44:04 +0800
commit02c3891865c7741b8f772aea75cc01564d2f0ff4 (patch)
treedb0e4dd8c3ef95181f5e665ca09f731b75de0387 /layouts
parent2338da969d3bc1b2bc26df9f7192dd20a0906c5b (diff)
downloadhugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.tar.gz
hugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.tar.bz2
hugo-theme-fuji-02c3891865c7741b8f772aea75cc01564d2f0ff4.zip
Remove jQuery
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/partials/head.html7
-rw-r--r--layouts/partials/scripts-end.html9
-rw-r--r--layouts/partials/scripts-front.html19
4 files changed, 18 insertions, 19 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index a61499c..4a2a490 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -5,7 +5,7 @@
{{ partial "head.html" . }}
</head>
-<body data-theme="{{ .Site.Params.toggleMode }}">
+<body data-theme="auto">
{{ partial "scripts-front.html" . }}
{{ partial "header.html" . }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 7141a40..bf6e1bf 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -33,12 +33,7 @@
{{ template "_internal/twitter_cards.html" . }}
<!-- dep -->
-{{ $sass := resources.Get "scss/fuji.scss" }}
-{{ $options := (dict "targetPath" "assets/css/fuji.min.css" "outputStyle" "compressed" "enableSourceMap" true) }}
-{{ $style := $sass | resources.ToCSS $options }}
-<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
-
-<script data-cfasync="false" src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
+<link rel="stylesheet" href="{{ "/assets/css/fuji.min.css" | relURL }}" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/amzrk2/web-font-archive@1.4.5/font-awesome/fontawesome.min.css" />
{{ if .Params.playerURL }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css" />
diff --git a/layouts/partials/scripts-end.html b/layouts/partials/scripts-end.html
index 1e02812..99f9e9e 100644
--- a/layouts/partials/scripts-end.html
+++ b/layouts/partials/scripts-end.html
@@ -1,8 +1,8 @@
<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.2.2/lazysizes.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.5/dist/medium-zoom.min.js"></script>
+<script src="{{ "/assets/js/fuji.min.js" | relURL }}"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.20.0/components/prism-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.20.0/plugins/autoloader/prism-autoloader.min.js"></script>
-<script src="{{ "/assets/js/fuji.js" | relURL }}"></script>
{{ with .Params.playerURL }}
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
@@ -19,5 +19,12 @@
cover: '{{ $.Params.playerCover }}'
}]
});
+ // aplayer toc anchors fix
+ // see https://github.com/MoePlayer/APlayer/issues/242#issuecomment-602471423
+ document.addEventListener('DOMContentLoaded', function () {
+ var issueTocEle = document.querySelector('.sidebar-toc');
+ var newTocEle = issueTocEle.cloneNode(true);
+ issueTocEle.parentNode.replaceChild(newTocEle, issueTocEle);
+ });
</script>
{{ end }} \ No newline at end of file
diff --git a/layouts/partials/scripts-front.html b/layouts/partials/scripts-front.html
index 9425769..c516aad 100644
--- a/layouts/partials/scripts-front.html
+++ b/layouts/partials/scripts-front.html
@@ -1,16 +1,13 @@
<script data-cfasync="false">
// detect theme data in localStorage
- // if diff change the data-theme attribute of body
- var fujiThemeData = localStorage.getItem('fuji_theme');
- if (fujiThemeData) {
- if ($('body').attr('data-theme') !== fujiThemeData) {
- $('body').attr('data-theme', (index, attr) => {
- if (fujiThemeData === 'dark') {
- return 'dark';
- } else {
- return 'light';
- }
- });
+ var fujiThemeData = localStorage.getItem('fuji_data-theme');
+ // if first look, set theme mode to auto
+ if (!fujiThemeData) {
+ localStorage.setItem('fuji_data-theme', 'auto');
+ } else {
+ // if not auto mode, change the data-theme attribute of body
+ if (fujiThemeData !== 'auto') {
+ document.body.setAttribute('data-theme', fujiThemeData === 'dark' ? 'dark' : 'light');
}
}
</script>