mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
4b3f33f35a
- Add custom.js.example alongside custom.ts.example - Update examples to use window.fixit instead of importing from theme source - Add "Build" true for custom.ts in assets pipeline so esbuild compiles it - Make code_font_family configurable via [params.appearance] in hugo.toml - Standardize SCSS header comments: // → ///, remove Chinese text - Add documented examples in custom.scss: fonts, page width, admonitions, task lists
50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
/**
|
|
* Custom JavaScript for FixIt site.
|
|
*
|
|
* Copy this file to your project's assets/js/ directory
|
|
* and rename it to custom.js to activate it.
|
|
* Access the FixIt public API via `window.fixit`.
|
|
* @see https://fixit.lruihao.cn
|
|
*/
|
|
|
|
const { fixit } = window
|
|
|
|
class CustomScript {
|
|
constructor() {
|
|
this.init()
|
|
}
|
|
|
|
init() {
|
|
console.log('hello from custom.js!')
|
|
console.log('FixIt API:', fixit)
|
|
|
|
// Top-level properties
|
|
console.log('version:', fixit.version)
|
|
console.log('themeMode:', fixit.themeMode)
|
|
console.log('isDark:', fixit.isDark)
|
|
console.log('config:', fixit.config)
|
|
|
|
// Theme control
|
|
// fixit.setThemeMode('dark')
|
|
// fixit.setThemeMode('auto', true) // persist to localStorage
|
|
|
|
// Mask overlay (via core module)
|
|
// fixit.core.registerMaskOverlay('my-overlay', {
|
|
// isActive: () => boolean,
|
|
// onOpen: () => void,
|
|
// onClose: () => void,
|
|
// })
|
|
|
|
// Typed event bus
|
|
fixit.eventBus.on('fixit:switch-theme', ({ detail }) => {
|
|
console.log('Theme switched:', detail.mode, 'isDark:', detail.isDark, 'isChanged:', detail.isChanged)
|
|
})
|
|
|
|
return this
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
void new CustomScript()
|
|
})
|