@clarusjs/content 0.2.2 → 0.2.3

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/dist/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { Source } from 'clarusjs/vite';
2
+ /**
3
+ * `markdown()`'s options: the layout, components for blocks, code copy and quizzes, and frontmatter schemas.
4
+ * @see https://clarusjs.com/reference/content#markdown
5
+ */
2
6
  export type MarkdownOptions = {
3
7
  /** The layout every page renders in, root-relative (`/src/layouts/docs.tscl`). Frontmatter `layout` overrides it; `false` means none. */
4
8
  layout?: string | false;
@@ -36,7 +40,10 @@ export type MarkdownOptions = {
36
40
  */
37
41
  schema?: StandardSchema | Record<string, StandardSchema>;
38
42
  };
39
- /** The Standard Schema interface (https://standardschema.dev), as much of it as validating frontmatter needs. */
43
+ /**
44
+ * The Standard Schema interface (https://standardschema.dev), as much of it as validating frontmatter needs.
45
+ * @see https://clarusjs.com/reference/content#markdown
46
+ */
40
47
  export type StandardSchema<Output = unknown> = {
41
48
  readonly '~standard': {
42
49
  readonly version: 1;
@@ -55,7 +62,30 @@ type StandardResult<Output> = {
55
62
  }>;
56
63
  }>;
57
64
  };
58
- /** 'Hello, World!' → 'hello-world'. Shared by heading ids and (later) link checking. */
65
+ /**
66
+ * 'Hello, World!' → 'hello-world'. Shared by heading ids and (later) link checking.
67
+ * @example
68
+ * ```ts
69
+ * slugify('Getting started!') // 'getting-started'
70
+ * ```
71
+ * @see https://clarusjs.com/reference/content#slugify
72
+ */
59
73
  export declare function slugify(text: string): string;
74
+ /**
75
+ * Markdown pages as a page source: `src/pages/**\/*.md` become pages, rendered in your layout, with frontmatter, headings
76
+ * with anchors, highlighted code, `::: tip` blocks, components imported at the top, and (in lessons) quizzes.
77
+ * Build-time only: nothing of it reaches the browser.
78
+ * @example
79
+ * ```ts
80
+ * // vite.config.ts
81
+ * import clarusjs from 'clarusjs/vite'
82
+ * import markdown from '@clarusjs/content'
83
+ *
84
+ * export default defineConfig({
85
+ * plugins: [clarusjs({ sources: [markdown({ layout: '/src/layouts/docs.tscl' })] })],
86
+ * })
87
+ * ```
88
+ * @see https://clarusjs.com/reference/content#markdown
89
+ */
60
90
  export default function markdown(options?: MarkdownOptions): Source;
61
91
  export {};
package/dist/index.js CHANGED
@@ -159,7 +159,7 @@ function renderer(options) {
159
159
  const q = meta;
160
160
  if (!options.quiz)
161
161
  return `<div class="quiz" data-quiz="${q.name}">`;
162
- tags.push(`<${options.quiz.tag} [name]="${quote(q.name)}" [question]="${escapeHtml(quote(title))}" [options]="[${q.options.map((o) => escapeHtml(quote(o))).join(', ')}]" [answer]="${q.answer}">`);
162
+ tags.push(`<${options.quiz.tag} [name]="${quote(q.name)}" [question]="${quote(title)}" [options]="[${q.options.map(quote).join(', ')}]" [answer]="${q.answer}">`);
163
163
  return `<!--cl-tag-${tags.length - 1}-->`;
164
164
  }
165
165
  if (options.container) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clarusjs/content",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Markdown pages for clarusjs: frontmatter, layouts, components in Markdown, rendered to static HTML at build time.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "peerDependencies": {
22
- "clarusjs": "^0.9.0"
22
+ "clarusjs": "^0.10.0"
23
23
  },
24
24
  "engines": {
25
25
  "node": "^22.12.0 || ^24.0.0 || >=26.0.0"
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@types/markdown-it": "^14.2.0",
52
52
  "@types/node": "^26.6.6",
53
- "clarusjs": "^0.9.0",
53
+ "clarusjs": "^0.10.0",
54
54
  "typescript": "^7.0.2",
55
55
  "vite": "^8.3.8",
56
56
  "vitest": "^5.1.1"