@riebeckite/honox 0.0.17 → 0.0.19

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.
@@ -1,3 +1,4 @@
1
+ import type { ContentBodySlot, ContentBodySlots } from "@riebeckite/core";
1
2
  export type PrimitiveChildren = unknown;
2
3
  export type PrimitiveProps = {
3
4
  children?: PrimitiveChildren;
@@ -12,6 +13,9 @@ export type ArticleProps = PrimitiveProps & {
12
13
  "data-slot"?: string;
13
14
  };
14
15
  export type ArticleLayoutProps = PrimitiveProps & {
16
+ /**
17
+ * @deprecated Render aside content as children instead.
18
+ */
15
19
  aside?: PrimitiveChildren;
16
20
  };
17
21
  export type ArticleHeaderProps = (PrimitiveClassProps & {
@@ -24,6 +28,10 @@ export type ArticleHeaderProps = (PrimitiveClassProps & {
24
28
  children?: PrimitiveChildren;
25
29
  });
26
30
  export type ArticleContentProps = (PrimitiveClassProps & {
31
+ /**
32
+ * @deprecated Render Markdown HTML with `ArticleBody` inside an
33
+ * `ArticleContent` shell instead.
34
+ */
27
35
  html: string;
28
36
  children?: never;
29
37
  "data-slot"?: string;
@@ -44,5 +52,32 @@ export declare function ArticleLayout(props: ArticleLayoutProps): import("hono/j
44
52
  export declare function ArticleHeader(props: ArticleHeaderProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
45
53
  export declare function ArticleMeta(props: ArticleMetaProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
46
54
  export declare function ArticleContent(props: ArticleContentProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
55
+ export type ArticleBodyProps = PrimitiveClassProps & {
56
+ html: string;
57
+ };
58
+ export type ContentSlotProps = PrimitiveClassProps & {
59
+ slots?: ContentBodySlots;
60
+ name: ContentBodySlot;
61
+ };
62
+ /**
63
+ * Whether a body slot holds renderable content.
64
+ *
65
+ * A slot is absent when its source map is missing, the value is missing, or
66
+ * the value is whitespace-only. This is the same check `ContentSlot` uses.
67
+ */
68
+ export declare function hasSlot(slots: ContentBodySlots | undefined, name: ContentBodySlot): boolean;
69
+ /**
70
+ * Renders a Plugin-provided body slot fragment at the position the Site chose.
71
+ *
72
+ * The Site owns placement; this primitive owns the lookup, empty handling, and
73
+ * HTML injection. It renders nothing when the slot is absent or blank.
74
+ */
75
+ export declare function ContentSlot(props: ContentSlotProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
76
+ /**
77
+ * Renders Markdown-produced HTML as the canonical article body.
78
+ *
79
+ * Owns the `.rb-article-content` Stable Hook so Sites never hand-write it.
80
+ */
81
+ export declare function ArticleBody(props: ArticleBodyProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
47
82
  export declare function ArticleFooter(props: ArticleFooterProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
48
83
  export declare function Sidebar(props: SidebarProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
@@ -68,6 +68,32 @@ function ArticleContent(props) {
68
68
  }
69
69
  return /* @__PURE__ */ jsx("div", { class: className, "data-slot": dataSlot, children: props.children });
70
70
  }
71
+ function hasSlot(slots, name) {
72
+ return Boolean(slots?.[name]?.trim());
73
+ }
74
+ function ContentSlot(props) {
75
+ const html = props.slots?.[props.name];
76
+ if (!html?.trim()) {
77
+ return null;
78
+ }
79
+ return /* @__PURE__ */ jsx(
80
+ "div",
81
+ {
82
+ "data-slot": props.name,
83
+ class: joinClassNames(props.class, props.className) || void 0,
84
+ dangerouslySetInnerHTML: { __html: html }
85
+ }
86
+ );
87
+ }
88
+ function ArticleBody(props) {
89
+ return /* @__PURE__ */ jsx(
90
+ "div",
91
+ {
92
+ class: joinClassNames("rb-article-content", props.class, props.className),
93
+ dangerouslySetInnerHTML: { __html: props.html }
94
+ }
95
+ );
96
+ }
71
97
  function ArticleFooter(props) {
72
98
  return /* @__PURE__ */ jsx(
73
99
  "footer",
@@ -92,10 +118,13 @@ function joinClassNames(...classNames) {
92
118
  }
93
119
  export {
94
120
  Article,
121
+ ArticleBody,
95
122
  ArticleContent,
96
123
  ArticleFooter,
97
124
  ArticleHeader,
98
125
  ArticleLayout,
99
126
  ArticleMeta,
100
- Sidebar
127
+ ContentSlot,
128
+ Sidebar,
129
+ hasSlot
101
130
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,12 +12,6 @@
12
12
  "source": "./index.ts",
13
13
  "default": "./dist/index.js"
14
14
  },
15
- "./scaffold": {
16
- "types": "./dist/src/scaffold/presets.d.ts",
17
- "import": "./dist/src/scaffold/presets.js",
18
- "source": "./src/scaffold/presets.ts",
19
- "default": "./dist/src/scaffold/presets.js"
20
- },
21
15
  "./server": {
22
16
  "types": "./dist/server.d.ts",
23
17
  "import": "./dist/server.js",
@@ -36,11 +30,11 @@
36
30
  "esbuild": "^0.28.2",
37
31
  "hono": "^4.12.25",
38
32
  "vite": "^8.0.9",
39
- "@riebeckite/core": "0.0.17"
33
+ "@riebeckite/core": "0.0.19"
40
34
  },
41
35
  "devDependencies": {
42
36
  "tsx": "^4.22.4",
43
- "@riebeckite/test": "0.0.17"
37
+ "@riebeckite/test": "0.0.19"
44
38
  },
45
39
  "publishConfig": {
46
40
  "access": "public"
@@ -49,7 +43,6 @@
49
43
  "LICENSE",
50
44
  "README.md",
51
45
  "README_ja.md",
52
- "assets",
53
46
  "dist"
54
47
  ],
55
48
  "repository": {
Binary file
Binary file
@@ -1,15 +0,0 @@
1
- import type { ScaffoldPreset } from "./presets.js";
2
- export declare function server(): string;
3
- export declare function client(): string;
4
- export declare function appConfig(): string;
5
- export declare function appContent(): string;
6
- export declare function paths(): string;
7
- export declare function globalDeclarations(): string;
8
- export declare function style(preset: ScaffoldPreset): string;
9
- export declare function siteHeader(): string;
10
- export declare function article(): string;
11
- export declare function renderer(preset: ScaffoldPreset): string;
12
- export declare function bareRenderer(): string;
13
- export declare function indexRoute(preset: ScaffoldPreset): string;
14
- export declare function staticIndexRoute(): string;
15
- export declare function slugRoute(preset: ScaffoldPreset): string;
@@ -1,8 +0,0 @@
1
- import type { SiteTemplateFile } from "./templates.js";
2
- export type ScaffoldDeploymentOptions = {
3
- readonly contentRepository?: string;
4
- readonly siteRepository?: string;
5
- };
6
- export declare function assertGitHubRepository(value: string, option: string): void;
7
- export declare function deploymentTemplateFiles(options: ScaffoldDeploymentOptions): readonly SiteTemplateFile[];
8
- export declare function wranglerJsoncFile(workerName: string): SiteTemplateFile;
@@ -1,26 +0,0 @@
1
- import { type ScaffoldPreset, type ScaffoldPresetName } from "./presets.js";
2
- export type ScaffoldSiteOptions = {
3
- readonly targetDirectory: string;
4
- readonly name?: string;
5
- readonly siteTitle?: string;
6
- readonly description?: string;
7
- readonly baseUrl?: string;
8
- readonly locale?: string;
9
- readonly preset?: ScaffoldPresetName | ScaffoldPreset;
10
- readonly overwrite?: boolean;
11
- /** Generate the Cloudflare Workers GitHub Actions workflow. */
12
- readonly githubActions?: boolean;
13
- readonly cloudflareWorkers?: boolean;
14
- /** Read content from this separate GitHub repository during deployment. */
15
- readonly contentRepository?: string;
16
- /** Site repository to notify from the generated content workflow. */
17
- readonly siteRepository?: string;
18
- };
19
- export type ScaffoldSiteResult = {
20
- readonly targetDirectory: string;
21
- readonly files: readonly string[];
22
- };
23
- export declare class ScaffoldSiteError extends Error {
24
- constructor(message: string);
25
- }
26
- export declare function scaffoldRiebeckiteSite(options: ScaffoldSiteOptions): Promise<ScaffoldSiteResult>;
@@ -1,13 +0,0 @@
1
- import { type ScaffoldPreset } from "./presets.js";
2
- import { type SiteTemplateFile, type SiteTemplateVariables } from "./templates.js";
3
- /**
4
- * Generates the content pages for a scaffold preset.
5
- *
6
- * Localized pages (`index`, `framework/plugins`, `framework/themes`) follow the
7
- * l10n plugin convention: the default-language page keeps the plain name
8
- * (`index.md`) while every other language uses the `<base>.<lang>.md` suffix.
9
- * Presets without l10n emit the index in the site's default language only.
10
- * Extra pages (`guide`, `examples`, `reference/*`) are English-only and are
11
- * suffixed with `.en` when English is not the site's default language.
12
- */
13
- export declare function localizedContentFiles(variables: SiteTemplateVariables, preset: ScaffoldPreset): readonly SiteTemplateFile[];
@@ -1,7 +0,0 @@
1
- export type ScaffoldNextStepsOptions = {
2
- /** First Markdown file to edit, when the scaffold wrote one. */
3
- readonly editFile?: string;
4
- /** The site keeps its content in a separate repository. */
5
- readonly externalContent?: boolean;
6
- };
7
- export declare function formatScaffoldNextSteps(relativeDirectory: string, options?: ScaffoldNextStepsOptions): string;
@@ -1,103 +0,0 @@
1
- /**
2
- * Scaffold presets.
3
- *
4
- * A preset is the declarative description of one starter template. The
5
- * scaffolder consumes a preset to decide which files it generates:
6
- *
7
- * - which plugins are registered in `riebeckite.config.ts`
8
- * - which theme is applied
9
- * - which content pages are emitted (localized, or English-only extras)
10
- * - which `app/` shell files are written
11
- *
12
- * Presets are cumulative in spirit but defined explicitly so each tier is
13
- * self-contained and can be imported and reused on its own:
14
- *
15
- * import { showcase, starter } from "@riebeckite/honox/scaffold";
16
- */
17
- export declare const SCAFFOLD_LANGUAGES: readonly ["en", "ja", "zh-CN", "es", "de", "fr", "ko"];
18
- export type ScaffoldLanguage = (typeof SCAFFOLD_LANGUAGES)[number];
19
- export declare function defaultLanguageForLocale(locale: string): string;
20
- export type ScaffoldPresetName = "starter" | "minimal" | "showcase" | "empty";
21
- export declare const SCAFFOLD_PRESET_NAMES: readonly ScaffoldPresetName[];
22
- export declare function isScaffoldPresetName(value: string): value is ScaffoldPresetName;
23
- /** How a theme factory is referenced in the generated config file. */
24
- export type ScaffoldThemeSpec = {
25
- /** Npm package, for example `@riebeckite/theme-minimal`. */
26
- readonly package: string;
27
- /** Factory/import name, for example `minimalTheme`. */
28
- readonly factory: string;
29
- /** Optional literal source for the factory call arguments, e.g. `{ colorMode: "light" }`. */
30
- readonly options?: string;
31
- };
32
- /** How a plugin factory is referenced in the generated config file. */
33
- export type ScaffoldPluginSpec = {
34
- /** Npm package, for example `@riebeckite/plugin-seo`. */
35
- readonly package: string;
36
- /** Factory/import name, for example `seo`. */
37
- readonly factory: string;
38
- /** Options source for the factory call; see {@link ScaffoldOptions}. */
39
- readonly options?: ScaffoldOptions;
40
- };
41
- /**
42
- * Context passed to option sources. `variables` are the user-supplied site
43
- * values (`title`, `baseUrl`, ...), `languages` the preset's configured
44
- * languages, and configuration detail depth. `showcase` uses depth 3 so its
45
- * generated config is a complete options reference; the other presets keep
46
- * their configuration intentionally small.
47
- */
48
- export type ScaffoldOptionContext = {
49
- readonly variables: {
50
- readonly name: string;
51
- readonly title: string;
52
- readonly description: string;
53
- readonly baseUrl: string;
54
- readonly locale: string;
55
- };
56
- readonly languages: readonly ScaffoldLanguage[];
57
- readonly depth: number;
58
- };
59
- /** A single option value: a literal, or a function of the scaffold context. */
60
- export type ScaffoldOptionValue = string | ((context: ScaffoldOptionContext) => string);
61
- /** A config field gated to a minimum preset depth. */
62
- export type ScaffoldOptionField = {
63
- /** The lowest `ScaffoldOptionContext.depth` that includes this field. */
64
- readonly depth: number;
65
- readonly value: ScaffoldOptionValue;
66
- };
67
- /**
68
- * Options for a generated plugin call: a literal source string, a function
69
- * producing one, or a field map whose fields appear from a minimum depth.
70
- * The field map form lets each preset tier demonstrate the configuration
71
- * surface step by step while keeping one source of truth per plugin.
72
- */
73
- export type ScaffoldOptions = string | ((context: ScaffoldOptionContext) => string) | Readonly<Record<string, ScaffoldOptionField>>;
74
- /** Content pages the scaffold can emit. */
75
- export type ScaffoldPageKey = "index" | "framework/plugins" | "framework/themes" | "guide" | "examples" | "reference/plugins" | "reference/themes";
76
- /** `app/` shell files the scaffold can emit. */
77
- export type ScaffoldAppFileKey = "server" | "client" | "config" | "content" | "paths" | "global" | "style" | "renderer" | "index" | "slug" | "header" | "article";
78
- /** README verbosity. */
79
- export type ScaffoldReadmeLevel = "short" | "standard" | "rich";
80
- export type ScaffoldPreset = {
81
- readonly name: ScaffoldPresetName;
82
- /** One-line human description, shown by `--list-presets`. */
83
- readonly description: string;
84
- /** Languages the l10n plugin is configured with. A single entry means no l10n. */
85
- readonly languages: readonly ScaffoldLanguage[];
86
- readonly theme: ScaffoldThemeSpec | null;
87
- readonly plugins: readonly ScaffoldPluginSpec[];
88
- readonly contentPages: readonly ScaffoldPageKey[];
89
- /**
90
- * Order-sensitive; the scaffolder writes `app/` files in this order.
91
- * Structural files (`server`, `client`, `config`, `content`, `paths`,
92
- * `global`, `style`, `renderer`) are always included.
93
- */
94
- readonly appFiles: readonly ScaffoldAppFileKey[];
95
- readonly readme: ScaffoldReadmeLevel;
96
- };
97
- export declare const empty: ScaffoldPreset;
98
- export declare const minimal: ScaffoldPreset;
99
- export declare const starter: ScaffoldPreset;
100
- export declare const showcase: ScaffoldPreset;
101
- export declare const scaffoldPresets: Readonly<Record<ScaffoldPresetName, ScaffoldPreset>>;
102
- export declare const SCAFFOLD_DEFAULT_PRESET: ScaffoldPresetName;
103
- export declare function resolveScaffoldPreset(value: ScaffoldPresetName | ScaffoldPreset | undefined): ScaffoldPreset;