refactor: restructure TypeScript modules and search config

- Create PublicAPI class to encapsulate module initialization
- Move search config types to modules/search/types.ts
- Rename ui.ts to global.ts for clarity
- Simplify pagefind engine (remove normalizeSortOrder, toObject)
- Move pagefind config to top-level in FixItConfig
- Add TSDoc comments and @param tags
- Update PagefindConfig.sortOrder type to 'asc' | 'desc'
- Improve pagefind detection warning message
This commit is contained in:
Cell
2026-06-18 16:09:16 +08:00
parent 01eadc4356
commit 6f83bc6da5
21 changed files with 211 additions and 210 deletions
+3 -2
View File
@@ -10,7 +10,7 @@ This document defines the detailed coding standards for the FixIt theme project.
- **SCSS variables**: hyphen-separated, semantic (`$global-font-family`, `$code-background-color`)
- **CSS custom properties**: prefixed with `fi-` / `--fi-`
### Guidelines
### SCSS Guidelines
- Use 2-space indentation
- Use CSS variables for theme switching support
@@ -48,6 +48,7 @@ export class ExampleModule implements ExampleService {
- Import the shared `eventBus` singleton from `core/event-bus` for cross-module communication
- Constructor injection for dependencies — no global state access
- `window.fixit` exposes a typed public API (`FixItPublicAPI`) for user custom scripts
- Comment style: follow [TSDoc](https://tsdoc.org/) conventions
### Utilities
@@ -63,7 +64,7 @@ export class ExampleModule implements ExampleService {
- **Translation**: Use `T` function for i18n (`{{ T "header.switchTheme" }}`)
- **Whitespace**: Use `{{- -}}` trim markers to control whitespace output
### Guidelines
### Hugo Template Guidelines
- Use `partialCached` for expensive partials that don't change per page
- Use `.Site.Store` for shared computed values (e.g. fingerprint)