mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
📝 Docs: add documentation for customJS option
This commit is contained in:
@@ -9,7 +9,7 @@ const CustomJS = new (function () {
|
||||
* @returns {CustomJS}
|
||||
*/
|
||||
this.hello = () => {
|
||||
console.log('Hello CustomJS!');
|
||||
// console.log('Hello CustomJS!');
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@@ -30,6 +30,6 @@ const CustomJS = new (function () {
|
||||
CustomJS.init();
|
||||
// It will be executed when the DOM tree is built.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
console.log('DOM content loaded!')
|
||||
// console.log('DOM content loaded!')
|
||||
});
|
||||
})();
|
||||
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
const CustomJS=new function(){this.hello=(()=>(console.log("Hello CustomJS!"),this)),this.init=(()=>(this.hello(),this))};CustomJS.init(),document.addEventListener("DOMContentLoaded",()=>{console.log("DOM content loaded!")});
|
||||
@@ -976,9 +976,6 @@ enableEmoji = true
|
||||
# "assets/js/_custom.js"
|
||||
[params.customJS]
|
||||
enable = true
|
||||
# Use "_custom.min.js" in the same path
|
||||
# 使用同目录下的压缩文件 "_custom.min.js"
|
||||
minify = true
|
||||
|
||||
# Markup related configuration in Hugo
|
||||
# Hugo 解析文档的配置
|
||||
|
||||
@@ -696,8 +696,15 @@ Please open the code block below to view the complete sample configuration :(far
|
||||
polyfill = false
|
||||
# whether to use object-fit-images to be compatible with older browsers
|
||||
objectFit = false
|
||||
|
||||
# {{< version 0.2.12 >}} 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
|
||||
|
||||
# Markup related config in Hugo
|
||||
# Markup related configuration in Hugo
|
||||
[markup]
|
||||
# {{< link "https://gohugo.io/content-management/syntax-highlighting" "Syntax Highlighting" >}} (https://gohugo.io/content-management/syntax-highlighting)
|
||||
[markup.highlight]
|
||||
|
||||
@@ -707,6 +707,13 @@ hugo
|
||||
polyfill = false
|
||||
# 是否使用 object-fit-images 来兼容旧式浏览器
|
||||
objectFit = false
|
||||
|
||||
# {{< version 0.2.12 >}} 页面最后添加自定义 JS
|
||||
# "_custom.js" 位于 "themes/FixIt/assets/js" 目录
|
||||
# 可以在你的项目下相同路径存放你自己的自定义 JS 文件:
|
||||
# "assets/js/_custom.js"
|
||||
[params.customJS]
|
||||
enable = true
|
||||
|
||||
# Hugo 解析文档的配置
|
||||
[markup]
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
{{- /* mermaid */ -}}
|
||||
{{- if (.Scratch.Get "this").mermaid -}}
|
||||
{{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" "enableSourceMap" true -}}
|
||||
{{- dict "Source" "lib/mermaid/mermaid.scss" "ToCSS" $options "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
|
||||
{{- end -}}
|
||||
@@ -135,7 +135,7 @@
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
|
||||
{{- $source := $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.min.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- dict "Source" "lib/mapbox-gl/mapbox-gl-language.js" "Minify" true "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- dict "Source" "lib/mapbox-gl/mapbox-gl-language.js" "Minify" true "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- $config = dict "accessToken" $params.mapbox.accessToken "RTLTextPlugin" "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js" | dict "mapbox" | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -218,10 +218,7 @@
|
||||
{{- /* Custom script */ -}}
|
||||
{{- if eq .Site.Params.customJS.enable true -}}
|
||||
{{- $source = "js/_custom.js" -}}
|
||||
{{- if eq .Site.Params.customJS.minify true -}}
|
||||
{{- $source = "js/_custom.min.js" -}}
|
||||
{{- end -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- dict "Source" $source "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