contentbit 0.7.1 → 0.7.2

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
@@ -27,6 +27,12 @@ contentbit init --seo
27
27
  contentbit agents
28
28
  ```
29
29
 
30
+ Astro init creates a self-contained `/example` route without editing the
31
+ project's content collections. Integrate `content/` into an existing collection
32
+ deliberately, or use
33
+ [`astro-speedrun-seo`](https://github.com/agonist/astro-speedrun-seo) as the
34
+ production-shaped reference template.
35
+
30
36
  Everyday commands:
31
37
 
32
38
  ```bash
package/dist/bin.js CHANGED
@@ -22007,7 +22007,9 @@ function astroPage(styled) {
22007
22007
  return `---
22008
22008
  import { genericBlocks } from '@contentbit/blocks'
22009
22009
  import { assertValidDocument, compileDocument, createBlockRegistry } from '@contentbit/core'
22010
- import { getEntry } from 'astro:content'
22010
+ // Vite's ?raw import keeps this example independent from the host project's
22011
+ // content collections. See astro-speedrun-seo for a production collection.
22012
+ import source from '../../content/example.md?raw'
22011
22013
 
22012
22014
  ${importLine}
22013
22015
 
@@ -22015,13 +22017,9 @@ ${importLine}
22015
22017
  import customBlocks from '../../blocks/registry'
22016
22018
  import QuoteBlock from '../../blocks/QuoteBlock.astro'
22017
22019
 
22018
- // Entry ids are the file path relative to the collection base, minus ".md".
22019
- const entry = await getEntry('articles', 'example')
22020
- if (!entry?.body) throw new Error('Entry "example" not found in the articles collection.')
22021
-
22022
22020
  const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
22023
22021
  // Static pages render at build time, so invalid blocks fail the build here.
22024
- const document = assertValidDocument(compileDocument(entry.body, registry), entry.id)
22022
+ const document = assertValidDocument(compileDocument(source, registry), 'content/example.md')
22025
22023
  ---
22026
22024
 
22027
22025
  <main style="max-width: 42rem; margin: 0 auto; padding: 3rem 1.5rem;">
@@ -22061,25 +22059,17 @@ async function createAstroPlan(ctx) {
22061
22059
  const files = [["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]];
22062
22060
  const componentsJsonPath = join3(ctx.cwd, "components.json");
22063
22061
  const styled = !ctx.noStyled && existsSync2(componentsJsonPath) && await ctx.installStyledPack("@contentbit/astro-pack");
22064
- const configCandidates = ["ts", "mts", "mjs", "js"].flatMap((ext) => [
22065
- `src/content.config.${ext}`,
22066
- `src/content/config.${ext}`
22067
- ]);
22068
- const existingConfig = configCandidates.find((p) => existsSync2(join3(ctx.cwd, p)));
22069
- if (existingConfig) {
22070
- ctx.io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
22071
- ctx.io.stdout(ASTRO_CONTENT_CONFIG);
22072
- ctx.io.stdout('the example page expects the "articles" collection above');
22073
- } else {
22074
- files.push(["src/content.config.ts", ASTRO_CONTENT_CONFIG]);
22075
- }
22076
22062
  if (!ctx.noPage) files.push(["src/pages/example.astro", astroPage(styled)]);
22063
+ const nextSteps = ctx.noPage ? [
22064
+ " 2. Wire content/ into your Astro content collection and render it with @contentbit/astro."
22065
+ ] : [" 2. Start the dev server and open /example to see the article rendered."];
22066
+ nextSteps.push(
22067
+ " 3. Production Astro reference: https://github.com/agonist/astro-speedrun-seo",
22068
+ " 4. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22069
+ );
22077
22070
  return {
22078
22071
  files,
22079
- nextSteps: [
22080
- " 2. Start the dev server and open /example to see the article rendered.",
22081
- " 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22082
- ]
22072
+ nextSteps
22083
22073
  };
22084
22074
  }
22085
22075
  function detectTarget(deps) {
@@ -22087,7 +22077,7 @@ function detectTarget(deps) {
22087
22077
  const hasAstro = Boolean(deps.astro);
22088
22078
  return hasAstro ? "astro" : hasReact ? "react" : "markdown";
22089
22079
  }
22090
- var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_CONTENT_CONFIG, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22080
+ var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22091
22081
  var init_init_targets = __esm({
22092
22082
  "src/commands/init-targets.ts"() {
22093
22083
  "use strict";
@@ -22122,18 +22112,6 @@ export default async function ExamplePage() {
22122
22112
  </main>
22123
22113
  )
22124
22114
  }
22125
- `;
22126
- ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
22127
- import { glob } from 'astro/loaders'
22128
-
22129
- export const collections = {
22130
- articles: defineCollection({
22131
- // Astro's builtin Markdown loader. Entry bodies are parsed and validated
22132
- // where they render (see src/pages/example.astro); \`contentbit validate\`
22133
- // covers the same files in CI.
22134
- loader: glob({ pattern: '**/*.md', base: './content' }),
22135
- }),
22136
- }
22137
22115
  `;
22138
22116
  ASTRO_QUOTE_BLOCK = `---
22139
22117
  // The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
@@ -22286,7 +22264,7 @@ async function initCommand(input, io) {
22286
22264
  initialValue: detected,
22287
22265
  options: [
22288
22266
  { value: "react", label: "React", hint: "ContentBlocks component" },
22289
- { value: "astro", label: "Astro", hint: "content collections + .astro components" },
22267
+ { value: "astro", label: "Astro", hint: "standalone .astro example" },
22290
22268
  { value: "markdown", label: "Plain Markdown", hint: "fallback rendering only" }
22291
22269
  ]
22292
22270
  });
@@ -22341,7 +22319,6 @@ async function initCommand(input, io) {
22341
22319
  md,
22342
22320
  noPage: Boolean(input.noPage),
22343
22321
  noStyled: Boolean(input.noStyled),
22344
- io,
22345
22322
  installStyledPack: (pack) => installStyledPack(cwd, pack, Boolean(input.noInstall), io)
22346
22323
  });
22347
22324
  const files = [
@@ -22441,6 +22418,8 @@ export default [quote] satisfies BlockDefinition<unknown>[]
22441
22418
  `;
22442
22419
  EXAMPLE_CONTENT = `---
22443
22420
  slug: hello-content-blocks
22421
+ type: article
22422
+ intent: learn the contentbit authoring workflow
22444
22423
  linksTo:
22445
22424
  - related-contentbit-workflows
22446
22425
  aliases:
@@ -22474,6 +22453,8 @@ weaves flowers and leaves.
22474
22453
  `;
22475
22454
  RELATED_CONTENT = `---
22476
22455
  slug: related-contentbit-workflows
22456
+ type: article
22457
+ intent: learn the contentbit validation workflow
22477
22458
  linksTo:
22478
22459
  - hello-content-blocks
22479
22460
  keywords:
@@ -22497,6 +22478,10 @@ stays as the rename record.
22497
22478
 
22498
22479
  export default defineSeoConfig({
22499
22480
  pageTypes: {
22481
+ article: {
22482
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22483
+ minOutgoingLinks: 1,
22484
+ },
22500
22485
  alternative: {
22501
22486
  requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22502
22487
  requiredSections: [
@@ -1,4 +1,3 @@
1
- import type { Io } from '../run.js';
2
1
  export type Target = 'react' | 'markdown' | 'astro';
3
2
  export type Md = 'react-markdown' | 'none';
4
3
  export declare const TARGETS: Target[];
@@ -13,7 +12,6 @@ interface InitTargetContext {
13
12
  md: Md;
14
13
  noPage: boolean;
15
14
  noStyled: boolean;
16
- io: Io;
17
15
  installStyledPack: (pack: string) => Promise<boolean>;
18
16
  }
19
17
  interface InitTargetAdapter {
@@ -1 +1 @@
1
- {"version":3,"file":"init-targets.d.ts","sourceRoot":"","sources":["../../src/commands/init-targets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAA;AACnD,MAAM,MAAM,EAAE,GAAG,gBAAgB,GAAG,MAAM,CAAA;AAE1C,eAAO,MAAM,OAAO,EAAE,MAAM,EAAmC,CAAA;AAE/D,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAEnD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,UAAU,iBAAiB;IACzB,GAAG,EAAE,MAAM,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M,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACtD;AAED,UAAU,iBAAiB;IACzB,eAAe,EAAE,EAAE,EAAE,CAAA;IACrB,mBAAmB,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAA;IACrC,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAC5D;AAqQD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAoB7D,CAAA;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAIjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AA0OnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgLlF"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAkPnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+KlF"}
package/dist/run.js CHANGED
@@ -22006,7 +22006,9 @@ function astroPage(styled) {
22006
22006
  return `---
22007
22007
  import { genericBlocks } from '@contentbit/blocks'
22008
22008
  import { assertValidDocument, compileDocument, createBlockRegistry } from '@contentbit/core'
22009
- import { getEntry } from 'astro:content'
22009
+ // Vite's ?raw import keeps this example independent from the host project's
22010
+ // content collections. See astro-speedrun-seo for a production collection.
22011
+ import source from '../../content/example.md?raw'
22010
22012
 
22011
22013
  ${importLine}
22012
22014
 
@@ -22014,13 +22016,9 @@ ${importLine}
22014
22016
  import customBlocks from '../../blocks/registry'
22015
22017
  import QuoteBlock from '../../blocks/QuoteBlock.astro'
22016
22018
 
22017
- // Entry ids are the file path relative to the collection base, minus ".md".
22018
- const entry = await getEntry('articles', 'example')
22019
- if (!entry?.body) throw new Error('Entry "example" not found in the articles collection.')
22020
-
22021
22019
  const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
22022
22020
  // Static pages render at build time, so invalid blocks fail the build here.
22023
- const document = assertValidDocument(compileDocument(entry.body, registry), entry.id)
22021
+ const document = assertValidDocument(compileDocument(source, registry), 'content/example.md')
22024
22022
  ---
22025
22023
 
22026
22024
  <main style="max-width: 42rem; margin: 0 auto; padding: 3rem 1.5rem;">
@@ -22060,25 +22058,17 @@ async function createAstroPlan(ctx) {
22060
22058
  const files = [["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]];
22061
22059
  const componentsJsonPath = join3(ctx.cwd, "components.json");
22062
22060
  const styled = !ctx.noStyled && existsSync2(componentsJsonPath) && await ctx.installStyledPack("@contentbit/astro-pack");
22063
- const configCandidates = ["ts", "mts", "mjs", "js"].flatMap((ext) => [
22064
- `src/content.config.${ext}`,
22065
- `src/content/config.${ext}`
22066
- ]);
22067
- const existingConfig = configCandidates.find((p) => existsSync2(join3(ctx.cwd, p)));
22068
- if (existingConfig) {
22069
- ctx.io.stdout(`content config exists (${existingConfig}); add this collection manually:`);
22070
- ctx.io.stdout(ASTRO_CONTENT_CONFIG);
22071
- ctx.io.stdout('the example page expects the "articles" collection above');
22072
- } else {
22073
- files.push(["src/content.config.ts", ASTRO_CONTENT_CONFIG]);
22074
- }
22075
22061
  if (!ctx.noPage) files.push(["src/pages/example.astro", astroPage(styled)]);
22062
+ const nextSteps = ctx.noPage ? [
22063
+ " 2. Wire content/ into your Astro content collection and render it with @contentbit/astro."
22064
+ ] : [" 2. Start the dev server and open /example to see the article rendered."];
22065
+ nextSteps.push(
22066
+ " 3. Production Astro reference: https://github.com/agonist/astro-speedrun-seo",
22067
+ " 4. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22068
+ );
22076
22069
  return {
22077
22070
  files,
22078
- nextSteps: [
22079
- " 2. Start the dev server and open /example to see the article rendered.",
22080
- " 3. Styled components: pnpm dlx shadcn@latest add @contentbit/astro-pack"
22081
- ]
22071
+ nextSteps
22082
22072
  };
22083
22073
  }
22084
22074
  function detectTarget(deps) {
@@ -22086,7 +22076,7 @@ function detectTarget(deps) {
22086
22076
  const hasAstro = Boolean(deps.astro);
22087
22077
  return hasAstro ? "astro" : hasReact ? "react" : "markdown";
22088
22078
  }
22089
- var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_CONTENT_CONFIG, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22079
+ var TARGETS, RUNTIME_BASE, TANSTACK_PAGE, NEXT_PAGE, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
22090
22080
  var init_init_targets = __esm({
22091
22081
  "src/commands/init-targets.ts"() {
22092
22082
  "use strict";
@@ -22121,18 +22111,6 @@ export default async function ExamplePage() {
22121
22111
  </main>
22122
22112
  )
22123
22113
  }
22124
- `;
22125
- ASTRO_CONTENT_CONFIG = `import { defineCollection } from 'astro:content'
22126
- import { glob } from 'astro/loaders'
22127
-
22128
- export const collections = {
22129
- articles: defineCollection({
22130
- // Astro's builtin Markdown loader. Entry bodies are parsed and validated
22131
- // where they render (see src/pages/example.astro); \`contentbit validate\`
22132
- // covers the same files in CI.
22133
- loader: glob({ pattern: '**/*.md', base: './content' }),
22134
- }),
22135
- }
22136
22114
  `;
22137
22115
  ASTRO_QUOTE_BLOCK = `---
22138
22116
  // The Astro component for the custom \`quote\` block defined in blocks/registry.ts.
@@ -22285,7 +22263,7 @@ async function initCommand(input, io) {
22285
22263
  initialValue: detected,
22286
22264
  options: [
22287
22265
  { value: "react", label: "React", hint: "ContentBlocks component" },
22288
- { value: "astro", label: "Astro", hint: "content collections + .astro components" },
22266
+ { value: "astro", label: "Astro", hint: "standalone .astro example" },
22289
22267
  { value: "markdown", label: "Plain Markdown", hint: "fallback rendering only" }
22290
22268
  ]
22291
22269
  });
@@ -22340,7 +22318,6 @@ async function initCommand(input, io) {
22340
22318
  md,
22341
22319
  noPage: Boolean(input.noPage),
22342
22320
  noStyled: Boolean(input.noStyled),
22343
- io,
22344
22321
  installStyledPack: (pack) => installStyledPack(cwd, pack, Boolean(input.noInstall), io)
22345
22322
  });
22346
22323
  const files = [
@@ -22440,6 +22417,8 @@ export default [quote] satisfies BlockDefinition<unknown>[]
22440
22417
  `;
22441
22418
  EXAMPLE_CONTENT = `---
22442
22419
  slug: hello-content-blocks
22420
+ type: article
22421
+ intent: learn the contentbit authoring workflow
22443
22422
  linksTo:
22444
22423
  - related-contentbit-workflows
22445
22424
  aliases:
@@ -22473,6 +22452,8 @@ weaves flowers and leaves.
22473
22452
  `;
22474
22453
  RELATED_CONTENT = `---
22475
22454
  slug: related-contentbit-workflows
22455
+ type: article
22456
+ intent: learn the contentbit validation workflow
22476
22457
  linksTo:
22477
22458
  - hello-content-blocks
22478
22459
  keywords:
@@ -22496,6 +22477,10 @@ stays as the rename record.
22496
22477
 
22497
22478
  export default defineSeoConfig({
22498
22479
  pageTypes: {
22480
+ article: {
22481
+ requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22482
+ minOutgoingLinks: 1,
22483
+ },
22499
22484
  alternative: {
22500
22485
  requiredFrontmatter: ['type', 'intent', 'keywords.primary'],
22501
22486
  requiredSections: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentbit",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "CLI for Content Blocks: validate, render, and generate LLM authoring instructions from your registry.",
5
5
  "keywords": [
6
6
  "cli",
@@ -38,15 +38,15 @@
38
38
  "@clack/prompts": "^1.5.1",
39
39
  "commander": "^15.0.0",
40
40
  "tinyglobby": "^0.2.10",
41
- "@contentbit/blocks": "0.7.1",
42
- "@contentbit/core": "0.7.1"
41
+ "@contentbit/blocks": "0.7.2",
42
+ "@contentbit/core": "0.7.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^25.0.9",
46
46
  "esbuild": "^0.28.0",
47
47
  "typescript": "^5.9.3",
48
48
  "vitest": "^4.0.17",
49
- "@contentbit/studio": "0.7.1"
49
+ "@contentbit/studio": "0.7.2"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=22.18"