@aerobuilt/content 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ // src/processor.ts
2
+ import { remark } from "remark";
3
+ import remarkRehype from "remark-rehype";
4
+ import rehypeStringify from "rehype-stringify";
5
+ if (!globalThis.__aeroProcessorState) {
6
+ globalThis.__aeroProcessorState = {
7
+ processor: null,
8
+ initialized: false
9
+ };
10
+ }
11
+ function applyPlugins(pipeline, plugins) {
12
+ for (const entry of plugins) {
13
+ if (Array.isArray(entry)) {
14
+ const [plugin, ...options] = entry;
15
+ pipeline = pipeline.use(plugin, ...options);
16
+ } else {
17
+ pipeline = pipeline.use(entry);
18
+ }
19
+ }
20
+ return pipeline;
21
+ }
22
+ function createProcessor(remarkPlugins = [], rehypePlugins = []) {
23
+ let pipeline = remark();
24
+ pipeline = applyPlugins(pipeline, remarkPlugins);
25
+ pipeline = pipeline.use(remarkRehype);
26
+ pipeline = applyPlugins(pipeline, rehypePlugins);
27
+ return pipeline.use(rehypeStringify);
28
+ }
29
+ async function initProcessor(config) {
30
+ globalThis.__aeroProcessorState.processor = createProcessor(
31
+ config?.remarkPlugins ?? [],
32
+ config?.rehypePlugins ?? []
33
+ );
34
+ globalThis.__aeroProcessorState.initialized = true;
35
+ }
36
+ function getProcessor() {
37
+ if (!globalThis.__aeroProcessorState.processor) {
38
+ globalThis.__aeroProcessorState.processor = createProcessor();
39
+ globalThis.__aeroProcessorState.initialized = true;
40
+ }
41
+ return globalThis.__aeroProcessorState.processor;
42
+ }
43
+ function resetProcessor() {
44
+ globalThis.__aeroProcessorState.processor = null;
45
+ globalThis.__aeroProcessorState.initialized = false;
46
+ }
47
+
48
+ export {
49
+ initProcessor,
50
+ getProcessor,
51
+ resetProcessor
52
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getProcessor
3
- } from "./chunk-5EPOOVMT.js";
3
+ } from "./chunk-3GJWVG5N.js";
4
4
 
5
5
  // src/render.ts
6
6
  async function render(doc) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a as ContentCollectionConfig, b as ContentConfig, C as ContentDocument, c as ContentMeta, d as defineCollection, e as defineConfig } from './types-BxvX8bzG.js';
2
- export { ShikiConfig } from '@aerobuilt/highlight';
1
+ export { a as ContentCollectionConfig, b as ContentConfig, C as ContentDocument, c as ContentMeta, M as MarkdownConfig, d as defineCollection, e as defineConfig } from './types-D4g4HdAa.js';
3
2
  export { render } from './render.js';
3
+ import 'unified';
4
4
  import 'zod';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  render
3
- } from "./chunk-DHKNQV3I.js";
4
- import "./chunk-5EPOOVMT.js";
3
+ } from "./chunk-VZVJXSM5.js";
4
+ import "./chunk-3GJWVG5N.js";
5
5
 
6
6
  // src/types.ts
7
7
  function defineCollection(config) {
@@ -1,5 +1,5 @@
1
- import { C as ContentDocument } from './types-BxvX8bzG.js';
2
- import '@aerobuilt/highlight';
1
+ import { C as ContentDocument } from './types-D4g4HdAa.js';
2
+ import 'unified';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/markdown.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getProcessor
3
- } from "./chunk-5EPOOVMT.js";
3
+ } from "./chunk-3GJWVG5N.js";
4
4
 
5
5
  // src/markdown.ts
6
6
  async function compileMarkdown(document) {
@@ -1,17 +1,28 @@
1
- import { ShikiConfig } from '@aerobuilt/highlight';
2
1
  import { Processor } from 'unified';
2
+ import { M as MarkdownConfig } from './types-D4g4HdAa.js';
3
+ import 'zod';
3
4
 
4
5
  /**
5
- * Shared markdown processor: remark pipeline with optional Shiki syntax highlighting.
6
+ * Shared markdown processor: unified rehype pipeline with pluggable remark and rehype plugins.
6
7
  *
7
8
  * @remarks
8
9
  * Both `compileMarkdown` (eager, for transforms) and `render` (lazy, for pages) delegate to
9
- * this module. Call `initProcessor(shikiConfig)` once at startup (from the Vite plugin) to
10
- * enable Shiki; omit the config for plain `remark-html` output (backward compatible).
10
+ * this module. Call `initProcessor(config)` once at startup (from the Vite plugin) to
11
+ * configure the pipeline. The pipeline is always rehype-based:
12
+ *
13
+ * `remark` -> `[remarkPlugins]` -> `remark-rehype` -> `[rehypePlugins]` -> `rehype-stringify`
11
14
  *
12
15
  * The processor is created lazily on first use if `initProcessor` was never called.
13
16
  */
14
17
 
18
+ /**
19
+ * Processor config: remark and rehype plugin arrays.
20
+ *
21
+ * @remarks
22
+ * Mirrors the `markdown` slice of `ContentConfig` so that the processor does not
23
+ * depend on the full config shape.
24
+ */
25
+ type ProcessorConfig = MarkdownConfig;
15
26
  declare global {
16
27
  var __aeroProcessorState: {
17
28
  processor: Processor | null;
@@ -23,21 +34,20 @@ declare global {
23
34
  *
24
35
  * @remarks
25
36
  * Call once at startup (typically from the Vite plugin's configResolved hook) before any
26
- * markdown compilation occurs. If `shikiConfig` is provided, code blocks in markdown
27
- * will be syntax-highlighted. If omitted, plain `<pre><code>` output is produced.
37
+ * markdown compilation occurs. Pass remark/rehype plugins to extend the pipeline (e.g.
38
+ * add `@shikijs/rehype` or `rehype-pretty-code` for syntax highlighting).
28
39
  *
29
40
  * Safe to call multiple times — subsequent calls replace the processor.
30
41
  *
31
- * @param shikiConfig - Optional Shiki configuration. Omit for plain HTML output.
42
+ * @param config - Optional markdown plugin configuration.
32
43
  */
33
- declare function initProcessor(shikiConfig?: ShikiConfig): Promise<void>;
44
+ declare function initProcessor(config?: ProcessorConfig): Promise<void>;
34
45
  /**
35
46
  * Get the shared markdown processor.
36
47
  *
37
48
  * @remarks
38
49
  * Returns the processor created by `initProcessor`. If `initProcessor` was never called,
39
- * lazily creates the plain remark-html fallback (backward compat for direct imports of
40
- * `compileMarkdown` or `render` without going through the Vite plugin).
50
+ * lazily creates a default processor (no plugins).
41
51
  *
42
52
  * @returns The unified processor instance.
43
53
  */
@@ -47,4 +57,4 @@ declare function getProcessor(): Processor;
47
57
  */
48
58
  declare function resetProcessor(): void;
49
59
 
50
- export { getProcessor, initProcessor, resetProcessor };
60
+ export { type ProcessorConfig, getProcessor, initProcessor, resetProcessor };
package/dist/processor.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  getProcessor,
3
3
  initProcessor,
4
4
  resetProcessor
5
- } from "./chunk-5EPOOVMT.js";
5
+ } from "./chunk-3GJWVG5N.js";
6
6
  export {
7
7
  getProcessor,
8
8
  initProcessor,
package/dist/render.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ContentDocument } from './types-BxvX8bzG.js';
2
- import '@aerobuilt/highlight';
1
+ import { C as ContentDocument } from './types-D4g4HdAa.js';
2
+ import 'unified';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/render.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  render
3
- } from "./chunk-DHKNQV3I.js";
4
- import "./chunk-5EPOOVMT.js";
3
+ } from "./chunk-VZVJXSM5.js";
4
+ import "./chunk-3GJWVG5N.js";
5
5
  export {
6
6
  render
7
7
  };
@@ -1,6 +1,13 @@
1
- import * as _aerobuilt_highlight from '@aerobuilt/highlight';
1
+ import { Pluggable } from 'unified';
2
2
  import { ZodType } from 'zod';
3
3
 
4
+ /**
5
+ * Content package types: document metadata, collection config, and define helpers.
6
+ *
7
+ * @remarks
8
+ * Used by the loader (frontmatter + body → ContentDocument), by content.config.ts (defineCollection, defineConfig), and by the Vite plugin.
9
+ */
10
+
4
11
  /** Metadata attached to every content document (path, slug, filename, extension). */
5
12
  interface ContentMeta {
6
13
  /** Path relative to the collection directory (no extension). */
@@ -36,20 +43,32 @@ interface ContentCollectionConfig<TSchema extends Record<string, any> = Record<s
36
43
  /** Optional async transform after validation; receives document, returns final shape. */
37
44
  transform?: (document: ContentDocument<TSchema>) => TOutput | Promise<TOutput>;
38
45
  }
39
- /** Top-level content config: array of collection definitions with optional highlighting. */
46
+ /**
47
+ * Markdown pipeline configuration: custom remark and rehype plugins.
48
+ *
49
+ * @remarks
50
+ * The pipeline is: `remark` -> `[remarkPlugins]` -> `remark-rehype` -> `[rehypePlugins]` -> `rehype-stringify`.
51
+ * Add syntax highlighting (e.g. `@shikijs/rehype`, `rehype-pretty-code`) as a rehype plugin.
52
+ */
53
+ interface MarkdownConfig {
54
+ /** Remark plugins to apply before the remark-to-rehype bridge. */
55
+ remarkPlugins?: Pluggable[];
56
+ /** Rehype plugins to apply after remark-rehype and before rehype-stringify. */
57
+ rehypePlugins?: Pluggable[];
58
+ }
59
+ /** Top-level content config: array of collection definitions with optional markdown pipeline plugins. */
40
60
  interface ContentConfig {
41
61
  collections: ContentCollectionConfig<any, any>[];
42
62
  /**
43
- * Optional syntax highlighting configuration for markdown code blocks.
44
- * Nest under `highlight.shiki` to use Shiki-powered highlighting.
45
- * When omitted, plain `<pre><code>` output is produced (backward compatible).
63
+ * Custom remark and rehype plugins for the markdown pipeline.
46
64
  *
47
- * @see https://shiki.style/guide
65
+ * @remarks
66
+ * The pipeline is always rehype-based:
67
+ * `remark` -> `[remarkPlugins]` -> `remark-rehype` -> `[rehypePlugins]` -> `rehype-stringify`.
68
+ * Without any rehype plugins, code blocks render as plain `<pre><code>`.
69
+ * Add `@shikijs/rehype` or `rehype-pretty-code` as a rehype plugin for syntax highlighting.
48
70
  */
49
- highlight?: {
50
- /** Shiki configuration. Uses Shiki's native `theme`/`themes` options. */
51
- shiki: _aerobuilt_highlight.ShikiConfig;
52
- };
71
+ markdown?: MarkdownConfig;
53
72
  }
54
73
  /**
55
74
  * Define a content collection (typed helper for content.config.ts).
@@ -61,9 +80,9 @@ declare function defineCollection<TSchema extends Record<string, any> = Record<s
61
80
  /**
62
81
  * Define the content config (typed helper for content.config.ts).
63
82
  *
64
- * @param config - Config with `collections` array.
83
+ * @param config - Config with `collections` array and optional `markdown` pipeline plugins.
65
84
  * @returns The same config (unchanged).
66
85
  */
67
86
  declare function defineConfig(config: ContentConfig): ContentConfig;
68
87
 
69
- export { type ContentDocument as C, type ContentCollectionConfig as a, type ContentConfig as b, type ContentMeta as c, defineCollection as d, defineConfig as e };
88
+ export { type ContentDocument as C, type MarkdownConfig as M, type ContentCollectionConfig as a, type ContentConfig as b, type ContentMeta as c, defineCollection as d, defineConfig as e };
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  initProcessor
3
- } from "./chunk-5EPOOVMT.js";
3
+ } from "./chunk-3GJWVG5N.js";
4
4
 
5
5
  // src/loader.ts
6
6
  import fg from "fast-glob";
@@ -113,7 +113,7 @@ function aeroContent(options = {}) {
113
113
  );
114
114
  contentConfig = mod.default;
115
115
  watchedDirs = getWatchedDirs(contentConfig, root);
116
- await initProcessor(contentConfig.highlight?.shiki);
116
+ await initProcessor(contentConfig.markdown);
117
117
  } catch (err) {
118
118
  if (err.code === "ERR_MODULE_NOT_FOUND" || err.code === "ENOENT") {
119
119
  config.logger.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerobuilt/content",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Jamie Wilson",
@@ -42,12 +42,9 @@
42
42
  "fast-glob": "^3.3.3",
43
43
  "gray-matter": "^4.0.3",
44
44
  "remark": "^15.0.1",
45
- "remark-html": "^16.0.1",
46
45
  "remark-rehype": "^11.0.0",
47
46
  "rehype-stringify": "^10.0.0",
48
- "@shikijs/rehype": "^3.0.0",
49
- "unified": "^11.0.0",
50
- "@aerobuilt/highlight": "0.2.7"
47
+ "unified": "^11.0.0"
51
48
  },
52
49
  "peerDependencies": {
53
50
  "vite": "^8.0.0-0",
@@ -62,6 +59,7 @@
62
59
  }
63
60
  },
64
61
  "devDependencies": {
62
+ "@shikijs/rehype": "^3.0.0",
65
63
  "@shikijs/transformers": "^3.0.0",
66
64
  "@types/node": "^25.3.0",
67
65
  "tsup": "^8.5.1",
@@ -1,67 +0,0 @@
1
- // src/processor.ts
2
- import { remark } from "remark";
3
- import remarkHtml from "remark-html";
4
- if (!globalThis.__aeroProcessorState) {
5
- globalThis.__aeroProcessorState = {
6
- processor: null,
7
- initialized: false
8
- };
9
- }
10
- function createPlainProcessor() {
11
- return remark().use(remarkHtml);
12
- }
13
- function extractThemeOptions(config) {
14
- if ("theme" in config && config.theme) {
15
- return { theme: config.theme };
16
- }
17
- if ("themes" in config && config.themes) {
18
- const opts = { themes: config.themes };
19
- if ("defaultColor" in config && config.defaultColor !== void 0) {
20
- opts.defaultColor = config.defaultColor;
21
- }
22
- if ("cssVariablePrefix" in config && config.cssVariablePrefix !== void 0) {
23
- opts.cssVariablePrefix = config.cssVariablePrefix;
24
- }
25
- if ("colorsRendering" in config && config.colorsRendering !== void 0) {
26
- opts.colorsRendering = config.colorsRendering;
27
- }
28
- return opts;
29
- }
30
- return {};
31
- }
32
- async function createShikiProcessor(config) {
33
- const { getHighlighter } = await import("@aerobuilt/highlight");
34
- const remarkRehype = (await import("remark-rehype")).default;
35
- const rehypeShikiFromHighlighter = (await import("@shikijs/rehype/core")).default;
36
- const rehypeStringify = (await import("rehype-stringify")).default;
37
- const highlighter = await getHighlighter(config);
38
- return remark().use(remarkRehype).use(rehypeShikiFromHighlighter, highlighter, {
39
- ...extractThemeOptions(config),
40
- transformers: config.transformers ?? []
41
- }).use(rehypeStringify);
42
- }
43
- async function initProcessor(shikiConfig) {
44
- if (shikiConfig) {
45
- globalThis.__aeroProcessorState.processor = await createShikiProcessor(shikiConfig);
46
- } else {
47
- globalThis.__aeroProcessorState.processor = createPlainProcessor();
48
- }
49
- globalThis.__aeroProcessorState.initialized = true;
50
- }
51
- function getProcessor() {
52
- if (!globalThis.__aeroProcessorState.processor) {
53
- globalThis.__aeroProcessorState.processor = createPlainProcessor();
54
- globalThis.__aeroProcessorState.initialized = true;
55
- }
56
- return globalThis.__aeroProcessorState.processor;
57
- }
58
- function resetProcessor() {
59
- globalThis.__aeroProcessorState.processor = null;
60
- globalThis.__aeroProcessorState.initialized = false;
61
- }
62
-
63
- export {
64
- initProcessor,
65
- getProcessor,
66
- resetProcessor
67
- };