@ecopages/content-processor 0.2.0-rc.0 → 0.2.0-rc.1

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.
package/README.md CHANGED
@@ -121,32 +121,14 @@ Point `entryType` at the **frontmatter type** (`DocsFrontmatter`), not a hand-ro
121
121
 
122
122
  ## TypeScript setup
123
123
 
124
- Virtual-module types are generated at build/dev time into:
125
-
126
- ```text
127
- node_modules/@types/ecopages-content-processor/virtual-module.d.ts
128
- ```
129
-
130
- Add a root `modules.d.ts` (same pattern as `@ecopages/image-processor`):
124
+ Add one import to the app `modules.d.ts`:
131
125
 
132
126
  ```typescript
133
- /// <reference types="ecopages-content-processor" />
134
-
135
- import '@ecopages/core/declarations';
136
127
  import '@ecopages/content-processor/types';
137
128
  ```
138
129
 
139
- Recommended `tsconfig.json` additions:
140
-
141
- ```json
142
- {
143
- "compilerOptions": {
144
- "baseUrl": ".",
145
- "types": ["bun", "ecopages-content-processor"]
146
- },
147
- "include": ["src", "eco.config.ts", "modules.d.ts", "node_modules/@types/ecopages-content-processor"]
148
- }
149
- ```
130
+ That declares `ecopages:content/*`. Collection modules are generated at dev/build time into
131
+ `node_modules/@types/ecopages-content-processor`, which TypeScript loads automatically.
150
132
 
151
133
  Run `ecopages dev` or `ecopages build` before expecting IDE types. Restart the TypeScript server if types look stale after changing schema or collection config.
152
134
 
@@ -241,7 +223,7 @@ export const docsNav = entries.map((entry) => ({
241
223
  }));
242
224
  ```
243
225
 
244
- Group or sort in your app — for example by a `group` frontmatter field and an `order` number. See `apps/docs` (`src/lib/content-nav.ts`) and `examples/docs-starter` (`src/content-nav.ts`) for full layouts with sections and sidebars.
226
+ Group or sort in your app — for example by a `group` frontmatter field and an `order` number. See `apps/docs` (`src/lib/content-nav.ts`) and `templates/docs-starter` (`src/content-nav.ts`) for full layouts with sections and sidebars.
245
227
 
246
228
  ## Build scripts
247
229
 
@@ -293,11 +275,11 @@ Watch config drives manifest regeneration only. Asset ownership (which would ski
293
275
 
294
276
  ## MDX integration
295
277
 
296
- Content files are MDX components. Ensure your JSX/MDX integration (for example, `@ecopages/ecopages-jsx`) is configured in `eco.config.ts` so `getComponent()` returns a renderable component.
278
+ Content files are MDX components. Ensure your JSX or React integration is configured in `eco.config.ts` with MDX enabled so collection entries compile as components.
297
279
 
298
280
  Content collections with YAML frontmatter need `remark-frontmatter` in the **MDX compile pipeline**. The processor validates frontmatter at scan time (`vfile-matter`); MDX render time needs the remark plugin so `---` blocks are not emitted as content.
299
281
 
300
- Use `@ecopages/content-processor/mdx`:
282
+ Use `@ecopages/content-processor/mdx` on whichever integration compiles the MDX:
301
283
 
302
284
  ```typescript
303
285
  import { withContentMdxPlugins } from '@ecopages/content-processor/mdx';
@@ -312,6 +294,13 @@ ecopagesJsxPlugin({
312
294
  }),
313
295
  },
314
296
  });
297
+
298
+ reactPlugin({
299
+ mdx: {
300
+ enabled: true,
301
+ ...withContentMdxPlugins(),
302
+ },
303
+ });
315
304
  ```
316
305
 
317
306
  `withContentMdxPlugins()` prepends `remarkFrontmatter`. Import it directly when you need finer control:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/content-processor",
3
- "version": "0.2.0-rc.0",
3
+ "version": "0.2.0-rc.1",
4
4
  "description": "Scan MDX collections at build time and expose typed ecopages:content/* virtual modules for pages and scripts",
5
5
  "keywords": [
6
6
  "content",
@@ -17,10 +17,10 @@
17
17
  "directory": "packages/processors/content-processor"
18
18
  },
19
19
  "peerDependencies": {
20
- "@ecopages/core": "0.2.0-rc.0"
20
+ "@ecopages/core": "0.2.0-rc.1"
21
21
  },
22
22
  "dependencies": {
23
- "@ecopages/file-system": "0.2.0-rc.0",
23
+ "@ecopages/file-system": "0.2.0-rc.1",
24
24
  "@ecopages/logger": "^0.2.3",
25
25
  "remark-frontmatter": "^5.0.0",
26
26
  "unified": "^11.0.5",
@@ -37,7 +37,7 @@
37
37
  "types": "./src/plugin.d.ts"
38
38
  },
39
39
  "./types": {
40
- "types": "./src/types.d.ts"
40
+ "types": "./src/content-types.d.ts"
41
41
  },
42
42
  "./mdx": {
43
43
  "default": "./src/mdx.js",
@@ -48,19 +48,12 @@
48
48
  "types": "./src/plugin.d.ts"
49
49
  },
50
50
  "./types.ts": {
51
- "types": "./src/types.d.ts"
51
+ "types": "./src/content-types.d.ts"
52
52
  },
53
53
  "./mdx.ts": {
54
54
  "default": "./src/mdx.js",
55
55
  "types": "./src/mdx.d.ts"
56
56
  }
57
57
  },
58
- "typesVersions": {
59
- "*": {
60
- "ecopages:content/*": [
61
- "./virtual-module.d.ts"
62
- ]
63
- }
64
- },
65
58
  "types": "./src/index.d.ts"
66
59
  }
@@ -0,0 +1,11 @@
1
+ export type {
2
+ ContentCollectionComponentsModule,
3
+ ContentCollectionEntriesModule,
4
+ ContentCollectionModule,
5
+ ContentEntry,
6
+ EntryComparator,
7
+ OrderBy,
8
+ } from './types.js';
9
+
10
+ declare module 'ecopages:content/*' {}
11
+ declare module 'ecopages:content/*/server' {}
package/src/mdx.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import remarkFrontmatter from 'remark-frontmatter';
2
1
  import type { PluggableList } from 'unified';
3
2
  export { default as remarkFrontmatter } from 'remark-frontmatter';
4
3
  export type ContentMdxPluginsOptions = {
@@ -7,6 +6,10 @@ export type ContentMdxPluginsOptions = {
7
6
  /** Rehype plugins for the MDX pipeline. */
8
7
  rehypePlugins?: PluggableList;
9
8
  };
9
+ export type ContentMdxPlugins = {
10
+ remarkPlugins: PluggableList;
11
+ rehypePlugins: PluggableList;
12
+ };
10
13
  /**
11
14
  * Builds MDX plugin options for content collections that use YAML frontmatter.
12
15
  *
@@ -15,7 +18,4 @@ export type ContentMdxPluginsOptions = {
15
18
  * `contentProcessorPlugin()` — the processor validates frontmatter at scan time;
16
19
  * this helper wires the matching MDX remark plugin for render time.
17
20
  */
18
- export declare function withContentMdxPlugins(options?: ContentMdxPluginsOptions): {
19
- remarkPlugins: (typeof remarkFrontmatter | import("unified").Pluggable)[];
20
- rehypePlugins: PluggableList;
21
- };
21
+ export declare function withContentMdxPlugins(options?: ContentMdxPluginsOptions): ContentMdxPlugins;
package/src/plugin.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import path from 'node:path';
6
6
  import { fileSystem } from '@ecopages/file-system';
7
- import { mergeProcessorOptions, Processor, resolveGeneratedPath, } from '@ecopages/core/plugins/processor';
7
+ import { mergeProcessorOptions, Processor, resolveGeneratedPath, writeGeneratedTypesPackage, } from '@ecopages/core/plugins/processor';
8
8
  import { Logger } from '@ecopages/logger';
9
9
  import { renderCollectionComponentsModule, renderCollectionEntriesModule, renderVirtualModuleTypes, } from './codegen.js';
10
10
  import { compareEntriesBySlug } from './sort.js';
@@ -237,6 +237,12 @@ export class ContentProcessorPlugin extends Processor {
237
237
  subPath: 'index.d.ts',
238
238
  });
239
239
  this.writeGeneratedFile(indexTypesDir, 'import "./virtual-module.d.js";\n');
240
+ writeGeneratedTypesPackage({
241
+ root: this.context.rootDir,
242
+ module: this.name,
243
+ packageName: '@types/ecopages-content-processor',
244
+ writeFile: (filePath, content) => this.writeGeneratedFile(filePath, content),
245
+ });
240
246
  }
241
247
  async buildCollectionServerArtifact(collectionName, serverOutputFile, ownedSourcePaths) {
242
248
  if (!this.context?.config.runtime?.buildRuntime) {