mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
6f83bc6da5
- 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
3.2 KiB
3.2 KiB
FixIt Coding Standards and Guidelines
This document defines the detailed coding standards for the FixIt theme project. For project overview, architecture, and development commands, see CLAUDE.md.
SCSS Coding Standards
Naming
- CSS classes: BEM or semantic naming (
header-desktop,menu-item,post-tag) - SCSS variables: hyphen-separated, semantic (
$global-font-family,$code-background-color) - CSS custom properties: prefixed with
fi-/--fi-
SCSS Guidelines
- Use 2-space indentation
- Use CSS variables for theme switching support
- Prefer relative units (rem, em, %) over absolute units
- Use SCSS variables for colors — no hardcoded values
- Keep selector nesting shallow
TypeScript Coding Standards
Architecture
Service-class architecture with direct constructor calls:
TypedEventBus(core/event-bus.ts) — Module-level singleton (eventBus) wrapping DOMCustomEventswith typed event map.- Service interfaces (
core/tokens.ts) — Typed contracts for each module (CoreService,ThemeService,CodeService, etc.). - Module classes (
modules/*.ts) — Each module implements its service interface. Dependencies are constructor-injected.
Module Pattern
export class ExampleModule implements ExampleService {
#privateState: any // ES6 # private fields, not _ prefix
constructor(private readonly core: CoreService) {}
publicMethod(): void { /* ... */ }
#privateHelper(): void { /* ... */ }
}
Key Rules
- Use ES6
#private fields — not TypeScriptprivatewith_prefix - Keep modules focused: one module per file, one service interface per module
- Import the shared
eventBussingleton fromcore/event-busfor cross-module communication - Constructor injection for dependencies — no global state access
window.fixitexposes a typed public API (FixItPublicAPI) for user custom scripts- Comment style: follow TSDoc conventions
Utilities
- Pure functions only in
utils/— no side effects, no DOM state - Re-export everything through
utils/index.ts
Hugo Template Standards
Conventions
- Variable naming: camelCase (
$footerConfig,$fingerprint) - Comments: Hugo syntax
{{- /* comment */ -}} - Translation: Use
Tfunction for i18n ({{ T "header.switchTheme" }}) - Whitespace: Use
{{- -}}trim markers to control whitespace output
Hugo Template Guidelines
- Use
partialCachedfor expensive partials that don't change per page - Use
.Site.Storefor shared computed values (e.g. fingerprint) - Check
hugo.IsProductionbefore adding analytics or minification
Git Workflow
Commit Convention
Follows Conventional Commits:
<type>(<scope>): <subject>
Types: feat, fix, refactor, chore, docs, perf, style, test, ci, build
Scopes: workflow, archetypes, assets, i18n, layouts, config, or specific directories.
Pre-commit Hooks
Pre-commit runs: versioning (dev mode), typecheck, lint-staged (eslint --fix on staged files).
Browser Compatibility
- Target modern browsers
- Use progressive enhancement for advanced features
- Prefer feature detection over browser detection