@analogjs/content 3.0.0-alpha.2 → 3.0.0-alpha.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/LICENSE +21 -0
- package/fesm2022/analogjs-content-og.mjs +34 -46
- package/fesm2022/analogjs-content-prism-highlighter.mjs +81 -68
- package/fesm2022/analogjs-content-resources.mjs +107 -122
- package/fesm2022/analogjs-content-shiki-highlighter.mjs +9 -14
- package/fesm2022/analogjs-content.mjs +735 -618
- package/og/package.json +2 -2
- package/package.json +11 -11
- package/plugin/package.json +1 -1
- package/plugin/src/index.d.ts +1 -1
- package/plugin/src/index.js +3 -1
- package/plugin/src/migrations/update-markdown-renderer-feature/compat.d.ts +2 -1
- package/plugin/src/migrations/update-markdown-renderer-feature/compat.js +4 -2
- package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.d.ts +1 -1
- package/plugin/src/migrations/update-markdown-version/compat.d.ts +2 -1
- package/plugin/src/migrations/update-markdown-version/compat.js +4 -2
- package/plugin/src/migrations/update-markdown-version/update-markdown-version.d.ts +1 -1
- package/prism-highlighter/package.json +2 -2
- package/resources/package.json +2 -2
- package/shiki-highlighter/package.json +2 -2
- package/types/og/src/index.d.ts +2 -0
- package/types/og/src/lib/og.d.ts +5 -0
- package/types/og/src/lib/options.d.ts +11 -0
- package/types/prism-highlighter/src/index.d.ts +8 -0
- package/types/prism-highlighter/src/lib/prism/angular.d.ts +1 -0
- package/types/prism-highlighter/src/lib/prism-highlighter.d.ts +8 -0
- package/types/resources/src/content-file-resource.d.ts +14 -0
- package/types/resources/src/content-files-resource.d.ts +3 -0
- package/types/resources/src/index.d.ts +2 -0
- package/types/shiki-highlighter/src/index.d.ts +7 -0
- package/types/src/index.d.ts +15 -0
- package/types/src/lib/anchor-navigation.directive.d.ts +9 -0
- package/types/src/lib/content-file-loader.d.ts +6 -0
- package/types/src/lib/content-file.d.ts +8 -0
- package/types/src/lib/content-files-list-token.d.ts +3 -0
- package/types/src/lib/content-files-token.d.ts +3 -0
- package/types/src/lib/content-list-loader.d.ts +7 -0
- package/types/src/lib/content-renderer.d.ts +33 -0
- package/types/src/lib/content.d.ts +14 -0
- package/types/src/lib/get-content-files.d.ts +14 -0
- package/types/src/lib/inject-content-files.d.ts +4 -0
- package/types/src/lib/markdown-content-renderer.service.d.ts +10 -0
- package/types/src/lib/markdown-route.component.d.ts +15 -0
- package/types/src/lib/markdown.component.d.ts +26 -0
- package/types/src/lib/marked-content-highlighter.d.ts +17 -0
- package/types/src/lib/marked-setup.service.d.ts +10 -0
- package/types/src/lib/parse-raw-content-file.d.ts +4 -0
- package/types/src/lib/provide-content.d.ts +7 -0
- package/types/src/lib/render-task.service.d.ts +8 -0
- package/types/src/lib/utils/zone-wait-for.d.ts +2 -0
- package/fesm2022/analogjs-content-og.mjs.map +0 -1
- package/fesm2022/analogjs-content-prism-highlighter.mjs.map +0 -1
- package/fesm2022/analogjs-content-resources.mjs.map +0 -1
- package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +0 -1
- package/fesm2022/analogjs-content.mjs.map +0 -1
- package/og/README.md +0 -3
- package/plugin/src/index.js.map +0 -1
- package/plugin/src/migrations/update-markdown-renderer-feature/compat.js.map +0 -1
- package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js.map +0 -1
- package/plugin/src/migrations/update-markdown-version/compat.js.map +0 -1
- package/plugin/src/migrations/update-markdown-version/update-markdown-version.js.map +0 -1
- package/prism-highlighter/README.md +0 -3
- package/resources/README.md +0 -3
- package/shiki-highlighter/README.md +0 -3
- package/types/analogjs-content-og.d.ts +0 -19
- package/types/analogjs-content-prism-highlighter.d.ts +0 -15
- package/types/analogjs-content-resources.d.ts +0 -20
- package/types/analogjs-content-shiki-highlighter.d.ts +0 -11
- package/types/analogjs-content.d.ts +0 -168
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Brandon Roberts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,48 +1,36 @@
|
|
|
1
|
-
import satori from
|
|
2
|
-
import { html } from
|
|
3
|
-
import sharp from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
const svgBuffer = Buffer.from(svg);
|
|
15
|
-
const png = sharp(svgBuffer).png().toBuffer();
|
|
16
|
-
const pngBuffer = await png;
|
|
17
|
-
return pngBuffer;
|
|
1
|
+
import satori from "satori";
|
|
2
|
+
import { html } from "satori-html";
|
|
3
|
+
import sharp from "sharp";
|
|
4
|
+
//#region packages/content/og/src/lib/og.ts
|
|
5
|
+
var generateImage = async (element, options) => {
|
|
6
|
+
const svg = await satori(html(element), {
|
|
7
|
+
width: options.width || 1200,
|
|
8
|
+
height: options.height || 630,
|
|
9
|
+
fonts: options.fonts?.length ? options.fonts : [],
|
|
10
|
+
tailwindConfig: options.tailwindConfig
|
|
11
|
+
});
|
|
12
|
+
return await sharp(Buffer.from(svg)).png().toBuffer();
|
|
18
13
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Generated bundle index. Do not edit.
|
|
45
|
-
*/
|
|
46
|
-
|
|
14
|
+
var ImageResponse = class extends Response {
|
|
15
|
+
constructor(element, options = {}) {
|
|
16
|
+
super();
|
|
17
|
+
const body = new ReadableStream({ async start(controller) {
|
|
18
|
+
const buffer = await generateImage(element, options);
|
|
19
|
+
controller.enqueue(buffer);
|
|
20
|
+
controller.close();
|
|
21
|
+
} });
|
|
22
|
+
return new Response(body, {
|
|
23
|
+
headers: {
|
|
24
|
+
"Content-Type": "image/png",
|
|
25
|
+
"Cache-Control": options.debug ? "no-cache, no-store" : "public, immutable, no-transform, max-age=31536000",
|
|
26
|
+
...options.headers
|
|
27
|
+
},
|
|
28
|
+
status: options.status || 200,
|
|
29
|
+
statusText: options.statusText
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
47
34
|
export { ImageResponse };
|
|
48
|
-
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=analogjs-content-og.mjs.map
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { markedHighlight } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
class PrismHighlighter extends MarkedContentHighlighter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
diff = false;
|
|
24
|
-
console.warn(`Notice:
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable } from "@angular/core";
|
|
3
|
+
import { ContentRenderer, MarkedContentHighlighter, NoopContentRenderer } from "@analogjs/content";
|
|
4
|
+
import { markedHighlight } from "marked-highlight";
|
|
5
|
+
import Prism$1 from "prismjs";
|
|
6
|
+
import "prismjs/plugins/toolbar/prism-toolbar";
|
|
7
|
+
import "prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard";
|
|
8
|
+
//#region packages/content/prism-highlighter/src/lib/prism-highlighter.ts
|
|
9
|
+
var PrismHighlighter = class PrismHighlighter extends MarkedContentHighlighter {
|
|
10
|
+
augmentCodeBlock(code, lang) {
|
|
11
|
+
const classes = lang.startsWith("diff") && Prism.languages["diff"] ? `language-${lang} diff-highlight` : `language-${lang.replace("diff-", "")}`;
|
|
12
|
+
return `<pre class="${classes}"><code class="${classes}">${code}</code></pre>`;
|
|
13
|
+
}
|
|
14
|
+
getHighlightExtension() {
|
|
15
|
+
return markedHighlight({
|
|
16
|
+
async: true,
|
|
17
|
+
highlight: (code, lang) => {
|
|
18
|
+
let diff = lang?.startsWith("diff-");
|
|
19
|
+
lang = diff ? lang.replace("diff-", "") : lang || "typescript";
|
|
20
|
+
if (diff && !Prism.languages["diff"]) {
|
|
21
|
+
diff = false;
|
|
22
|
+
console.warn(`Notice:
|
|
25
23
|
---------------------------------------------------------------------------------------
|
|
26
24
|
The \`diff\` language and plugin are not available in the provided setup.
|
|
27
25
|
To enable it, add the following imports your \`app.config.ts\`:
|
|
@@ -29,57 +27,72 @@ class PrismHighlighter extends MarkedContentHighlighter {
|
|
|
29
27
|
import 'prismjs/plugins/diff-highlight/prism-diff-highlight';
|
|
30
28
|
---------------------------------------------------------------------------------------
|
|
31
29
|
`);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.warn(`Notice:
|
|
30
|
+
}
|
|
31
|
+
if (!Prism.languages[lang]) {
|
|
32
|
+
if (lang !== "mermaid") console.warn(`Notice:
|
|
36
33
|
---------------------------------------------------------------------------------------
|
|
37
34
|
The requested language '${lang}' is not available in the provided setup.
|
|
38
35
|
To enable it, add the following import your \`app.config.ts\`:
|
|
39
36
|
import 'prismjs/components/prism-${lang}';
|
|
40
37
|
---------------------------------------------------------------------------------------
|
|
41
38
|
`);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
return code;
|
|
40
|
+
}
|
|
41
|
+
return Prism.highlight(code, diff ? Prism.languages["diff"] : Prism.languages[lang], lang);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
static {
|
|
46
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
47
|
+
minVersion: "12.0.0",
|
|
48
|
+
version: "21.1.1",
|
|
49
|
+
ngImport: i0,
|
|
50
|
+
type: PrismHighlighter,
|
|
51
|
+
deps: null,
|
|
52
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
static {
|
|
56
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
57
|
+
minVersion: "12.0.0",
|
|
58
|
+
version: "21.1.1",
|
|
59
|
+
ngImport: i0,
|
|
60
|
+
type: PrismHighlighter
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
65
|
+
minVersion: "12.0.0",
|
|
66
|
+
version: "21.1.1",
|
|
67
|
+
ngImport: i0,
|
|
68
|
+
type: PrismHighlighter,
|
|
69
|
+
decorators: [{ type: Injectable }]
|
|
70
|
+
});
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region packages/content/prism-highlighter/src/lib/prism/angular.ts
|
|
73
|
+
(function() {
|
|
74
|
+
if (typeof Prism$1 === "undefined") return;
|
|
75
|
+
Prism$1.languages["angular"] = Prism$1.languages.extend("markup", {
|
|
76
|
+
keyword: /(?:@if|@for|@switch|@defer|@loading|@error|@placeholder|prefetch)\b/,
|
|
77
|
+
operator: /\b(?:on|when)\b/,
|
|
78
|
+
number: {
|
|
79
|
+
pattern: /\b(minimum|after)\s+\d+(?:s|ms|)/gi,
|
|
80
|
+
lookbehind: true
|
|
81
|
+
},
|
|
82
|
+
builtin: { pattern: /\b(?:viewport|timer|minimum|after|hover|idle|immediate|interaction)/ },
|
|
83
|
+
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/
|
|
84
|
+
});
|
|
85
|
+
Prism$1.languages["ng"] = Prism$1.languages["angular"];
|
|
74
86
|
})();
|
|
75
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region packages/content/prism-highlighter/src/index.ts
|
|
76
89
|
function withPrismHighlighter() {
|
|
77
|
-
|
|
90
|
+
return [{
|
|
91
|
+
provide: ContentRenderer,
|
|
92
|
+
useClass: NoopContentRenderer
|
|
93
|
+
}];
|
|
78
94
|
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Generated bundle index. Do not edit.
|
|
82
|
-
*/
|
|
83
|
-
|
|
95
|
+
//#endregion
|
|
84
96
|
export { PrismHighlighter, withPrismHighlighter };
|
|
85
|
-
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=analogjs-content-prism-highlighter.mjs.map
|
|
@@ -1,129 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { computed, inject, resource } from "@angular/core";
|
|
2
|
+
import { ActivatedRoute } from "@angular/router";
|
|
3
|
+
import { from } from "rxjs";
|
|
4
|
+
import { map } from "rxjs/operators";
|
|
5
|
+
import { toSignal } from "@angular/core/rxjs-interop";
|
|
6
|
+
import { ContentRenderer, injectContentFileLoader, injectContentListLoader, parseRawContentFile } from "@analogjs/content";
|
|
7
|
+
//#region packages/content/resources/src/content-files-resource.ts
|
|
8
8
|
function contentFilesResource(filterFn) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return resource({
|
|
12
|
-
loader: () => contentList,
|
|
13
|
-
});
|
|
9
|
+
const contentList = injectContentListLoader()().then((items) => filterFn ? items.filter(filterFn) : items);
|
|
10
|
+
return resource({ loader: () => contentList });
|
|
14
11
|
}
|
|
15
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region packages/content/resources/src/content-file-resource.ts
|
|
16
14
|
async function getContentFile(contentFiles, slug, fallback) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
attributes,
|
|
55
|
-
content,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
filename: resolvedBase,
|
|
60
|
-
slug,
|
|
61
|
-
attributes: contentFile.metadata,
|
|
62
|
-
content: contentFile.default,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
15
|
+
const normalizedFiles = {};
|
|
16
|
+
for (const [key, resolver] of Object.entries(contentFiles)) {
|
|
17
|
+
const normalizedKey = key.replace(/^(?:.*?)\/content(?=\/)/, "/src/content").replace(/\/{2,}/g, "/");
|
|
18
|
+
normalizedFiles[normalizedKey] = resolver;
|
|
19
|
+
}
|
|
20
|
+
const base = `/src/content/${slug}`.replace(/\/{2,}/g, "/");
|
|
21
|
+
const matchKey = [
|
|
22
|
+
`${base}.md`,
|
|
23
|
+
`${base}.agx`,
|
|
24
|
+
`${base}/index.md`,
|
|
25
|
+
`${base}/index.agx`
|
|
26
|
+
].find((k) => k in normalizedFiles);
|
|
27
|
+
const contentFile = matchKey ? normalizedFiles[matchKey] : void 0;
|
|
28
|
+
if (!contentFile) return {
|
|
29
|
+
filename: base,
|
|
30
|
+
attributes: {},
|
|
31
|
+
slug: "",
|
|
32
|
+
content: fallback
|
|
33
|
+
};
|
|
34
|
+
const resolvedBase = matchKey.replace(/\.(md|agx)$/, "");
|
|
35
|
+
return contentFile().then((contentFile) => {
|
|
36
|
+
if (typeof contentFile === "string") {
|
|
37
|
+
const { content, attributes } = parseRawContentFile(contentFile);
|
|
38
|
+
return {
|
|
39
|
+
filename: resolvedBase,
|
|
40
|
+
slug,
|
|
41
|
+
attributes,
|
|
42
|
+
content
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
filename: resolvedBase,
|
|
47
|
+
slug,
|
|
48
|
+
attributes: contentFile.metadata,
|
|
49
|
+
content: contentFile.default
|
|
50
|
+
};
|
|
51
|
+
});
|
|
65
52
|
}
|
|
66
53
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function contentFileResource(params, fallback =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
54
|
+
* Resource for requesting an individual content file
|
|
55
|
+
*
|
|
56
|
+
* @param params
|
|
57
|
+
* @param fallback
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
function contentFileResource(params, fallback = "No Content Found") {
|
|
61
|
+
const loaderPromise = injectContentFileLoader();
|
|
62
|
+
const contentRenderer = inject(ContentRenderer);
|
|
63
|
+
const contentFilesMap = toSignal(from(loaderPromise()));
|
|
64
|
+
const input = params || toSignal(inject(ActivatedRoute).paramMap.pipe(map((params) => params.get("slug"))), { requireSync: true });
|
|
65
|
+
return resource({
|
|
66
|
+
params: computed(() => ({
|
|
67
|
+
input: input(),
|
|
68
|
+
files: contentFilesMap()
|
|
69
|
+
})),
|
|
70
|
+
loader: async ({ params }) => {
|
|
71
|
+
const { input: param, files } = params;
|
|
72
|
+
if (typeof param === "string") {
|
|
73
|
+
if (param) {
|
|
74
|
+
const file = await getContentFile(files, param, fallback);
|
|
75
|
+
if (typeof file.content === "string") {
|
|
76
|
+
const rendered = await contentRenderer.render(file.content);
|
|
77
|
+
return {
|
|
78
|
+
...file,
|
|
79
|
+
toc: rendered.toc ?? []
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...file,
|
|
84
|
+
toc: []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
filename: "",
|
|
89
|
+
slug: "",
|
|
90
|
+
attributes: {},
|
|
91
|
+
content: fallback,
|
|
92
|
+
toc: []
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
const file = await getContentFile(files, param.customFilename, fallback);
|
|
96
|
+
if (typeof file.content === "string") {
|
|
97
|
+
const rendered = await contentRenderer.render(file.content);
|
|
98
|
+
return {
|
|
99
|
+
...file,
|
|
100
|
+
toc: rendered.toc ?? []
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
...file,
|
|
105
|
+
toc: []
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
122
110
|
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Generated bundle index. Do not edit.
|
|
126
|
-
*/
|
|
127
|
-
|
|
111
|
+
//#endregion
|
|
128
112
|
export { contentFileResource, contentFilesResource };
|
|
129
|
-
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=analogjs-content-resources.mjs.map
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ContentRenderer, NoopContentRenderer } from "@analogjs/content";
|
|
2
|
+
//#region packages/content/shiki-highlighter/src/index.ts
|
|
3
3
|
function withShikiHighlighter(_opts = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
];
|
|
4
|
+
return [{
|
|
5
|
+
provide: ContentRenderer,
|
|
6
|
+
useClass: NoopContentRenderer
|
|
7
|
+
}];
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Generated bundle index. Do not edit.
|
|
14
|
-
*/
|
|
15
|
-
|
|
9
|
+
//#endregion
|
|
16
10
|
export { withShikiHighlighter };
|
|
17
|
-
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=analogjs-content-shiki-highlighter.mjs.map
|