mirror of
https://github.com/quartz-community/fonts.git
synced 2026-07-22 03:00:28 +00:00
2.8 KiB
2.8 KiB
Architecture Reference
Machine-readable architecture overview for the Quartz community plugin template.
Plugin Lifecycle
Quartz plugins are factory functions that return an object with a name and lifecycle hooks.
- Loading: Quartz imports the plugin from the
externalPluginslist inquartz.config.ts. - Initialization: The factory function is called with user-provided options.
- Build Integration:
- Transformers: Run during the
transformphase (remark/rehype). - Filters: Run after transformation to prune the content list.
- Emitters: Run during the
emitphase to generate files. - Page Types: Run to generate virtual pages or custom routes.
- Components: Rendered during the HTML generation phase.
- Transformers: Run during the
Build System
The template uses tsup for bundling and declaration output.
- Inline Scripts: Files ending in
.inline.tsare bundled as raw strings for client-side injection. - Styles:
.scssfiles are compiled to CSS strings and attached to components viaComponent.css. - Entry Points:
index.ts: Main plugin exports.types.ts: Shared type definitions.components/index.ts: UI component exports.
Type System
The template relies on @quartz-community/types for core Quartz types.
- Branded Types:
FullSlugandFilePathare used for path safety. - vfile DataMap: Augmented with
QuartzPluginDatafor plugin-specific metadata. - Plugin Interfaces:
QuartzTransformerPlugin,QuartzFilterPlugin,QuartzEmitterPlugin,QuartzPageTypePlugin,QuartzComponentConstructor.
Export Conventions
- Default Exports: Used for components.
- Named Exports: Used for plugin factories and types.
- Re-exports:
src/index.tsre-exports all public APIs.
Dependency Management
- peerDependencies:
preact,vfile, and@jackyzha0/quartz(optional). - dependencies:
@quartz-community/types,@quartz-community/utils. - devDependencies: Build tools, linters, and test runners.
Testing Infrastructure
- vitest: Test runner.
- test helpers: Mock
BuildCtxandProcessedContentfor plugin testing.
CI/CD Pipeline
- GitHub Actions: Runs
npm run checkon PRs and publishes to npm on version tags (v*).
Directory Structure
src/: Source code.components/: UI components.scripts/: Client-side scripts (.inline.ts).styles/: Component styles (.scss).
i18n/: Internationalization.util/: Utility functions.index.ts: Main entry point.types.ts: Type definitions.transformer.ts: Transformer implementation.filter.ts: Filter implementation.emitter.ts: Emitter implementation.
dist/: Build output.package.json: Manifest and dependencies.tsup.config.ts: Build configuration.