Class: Ucode::Site::ConfigEmitter
- Inherits:
-
Object
- Object
- Ucode::Site::ConfigEmitter
- Includes:
- Repo::AtomicWrites
- Defined in:
- lib/ucode/site/config_emitter.rb
Overview
Writes ‘site/.vitepress/config.ts` from the JSON output tree.
Reads:
output/planes/<n>.json → top nav (17 planes)
output/blocks/index.json → sidebar groups (one per plane)
Writes:
site/.vitepress/config.ts — TypeScript module that exports the
Vitepress `defineConfig` payload. Idempotent via AtomicWrites.
Pure: reads JSON, writes TS. No Vitepress dependency on the Ruby side; the site is a thin shell that imports this generated config and re-exports ‘defineConfig(config)`.
Instance Method Summary collapse
-
#emit ⇒ Boolean
Read the output tree, render config.ts, write atomically.
-
#initialize(output_root:, site_root:) ⇒ ConfigEmitter
constructor
A new instance of ConfigEmitter.
-
#target_path ⇒ Pathname
The config file path that #emit writes.
Methods included from Repo::AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(output_root:, site_root:) ⇒ ConfigEmitter
Returns a new instance of ConfigEmitter.
28 29 30 31 |
# File 'lib/ucode/site/config_emitter.rb', line 28 def initialize(output_root:, site_root:) @output_root = Pathname.new(output_root) @site_root = Pathname.new(site_root) end |
Instance Method Details
#emit ⇒ Boolean
Read the output tree, render config.ts, write atomically.
40 41 42 |
# File 'lib/ucode/site/config_emitter.rb', line 40 def emit write_atomic(target_path, render(load_planes, load_blocks)) end |
#target_path ⇒ Pathname
Returns the config file path that #emit writes.
34 35 36 |
# File 'lib/ucode/site/config_emitter.rb', line 34 def target_path @site_root.join(".vitepress", "config.ts") end |