mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
♻️ Refactor: custom.js rendering and remove params.customJS
This commit is contained in:
@@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
|
||||
- :wheelchair: Feat(accessibility): use `aria-hidden=true` on icons that AT should ignore
|
||||
- :recycle: Refactor: image rendering
|
||||
- :recycle: Refactor: back to top and scroll to comments
|
||||
- :recycle: Refactor: custom.js rendering and remove `params.customJS` ([#189](https://github.com/hugo-fixit/FixIt/pull/189))
|
||||
- :bug: Fix: add function `dos2unix` to unify new lines symbol between Windows and Unix/Mac OS
|
||||
- :bug: Fix: author display error in post and markdown file
|
||||
- :bug: Fix: use data attributes or class replace for custom attributes
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
* Custom javascript for FixIt site.
|
||||
* @author @Lruihao https://lruihao.cn
|
||||
* @description Custom javascript for the hugo theme FixIt.
|
||||
*/
|
||||
const CustomJS = new (function () {
|
||||
const FixItCustom = new (function () {
|
||||
/**
|
||||
* Hello World
|
||||
* You can define your own functions below.
|
||||
* @returns {CustomJS}
|
||||
* @returns {FixItCustom}
|
||||
*/
|
||||
this.hello = () => {
|
||||
// console.log('Hello CustomJS!');
|
||||
console.log('FixItCustom echo: Hello FixIt!');
|
||||
return this;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Initialize.
|
||||
* @returns {CustomJS}
|
||||
* @returns {FixItCustom}
|
||||
*/
|
||||
this.init = () => {
|
||||
// Custom infos.
|
||||
@@ -27,9 +27,9 @@ const CustomJS = new (function () {
|
||||
* Immediate.
|
||||
*/
|
||||
(() => {
|
||||
CustomJS.init();
|
||||
FixItCustom.init();
|
||||
// It will be executed when the DOM tree is built.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// console.log('DOM content loaded!')
|
||||
// FixItCustom.init();
|
||||
});
|
||||
})();
|
||||
+1
-7
@@ -664,13 +664,7 @@
|
||||
polyfill = false
|
||||
# whether to use object-fit-images to be compatible with older browsers
|
||||
objectFit = false
|
||||
|
||||
# FixIt 0.2.12 | NEW Custom JS at last
|
||||
# "_custom.js" located in "themes/FixIt/assets/js/"
|
||||
# you can store your custom JS file in the same path under your project:
|
||||
# "assets/js/_custom.js"
|
||||
[params.customJS]
|
||||
enable = true
|
||||
|
||||
# FixIt 0.2.14 | NEW GitHub banner in the top-right or top-left corner
|
||||
[params.githubCorner]
|
||||
enable = false
|
||||
|
||||
+1
-1
Submodule docs updated: 997258619c...c63bb5cc07
@@ -235,8 +235,8 @@
|
||||
{{- $options := dict -}}
|
||||
{{- $options = dict "targetPath" "service-worker.min.js" | merge $options -}}
|
||||
{{- $options = dict "minify" true | merge $options -}}
|
||||
{{- $js := resources.Get "js/service-worker.js" | js.Build $options -}}
|
||||
{{- $_ := $js.RelPermalink -}}
|
||||
{{- $source := resources.Get "js/service-worker.js" | js.Build $options -}}
|
||||
{{- $_ := $source.RelPermalink -}}
|
||||
{{- $config = dict "enablePWA" .Site.Params.enablePWA | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -263,9 +263,8 @@
|
||||
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
|
||||
|
||||
{{- /* Custom script */ -}}
|
||||
{{- if eq .Site.Params.customJS.enable true -}}
|
||||
{{- $source := "js/_custom.js" -}}
|
||||
{{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- with ((resources.Get "js/custom.js") | default (resources.Get "js/_custom.js")) -}}
|
||||
{{- dict "Source" .RelPermalink "Minify" true "Fingerprint" $fingerprint "Defer" true | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with (.Scratch.Get "this").scriptArr -}}
|
||||
|
||||
Reference in New Issue
Block a user