@clarusjs/content 0.5.0 → 0.6.0
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 +4 -1
- package/dist/index.js +9 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ import type { Source } from 'clarusjs/vite';
|
|
|
4
4
|
* @see https://clarusjs.com/reference/content#markdown
|
|
5
5
|
*/
|
|
6
6
|
export type MarkdownOptions = {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The layout every page renders in, root-relative (`/src/layouts/docs.tscl`), inside the page's folder and config
|
|
9
|
+
* layouts. Frontmatter `layout` overrides it; `layout: false` there renders the page with no layout at all.
|
|
10
|
+
*/
|
|
8
11
|
layout?: string | false;
|
|
9
12
|
/**
|
|
10
13
|
* Render `::: tip` blocks (and alerts) through your own component: `<tag [type]="'tip'">`, with a custom title in its
|
package/dist/index.js
CHANGED
|
@@ -304,10 +304,14 @@ function renderer(options) {
|
|
|
304
304
|
});
|
|
305
305
|
return md;
|
|
306
306
|
}
|
|
307
|
-
function pageHead(data, title) {
|
|
307
|
+
function pageHead(data, title, bare = false) {
|
|
308
308
|
const tags = [];
|
|
309
309
|
if (data.titleTemplate === false && title !== undefined)
|
|
310
310
|
tags.push(`<title>${escapeHtml(title)}</title>`);
|
|
311
|
+
else if (bare && title !== undefined)
|
|
312
|
+
tags.push(`<title data-cl-template>${escapeHtml(title)}</title>`);
|
|
313
|
+
if (bare && typeof data.description === 'string')
|
|
314
|
+
tags.push(`<meta name="description" content="${escapeHtml(data.description)}">`);
|
|
311
315
|
if (data.sitemap === false)
|
|
312
316
|
tags.push('<meta name="sitemap" content="false">');
|
|
313
317
|
const lastmod = data.lastmod instanceof Date ? data.lastmod.toISOString().slice(0, 10) : typeof data.lastmod === 'string' ? data.lastmod : undefined;
|
|
@@ -442,8 +446,10 @@ export default function markdown(options = {}) {
|
|
|
442
446
|
const h1 = tokens.findIndex((t) => t.type === 'heading_open' && t.tag === 'h1');
|
|
443
447
|
const firstHeading = h1 === -1 ? undefined : (tokens[h1 + 1].children ?? []).filter((t) => t.type === 'text' || t.type === 'code_inline').map((t) => t.content).join('');
|
|
444
448
|
const title = typeof data.title === 'string' ? data.title : firstHeading;
|
|
445
|
-
const
|
|
446
|
-
const
|
|
449
|
+
const layout = data.layout === false ? undefined : typeof data.layout === 'string' ? data.layout : options.layout;
|
|
450
|
+
const html = pageHead(data, title, !layout) + tags.restore(staticHtml(md.renderer.render(tokens, md.options, env)));
|
|
451
|
+
if (data.layout === false)
|
|
452
|
+
return ['@layout none', ...imports, html].join('\n');
|
|
447
453
|
if (!layout)
|
|
448
454
|
return [...imports, html].join('\n');
|
|
449
455
|
const props = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clarusjs/content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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.
|
|
22
|
+
"clarusjs": "^0.17.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.
|
|
53
|
+
"clarusjs": "^0.17.0",
|
|
54
54
|
"typescript": "^7.0.2",
|
|
55
55
|
"vite": "^8.3.8",
|
|
56
56
|
"vitest": "^5.1.1"
|