@analogjs/content 2.0.0-alpha.9 → 2.0.0-beta.10
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/fesm2022/analogjs-content-og.mjs.map +1 -1
- package/fesm2022/analogjs-content-prism-highlighter.mjs +4 -4
- package/fesm2022/analogjs-content-prism-highlighter.mjs.map +1 -1
- package/fesm2022/analogjs-content-resources.mjs +84 -0
- package/fesm2022/analogjs-content-resources.mjs.map +1 -0
- package/fesm2022/analogjs-content-shiki-highlighter.mjs +1 -1
- package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +1 -1
- package/fesm2022/analogjs-content.mjs +80 -72
- package/fesm2022/analogjs-content.mjs.map +1 -1
- package/index.d.ts +160 -12
- package/og/index.d.ts +19 -2
- package/package.json +17 -6
- package/plugin/migrations.json +2 -24
- package/prism-highlighter/index.d.ts +14 -7
- package/resources/README.md +3 -0
- package/resources/index.d.ts +20 -0
- package/resources/package.json +3 -0
- package/shiki-highlighter/index.d.ts +8 -4
- package/lib/anchor-navigation.directive.d.ts +0 -9
- package/lib/content-file.d.ts +0 -6
- package/lib/content-files-list-token.d.ts +0 -3
- package/lib/content-files-token.d.ts +0 -2
- package/lib/content-renderer.d.ts +0 -25
- package/lib/content.d.ts +0 -14
- package/lib/get-content-files.d.ts +0 -15
- package/lib/inject-content-files.d.ts +0 -3
- package/lib/markdown-content-renderer.service.d.ts +0 -13
- package/lib/markdown-route.component.d.ts +0 -15
- package/lib/markdown.component.d.ts +0 -29
- package/lib/marked-content-highlighter.d.ts +0 -19
- package/lib/marked-setup.service.d.ts +0 -10
- package/lib/parse-raw-content-file.d.ts +0 -4
- package/lib/provide-content.d.ts +0 -7
- package/lib/render-task.service.d.ts +0 -8
- package/lib/utils/zone-wait-for.d.ts +0 -2
- package/og/lib/og.d.ts +0 -5
- package/og/lib/options.d.ts +0 -11
- package/prism-highlighter/lib/prism/angular.d.ts +0 -0
- package/prism-highlighter/lib/prism-highlighter.d.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analogjs-content-og.mjs","sources":["../../../../packages/content/og/src/lib/og.ts","../../../../packages/content/og/src/analogjs-content-og.ts"],"sourcesContent":["// Credit for modified source: https://github.com/etherCorps/sveltekit-og/blob/main/src/lib/api.ts\n\nimport satori from 'satori';\nimport { html as toReactElement } from 'satori-html';\nimport sharp from 'sharp';\n\nimport { ImageResponseOptions } from './options
|
|
1
|
+
{"version":3,"file":"analogjs-content-og.mjs","sources":["../../../../packages/content/og/src/lib/og.ts","../../../../packages/content/og/src/analogjs-content-og.ts"],"sourcesContent":["// Credit for modified source: https://github.com/etherCorps/sveltekit-og/blob/main/src/lib/api.ts\n\nimport satori from 'satori';\nimport { html as toReactElement } from 'satori-html';\nimport sharp from 'sharp';\n\nimport { ImageResponseOptions } from './options';\n\nexport const generateImage = async (\n element: string,\n options: ImageResponseOptions,\n) => {\n const elementHtml = toReactElement(element);\n const svg = await satori(elementHtml as any, {\n width: options.width || 1200,\n height: options.height || 630,\n fonts: options.fonts?.length ? options.fonts : [],\n tailwindConfig: options.tailwindConfig,\n });\n const svgBuffer = Buffer.from(svg);\n const png = sharp(svgBuffer).png().toBuffer();\n\n const pngBuffer = await png;\n\n return pngBuffer;\n};\n\nexport class ImageResponse extends Response {\n constructor(element: string, options: ImageResponseOptions = {}) {\n super();\n\n const body = new ReadableStream({\n async start(controller) {\n const buffer = await generateImage(element, options);\n controller.enqueue(buffer);\n controller.close();\n },\n });\n\n return new Response(body, {\n headers: {\n 'Content-Type': 'image/png',\n 'Cache-Control': options.debug\n ? 'no-cache, no-store'\n : 'public, immutable, no-transform, max-age=31536000',\n ...options.headers,\n },\n status: options.status || 200,\n statusText: options.statusText,\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["toReactElement"],"mappings":";;;;AAAA;AAQO,MAAM,aAAa,GAAG,OAC3B,OAAe,EACf,OAA6B,KAC3B;AACF,I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I,GAAG;YAC7B,UAAU,EAAE,OAAO,CAAC,UAAU;AAC/B,SAAA,CAAC;;AAEL;;ACnDD;;AAEG;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarkedContentHighlighter,
|
|
1
|
+
import { MarkedContentHighlighter, NoopContentRenderer, ContentRenderer } from '@analogjs/content';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { Injectable } from '@angular/core';
|
|
4
4
|
import { markedHighlight } from 'marked-highlight';
|
|
@@ -46,10 +46,10 @@ class PrismHighlighter extends MarkedContentHighlighter {
|
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
50
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
49
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: PrismHighlighter, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
50
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: PrismHighlighter }); }
|
|
51
51
|
}
|
|
52
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: PrismHighlighter, decorators: [{
|
|
53
53
|
type: Injectable
|
|
54
54
|
}] });
|
|
55
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analogjs-content-prism-highlighter.mjs","sources":["../../../../packages/content/prism-highlighter/src/lib/prism-highlighter.ts","../../../../packages/content/prism-highlighter/src/lib/prism/angular.js","../../../../packages/content/prism-highlighter/src/index.ts","../../../../packages/content/prism-highlighter/src/analogjs-content-prism-highlighter.ts"],"sourcesContent":["import { MarkedContentHighlighter } from '@analogjs/content';\nimport { Injectable } from '@angular/core';\nimport { markedHighlight } from 'marked-highlight';\n\ndeclare const Prism: typeof import('prismjs');\n\n@Injectable()\nexport class PrismHighlighter extends MarkedContentHighlighter {\n override augmentCodeBlock(code: string, lang: string): string {\n const classes =\n lang.startsWith('diff') && Prism.languages['diff']\n ? `language-${lang} diff-highlight`\n : `language-${lang.replace('diff-', '')}`;\n return `<pre class=\"${classes}\"><code class=\"${classes}\">${code}</code></pre>`;\n }\n\n override getHighlightExtension() {\n return markedHighlight({\n async: true,\n highlight: (code: string, lang: string) => {\n let diff = lang?.startsWith('diff-');\n lang = diff ? lang.replace('diff-', '') : lang || 'typescript';\n\n if (diff && !Prism.languages['diff']) {\n diff = false;\n console.warn(`Notice:\n ---------------------------------------------------------------------------------------\n The \\`diff\\` language and plugin are not available in the provided setup.\n To enable it, add the following imports your \\`app.config.ts\\`:\n import 'prismjs/components/prism-diff';\n import 'prismjs/plugins/diff-highlight/prism-diff-highlight';\n ---------------------------------------------------------------------------------------\n `);\n }\n\n if (!Prism.languages[lang]) {\n if (lang !== 'mermaid') {\n console.warn(`Notice:\n ---------------------------------------------------------------------------------------\n The requested language '${lang}' is not available in the provided setup.\n To enable it, add the following import your \\`app.config.ts\\`:\n import 'prismjs/components/prism-${lang}';\n ---------------------------------------------------------------------------------------\n `);\n }\n return code;\n }\n return Prism.highlight(\n code,\n diff ? Prism.languages['diff'] : Prism.languages[lang],\n lang,\n );\n },\n });\n }\n}\n","(function () {\n if (typeof Prism === 'undefined') {\n return;\n }\n\n Prism.languages.angular = Prism.languages.extend('markup', {\n keyword:\n /(?:@if|@for|@switch|@defer|@loading|@error|@placeholder|prefetch)\\b/,\n operator: /\\b(?:on|when)\\b/,\n number: {\n pattern: /\\b(minimum|after)\\s+\\d+(?:s|ms|)/gi,\n lookbehind: true,\n },\n builtin: {\n pattern:\n /\\b(?:viewport|timer|minimum|after|hover|idle|immediate|interaction)/,\n },\n function:\n /#?(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*(?:\\.\\s*(?:apply|bind|call)\\s*)?\\()/,\n });\n\n Prism.languages.ng = Prism.languages.angular;\n})();\n","import { ContentRenderer, NoopContentRenderer } from '@analogjs/content';\nimport { Provider } from '@angular/core';\nimport { PrismHighlighter } from './lib/prism-highlighter';\n\nimport 'prismjs';\nimport 'prismjs/plugins/toolbar/prism-toolbar';\nimport 'prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard';\nimport './lib/prism/angular';\n\nexport { PrismHighlighter };\n\nexport function withPrismHighlighter(): Provider[] {\n return [{ provide: ContentRenderer, useClass: NoopContentRenderer }];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAOM,MAAO,gBAAiB,SAAQ,wBAAwB,CAAA;IACnD,gBAAgB,CAAC,IAAY,EAAE,IAAY,EAAA;AAClD,QAAA,MAAM,OAAO,GACX,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM;cAC7C,
|
|
1
|
+
{"version":3,"file":"analogjs-content-prism-highlighter.mjs","sources":["../../../../packages/content/prism-highlighter/src/lib/prism-highlighter.ts","../../../../packages/content/prism-highlighter/src/lib/prism/angular.js","../../../../packages/content/prism-highlighter/src/index.ts","../../../../packages/content/prism-highlighter/src/analogjs-content-prism-highlighter.ts"],"sourcesContent":["import { MarkedContentHighlighter } from '@analogjs/content';\nimport { Injectable } from '@angular/core';\nimport { markedHighlight } from 'marked-highlight';\n\ndeclare const Prism: typeof import('prismjs');\n\n@Injectable()\nexport class PrismHighlighter extends MarkedContentHighlighter {\n override augmentCodeBlock(code: string, lang: string): string {\n const classes =\n lang.startsWith('diff') && Prism.languages['diff']\n ? `language-${lang} diff-highlight`\n : `language-${lang.replace('diff-', '')}`;\n return `<pre class=\"${classes}\"><code class=\"${classes}\">${code}</code></pre>`;\n }\n\n override getHighlightExtension() {\n return markedHighlight({\n async: true,\n highlight: (code: string, lang: string) => {\n let diff = lang?.startsWith('diff-');\n lang = diff ? lang.replace('diff-', '') : lang || 'typescript';\n\n if (diff && !Prism.languages['diff']) {\n diff = false;\n console.warn(`Notice:\n ---------------------------------------------------------------------------------------\n The \\`diff\\` language and plugin are not available in the provided setup.\n To enable it, add the following imports your \\`app.config.ts\\`:\n import 'prismjs/components/prism-diff';\n import 'prismjs/plugins/diff-highlight/prism-diff-highlight';\n ---------------------------------------------------------------------------------------\n `);\n }\n\n if (!Prism.languages[lang]) {\n if (lang !== 'mermaid') {\n console.warn(`Notice:\n ---------------------------------------------------------------------------------------\n The requested language '${lang}' is not available in the provided setup.\n To enable it, add the following import your \\`app.config.ts\\`:\n import 'prismjs/components/prism-${lang}';\n ---------------------------------------------------------------------------------------\n `);\n }\n return code;\n }\n return Prism.highlight(\n code,\n diff ? Prism.languages['diff'] : Prism.languages[lang],\n lang,\n );\n },\n });\n }\n}\n","(function () {\n if (typeof Prism === 'undefined') {\n return;\n }\n\n Prism.languages.angular = Prism.languages.extend('markup', {\n keyword:\n /(?:@if|@for|@switch|@defer|@loading|@error|@placeholder|prefetch)\\b/,\n operator: /\\b(?:on|when)\\b/,\n number: {\n pattern: /\\b(minimum|after)\\s+\\d+(?:s|ms|)/gi,\n lookbehind: true,\n },\n builtin: {\n pattern:\n /\\b(?:viewport|timer|minimum|after|hover|idle|immediate|interaction)/,\n },\n function:\n /#?(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?=\\s*(?:\\.\\s*(?:apply|bind|call)\\s*)?\\()/,\n });\n\n Prism.languages.ng = Prism.languages.angular;\n})();\n","import { ContentRenderer, NoopContentRenderer } from '@analogjs/content';\nimport { Provider } from '@angular/core';\nimport { PrismHighlighter } from './lib/prism-highlighter';\n\nimport 'prismjs';\nimport 'prismjs/plugins/toolbar/prism-toolbar';\nimport 'prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard';\nimport './lib/prism/angular';\n\nexport { PrismHighlighter };\n\nexport function withPrismHighlighter(): Provider[] {\n return [{ provide: ContentRenderer, useClass: NoopContentRenderer }];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAOM,MAAO,gBAAiB,SAAQ,wBAAwB,CAAA;IACnD,gBAAgB,CAAC,IAAY,EAAE,IAAY,EAAA;AAClD,QAAA,MAAM,OAAO,GACX,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM;cAC7C,CAAA,SAAA,EAAY,IAAI,CAAA,eAAA;cAChB,CAAA,SAAA,EAAY,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA,CAAE;AAC7C,QAAA,OAAO,eAAe,OAAO,CAAA,eAAA,EAAkB,OAAO,CAAA,EAAA,EAAK,IAAI,eAAe;;IAGvE,qBAAqB,GAAA;AAC5B,QAAA,OAAO,eAAe,CAAC;AACrB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,SAAS,EAAE,CAAC,IAAY,EAAE,IAAY,KAAI;gBACxC,IAAI,IAAI,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC;AACpC,gBAAA,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,YAAY;gBAE9D,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;oBACpC,IAAI,GAAG,KAAK;oBACZ,OAAO,CAAC,IAAI,CAAC,CAAA;;;;;;;AAOV,YAAA,CAAA,CAAC;;gBAGN,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;AAC1B,oBAAA,IAAI,IAAI,KAAK,SAAS,EAAE;wBACtB,OAAO,CAAC,IAAI,CAAC,CAAA;;8BAE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awContentFile, injectContentFileLoader } from '@analogjs/content';
|
|
3
|
+
import { ActivatedRoute } from '@angular/router';
|
|
4
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { from } from 'rxjs';
|
|
6
|
+
import { map } from 'rxjs/operators';
|
|
7
|
+
|
|
8
|
+
function contentFilesResource(filterFn) {
|
|
9
|
+
const contentListLoader = injectContentListLoader();
|
|
10
|
+
const contentList = contentListLoader().then((items) => filterFn ? items.filter(filterFn) : items);
|
|
11
|
+
return resource({
|
|
12
|
+
loader: () => contentList,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function getContentFile(contentFiles, slug, fallback) {
|
|
17
|
+
const filePath = `/src/content/${slug}`;
|
|
18
|
+
const contentFile = contentFiles[`${filePath}.md`] ?? contentFiles[`${filePath}.agx`];
|
|
19
|
+
if (!contentFile) {
|
|
20
|
+
return {
|
|
21
|
+
filename: filePath,
|
|
22
|
+
attributes: {},
|
|
23
|
+
slug: '',
|
|
24
|
+
content: fallback,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return contentFile().then((contentFile) => {
|
|
28
|
+
if (typeof contentFile === 'string') {
|
|
29
|
+
const { content, attributes } = parseRawContentFile(contentFile);
|
|
30
|
+
return {
|
|
31
|
+
filename: filePath,
|
|
32
|
+
slug,
|
|
33
|
+
attributes,
|
|
34
|
+
content,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
filename: filePath,
|
|
39
|
+
slug,
|
|
40
|
+
attributes: contentFile.metadata,
|
|
41
|
+
content: contentFile.default,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resource for requesting an individual content file
|
|
47
|
+
*
|
|
48
|
+
* @param params
|
|
49
|
+
* @param fallback
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
function contentFileResource(params, fallback = 'No Content Found') {
|
|
53
|
+
const loaderPromise = injectContentFileLoader();
|
|
54
|
+
const contentFilesMap = toSignal(from(loaderPromise()));
|
|
55
|
+
const input = params ||
|
|
56
|
+
toSignal(inject(ActivatedRoute).paramMap.pipe(map((params) => params.get('slug'))), { requireSync: true });
|
|
57
|
+
return resource({
|
|
58
|
+
params: computed(() => ({ input: input(), files: contentFilesMap() })),
|
|
59
|
+
loader: async ({ params }) => {
|
|
60
|
+
const { input: param, files } = params;
|
|
61
|
+
if (typeof param === 'string') {
|
|
62
|
+
if (param) {
|
|
63
|
+
return getContentFile(files, param, fallback);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
filename: '',
|
|
67
|
+
slug: '',
|
|
68
|
+
attributes: {},
|
|
69
|
+
content: fallback,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return getContentFile(files, param.customFilename, fallback);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Generated bundle index. Do not edit.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
export { contentFileResource, contentFilesResource };
|
|
84
|
+
//# sourceMappingURL=analogjs-content-resources.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analogjs-content-resources.mjs","sources":["../../../../packages/content/resources/src/content-files-resource.ts","../../../../packages/content/resources/src/content-file-resource.ts","../../../../packages/content/resources/src/analogjs-content-resources.ts"],"sourcesContent":["import { resource } from '@angular/core';\nimport {\n injectContentListLoader,\n InjectContentFilesFilterFunction,\n} from '@analogjs/content';\n\nexport function contentFilesResource<Attributes extends Record<string, any>>(\n filterFn?: InjectContentFilesFilterFunction<Attributes> | undefined,\n) {\n const contentListLoader = injectContentListLoader<Attributes>();\n const contentList = contentListLoader().then((items) =>\n filterFn ? items.filter(filterFn) : items,\n );\n\n return resource({\n loader: () => contentList,\n });\n}\n","import { computed, inject, resource, Signal } from '@angular/core';\nimport {\n ContentFile,\n parseRawContentFile,\n injectContentFileLoader,\n} from '@analogjs/content';\nimport { ActivatedRoute } from '@angular/router';\n\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { from } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\ntype ContentFileParams = Signal<\n | string\n | {\n customFilename: string;\n }\n>;\n\nasync function getContentFile<\n Attributes extends Record<string, any> = Record<string, any>,\n>(\n contentFiles: Record<string, () => Promise<string>>,\n slug: string,\n fallback: string,\n): Promise<ContentFile<Attributes | Record<string, never>>> {\n const filePath = `/src/content/${slug}`;\n const contentFile =\n contentFiles[`${filePath}.md`] ?? contentFiles[`${filePath}.agx`];\n\n if (!contentFile) {\n return {\n filename: filePath,\n attributes: {},\n slug: '',\n content: fallback,\n } as ContentFile<Attributes | Record<string, never>>;\n }\n\n return contentFile().then(\n (contentFile: string | { default: any; metadata: any }) => {\n if (typeof contentFile === 'string') {\n const { content, attributes } =\n parseRawContentFile<Attributes>(contentFile);\n\n return {\n filename: filePath,\n slug,\n attributes,\n content,\n } as ContentFile<Attributes | Record<string, never>>;\n }\n\n return {\n filename: filePath,\n slug,\n attributes: contentFile.metadata,\n content: contentFile.default,\n } as ContentFile<Attributes | Record<string, never>>;\n },\n );\n}\n\n/**\n * Resource for requesting an individual content file\n *\n * @param params\n * @param fallback\n * @returns\n */\nexport function contentFileResource<\n Attributes extends Record<string, any> = Record<string, any>,\n>(params?: ContentFileParams, fallback = 'No Content Found') {\n const loaderPromise = injectContentFileLoader();\n const contentFilesMap = toSignal(from(loaderPromise()));\n const input =\n params ||\n toSignal(\n inject(ActivatedRoute).paramMap.pipe(\n map((params) => params.get('slug') as string),\n ),\n { requireSync: true },\n );\n\n return resource({\n params: computed(() => ({ input: input(), files: contentFilesMap() })),\n loader: async ({ params }) => {\n const { input: param, files } = params;\n\n if (typeof param === 'string') {\n if (param) {\n return getContentFile<Attributes>(files!, param, fallback);\n }\n\n return {\n filename: '',\n slug: '',\n attributes: {},\n content: fallback,\n } as ContentFile<Attributes | Record<string, never>>;\n } else {\n return getContentFile<Attributes>(\n files!,\n param.customFilename,\n fallback,\n );\n }\n },\n });\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAMM,SAAU,oBAAoB,CAClC,QAAmE,EAAA;AAEnE,IAAA,MAAM,iBAAiB,GAAG,uBAAuB,EAAc;IAC/D,MAAM,WAAW,GAAG,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,KACjD,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAC1C;AAED,IAAA,OAAO,QAAQ,CAAC;AACd,QAAA,MAAM,EAAE,MAAM,WAAW;AAC1B,KAAA,CAAC;AACJ;;ACEA,eAAe,cAAc,CAG3B,YAAmD,EACnD,IAAY,EACZ,QAAgB,EAAA;AAEhB,IAAA,MAAM,QAAQ,GAAG,CAAA,aAAA,EAAgB,IAAI,EAAE;AACvC,IAAA,MAAM,WAAW,GACf,YAAY,CAAC,GAAG,QAAQ,CAAA,GAAA,CAAK,CAAC,IAAI,YAAY,CAAC,CAAA,EAAG,QAAQ,CAAA,IAAA,CAAM,CAAC;IAEnE,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO;AACL,YAAA,QAAQ,EAAE,QAAQ;AAClB,YAAA,UAAU,EAAE,EAAE;AACd,YAAA,IAAI,EAAE,EAAE;AACR,YAAA,OAAO,EAAE,QAAQ;SACiC;;IAGtD,OAAO,WAAW,EAAE,CAAC,IAAI,CACvB,CAAC,WAAqD,KAAI;AACxD,QAAA,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACnC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAC3B,mBAAmB,CAAa,WAAW,CAAC;YAE9C,OAAO;AACL,gBAAA,QAAQ,EAAE,QAAQ;gBAClB,IAAI;gBACJ,UAAU;gBACV,OAAO;aAC2C;;QAGtD,OAAO;AACL,YAAA,QA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GA;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analogjs-content-shiki-highlighter.mjs","sources":["../../../../packages/content/shiki-highlighter/src/index.ts","../../../../packages/content/shiki-highlighter/src/analogjs-content-shiki-highlighter.ts"],"sourcesContent":["import { ContentRenderer, NoopContentRenderer } from '@analogjs/content';\nimport { Provider } from '@angular/core';\nimport type {\n BundledLanguage,\n BundledTheme,\n CodeOptionsMeta,\n CodeOptionsMultipleThemes,\n CodeOptionsSingleTheme,\n CodeToHastOptionsCommon,\n} from 'shiki';\n\nexport type ShikiHighlightOptions = Partial<\n Omit<CodeToHastOptionsCommon<BundledLanguage>, 'lang'>\n> &\n CodeOptionsMeta &\n Partial<CodeOptionsSingleTheme<BundledTheme>> &\n Partial<CodeOptionsMultipleThemes<BundledTheme>>;\n\nexport type WithShikiHighlighterOptions = ShikiHighlightOptions & {\n container?: string;\n};\n\nexport function withShikiHighlighter(\n _opts: WithShikiHighlighterOptions = {},\n): Provider[] {\n return [\n {\n provide: ContentRenderer,\n useClass: NoopContentRenderer,\n },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"analogjs-content-shiki-highlighter.mjs","sources":["../../../../packages/content/shiki-highlighter/src/index.ts","../../../../packages/content/shiki-highlighter/src/analogjs-content-shiki-highlighter.ts"],"sourcesContent":["import { ContentRenderer, NoopContentRenderer } from '@analogjs/content';\nimport { Provider } from '@angular/core';\nimport type {\n BundledLanguage,\n BundledTheme,\n CodeOptionsMeta,\n CodeOptionsMultipleThemes,\n CodeOptionsSingleTheme,\n CodeToHastOptionsCommon,\n} from 'shiki';\n\nexport type ShikiHighlightOptions = Partial<\n Omit<CodeToHastOptionsCommon<BundledLanguage>, 'lang'>\n> &\n CodeOptionsMeta &\n Partial<CodeOptionsSingleTheme<BundledTheme>> &\n Partial<CodeOptionsMultipleThemes<BundledTheme>>;\n\nexport type WithShikiHighlighterOptions = ShikiHighlightOptions & {\n container?: string;\n};\n\nexport function withShikiHighlighter(\n _opts: WithShikiHighlighterOptions = {},\n): Provider[] {\n return [\n {\n provide: ContentRenderer,\n useClass: NoopContentRenderer,\n },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAsBM,SAAU,oBAAoB,CAClC,KAAA,GAAqC,EAAE,EAAA;IAEvC,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,QAAQ,EAAE,mBAAmB;AAC9B,SAAA;KACF;AACH;;AC/BA;;AAEG;;;;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject,
|
|
2
|
+
import { inject, HostListener, Directive, InjectionToken, signal, ɵPendingTasksInternal as _PendingTasksInternal, Injectable, TransferState, makeStateKey, Input, ViewEncapsulation, Component, NgZone, PLATFORM_ID, computed, input } from '@angular/core';
|
|
3
3
|
import { DOCUMENT, Location, AsyncPipe, isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
5
5
|
import { isObservable, firstValueFrom, of, Observable, from } from 'rxjs';
|
|
6
|
-
import { map, switchMap, tap,
|
|
6
|
+
import { map, switchMap, tap, catchError } from 'rxjs/operators';
|
|
7
7
|
import fm from 'front-matter';
|
|
8
8
|
import { getHeadingList, gfmHeadingId } from 'marked-gfm-heading-id';
|
|
9
9
|
import { marked } from 'marked';
|
|
10
10
|
import { mangle } from 'marked-mangle';
|
|
11
11
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
12
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
12
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
13
13
|
|
|
14
14
|
class AnchorNavigationDirective {
|
|
15
15
|
constructor() {
|
|
@@ -29,10 +29,10 @@ class AnchorNavigationDirective {
|
|
|
29
29
|
}
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
33
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
32
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnchorNavigationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
33
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.0", type: AnchorNavigationDirective, isStandalone: true, selector: "[analogAnchorNavigation]", host: { listeners: { "click": "handleNavigation($event.target)" } }, ngImport: i0 }); }
|
|
34
34
|
}
|
|
35
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
35
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnchorNavigationDirective, decorators: [{
|
|
36
36
|
type: Directive,
|
|
37
37
|
args: [{
|
|
38
38
|
selector: '[analogAnchorNavigation]',
|
|
@@ -73,10 +73,6 @@ const getContentFiles = () => {
|
|
|
73
73
|
let ANALOG_CONTENT_ROUTE_FILES = {};
|
|
74
74
|
return ANALOG_CONTENT_ROUTE_FILES;
|
|
75
75
|
};
|
|
76
|
-
const getAgxFiles = () => {
|
|
77
|
-
let ANALOG_AGX_FILES = {};
|
|
78
|
-
return ANALOG_AGX_FILES;
|
|
79
|
-
};
|
|
80
76
|
|
|
81
77
|
function getSlug(filename) {
|
|
82
78
|
const parts = filename.match(/^(\\|\/)(.+(\\|\/))*(.+)\.(.+)$/);
|
|
@@ -102,8 +98,7 @@ const CONTENT_FILES_TOKEN = new InjectionToken('@analogjs/content Content Files'
|
|
|
102
98
|
providedIn: 'root',
|
|
103
99
|
factory() {
|
|
104
100
|
const contentFiles = getContentFiles();
|
|
105
|
-
const
|
|
106
|
-
const allFiles = { ...contentFiles, ...agxFiles };
|
|
101
|
+
const allFiles = { ...contentFiles };
|
|
107
102
|
const contentFilesList = inject(CONTENT_FILES_LIST_TOKEN);
|
|
108
103
|
const lookup = {};
|
|
109
104
|
contentFilesList.forEach((item) => {
|
|
@@ -126,6 +121,12 @@ const CONTENT_FILES_TOKEN = new InjectionToken('@analogjs/content Content Files'
|
|
|
126
121
|
return objectUsingSlugAttribute;
|
|
127
122
|
},
|
|
128
123
|
});
|
|
124
|
+
const CONTENT_FILES_MAP_TOKEN = new InjectionToken('@analogjs/content Content Files', {
|
|
125
|
+
providedIn: 'root',
|
|
126
|
+
factory() {
|
|
127
|
+
return signal(inject(CONTENT_FILES_TOKEN));
|
|
128
|
+
},
|
|
129
|
+
});
|
|
129
130
|
|
|
130
131
|
function parseRawContentFile(rawContentFile) {
|
|
131
132
|
const { body, attributes } = fm(rawContentFile);
|
|
@@ -159,17 +160,17 @@ class RenderTaskService {
|
|
|
159
160
|
this.#pendingTasks.remove(clear);
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
163
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
163
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: RenderTaskService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
164
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: RenderTaskService }); }
|
|
164
165
|
}
|
|
165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
166
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: RenderTaskService, decorators: [{
|
|
166
167
|
type: Injectable
|
|
167
168
|
}] });
|
|
168
169
|
|
|
169
170
|
/// <reference types="vite/client" />
|
|
170
171
|
function getContentFile(contentFiles, prefix, slug, fallback, renderTaskService) {
|
|
171
172
|
const filePath = `/src/content/${prefix}${slug}`;
|
|
172
|
-
const contentFile = contentFiles[`${filePath}.md`]
|
|
173
|
+
const contentFile = contentFiles[`${filePath}.md`];
|
|
173
174
|
if (!contentFile) {
|
|
174
175
|
return of({
|
|
175
176
|
filename: filePath,
|
|
@@ -253,10 +254,10 @@ class ContentRenderer {
|
|
|
253
254
|
}
|
|
254
255
|
// eslint-disable-next-line
|
|
255
256
|
enhance() { }
|
|
256
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
257
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
257
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ContentRenderer, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
258
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ContentRenderer }); }
|
|
258
259
|
}
|
|
259
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
260
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: ContentRenderer, decorators: [{
|
|
260
261
|
type: Injectable
|
|
261
262
|
}] });
|
|
262
263
|
class NoopContentRenderer {
|
|
@@ -304,12 +305,15 @@ function injectContentFiles(filterFn) {
|
|
|
304
305
|
}
|
|
305
306
|
return allContentFiles;
|
|
306
307
|
}
|
|
308
|
+
function injectContentFilesMap() {
|
|
309
|
+
return inject(CONTENT_FILES_TOKEN);
|
|
310
|
+
}
|
|
307
311
|
|
|
308
312
|
class MarkedContentHighlighter {
|
|
309
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
310
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
313
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedContentHighlighter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
314
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedContentHighlighter }); }
|
|
311
315
|
}
|
|
312
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedContentHighlighter, decorators: [{
|
|
313
317
|
type: Injectable
|
|
314
318
|
}] });
|
|
315
319
|
function withHighlighter(provider) {
|
|
@@ -355,10 +359,10 @@ class MarkedSetupService {
|
|
|
355
359
|
getMarkedInstance() {
|
|
356
360
|
return this.marked;
|
|
357
361
|
}
|
|
358
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
359
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
362
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedSetupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
363
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedSetupService }); }
|
|
360
364
|
}
|
|
361
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
365
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkedSetupService, decorators: [{
|
|
362
366
|
type: Injectable
|
|
363
367
|
}], ctorParameters: () => [] });
|
|
364
368
|
|
|
@@ -375,18 +379,46 @@ class MarkdownContentRendererService {
|
|
|
375
379
|
}
|
|
376
380
|
// eslint-disable-next-line
|
|
377
381
|
enhance() { }
|
|
378
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
379
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
382
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkdownContentRendererService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
383
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkdownContentRendererService }); }
|
|
380
384
|
}
|
|
381
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
385
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MarkdownContentRendererService, decorators: [{
|
|
382
386
|
type: Injectable
|
|
383
387
|
}] });
|
|
384
388
|
|
|
389
|
+
const CONTENT_FILE_LOADER = new InjectionToken('@analogjs/content/resource File Loader');
|
|
390
|
+
function injectContentFileLoader() {
|
|
391
|
+
return inject(CONTENT_FILE_LOADER);
|
|
392
|
+
}
|
|
393
|
+
function withContentFileLoader() {
|
|
394
|
+
return {
|
|
395
|
+
provide: CONTENT_FILE_LOADER,
|
|
396
|
+
useFactory() {
|
|
397
|
+
return async () => injectContentFilesMap();
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const CONTENT_LIST_LOADER = new InjectionToken('@analogjs/content/resource List Loader');
|
|
403
|
+
function injectContentListLoader() {
|
|
404
|
+
return inject(CONTENT_LIST_LOADER);
|
|
405
|
+
}
|
|
406
|
+
function withContentListLoader() {
|
|
407
|
+
return {
|
|
408
|
+
provide: CONTENT_LIST_LOADER,
|
|
409
|
+
useFactory() {
|
|
410
|
+
return async () => injectContentFiles();
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
385
415
|
const CONTENT_RENDERER_PROVIDERS = [
|
|
386
416
|
{
|
|
387
417
|
provide: ContentRenderer,
|
|
388
418
|
useClass: NoopContentRenderer,
|
|
389
419
|
},
|
|
420
|
+
withContentFileLoader(),
|
|
421
|
+
withContentListLoader(),
|
|
390
422
|
];
|
|
391
423
|
function withMarkdownRenderer(options) {
|
|
392
424
|
return [
|
|
@@ -420,10 +452,10 @@ class AnalogMarkdownRouteComponent {
|
|
|
420
452
|
ngAfterViewChecked() {
|
|
421
453
|
this.contentRenderer.enhance();
|
|
422
454
|
}
|
|
423
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
424
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
455
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnalogMarkdownRouteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
456
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.0", type: AnalogMarkdownRouteComponent, isStandalone: true, selector: "analog-markdown-route", inputs: { classes: "classes" }, hostDirectives: [{ directive: AnchorNavigationDirective }], ngImport: i0, template: `<div [innerHTML]="content" [class]="classes"></div>`, isInline: true, encapsulation: i0.ViewEncapsulation.None, preserveWhitespaces: true }); }
|
|
425
457
|
}
|
|
426
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
458
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnalogMarkdownRouteComponent, decorators: [{
|
|
427
459
|
type: Component,
|
|
428
460
|
args: [{
|
|
429
461
|
selector: 'analog-markdown-route',
|
|
@@ -447,32 +479,24 @@ class AnalogMarkdownComponent {
|
|
|
447
479
|
this.mermaidImport = inject(MERMAID_IMPORT_TOKEN, {
|
|
448
480
|
optional: true,
|
|
449
481
|
});
|
|
450
|
-
this.
|
|
451
|
-
this.
|
|
482
|
+
this.contentSource = toSignal(this.getContentSource());
|
|
483
|
+
this.htmlContent = computed(() => {
|
|
484
|
+
const inputContent = this.content();
|
|
485
|
+
if (inputContent) {
|
|
486
|
+
return this.sanitizer.bypassSecurityTrustHtml(inputContent);
|
|
487
|
+
}
|
|
488
|
+
return this.contentSource();
|
|
489
|
+
}, ...(ngDevMode ? [{ debugName: "htmlContent" }] : []));
|
|
490
|
+
this.content = input(...(ngDevMode ? [undefined, { debugName: "content" }] : []));
|
|
491
|
+
this.classes = input('analog-markdown', ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
452
492
|
this.contentRenderer = inject(ContentRenderer);
|
|
453
493
|
if (isPlatformBrowser(this.platformId) && this.mermaidImport) {
|
|
454
494
|
// Mermaid can only be loaded on client side
|
|
455
495
|
this.loadMermaid(this.mermaidImport);
|
|
456
496
|
}
|
|
457
497
|
}
|
|
458
|
-
ngOnInit() {
|
|
459
|
-
this.updateContent();
|
|
460
|
-
}
|
|
461
|
-
ngOnChanges() {
|
|
462
|
-
this.updateContent();
|
|
463
|
-
}
|
|
464
|
-
updateContent() {
|
|
465
|
-
if (this.content && typeof this.content !== 'string') {
|
|
466
|
-
this.container.clear();
|
|
467
|
-
const componentRef = this.container.createComponent(this.content);
|
|
468
|
-
componentRef.changeDetectorRef.detectChanges();
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
this.content$ = this.getContentSource();
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
498
|
getContentSource() {
|
|
475
|
-
return this.route.data.pipe(map((data) =>
|
|
499
|
+
return this.route.data.pipe(map((data) => data['_analogContent'] ?? ''), switchMap((contentString) => this.renderContent(contentString)), map((content) => this.sanitizer.bypassSecurityTrustHtml(content)), catchError((e) => of(`There was an error ${e}`)));
|
|
476
500
|
}
|
|
477
501
|
async renderContent(content) {
|
|
478
502
|
return this.contentRenderer.render(content);
|
|
@@ -495,40 +519,24 @@ class AnalogMarkdownComponent {
|
|
|
495
519
|
this.mermaid?.default.run();
|
|
496
520
|
}));
|
|
497
521
|
}
|
|
498
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
499
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
500
|
-
#container
|
|
501
|
-
[innerHTML]="content$ | async"
|
|
502
|
-
[class]="classes"
|
|
503
|
-
></div>`, isInline: true, dependencies: [{ kind: "pipe", type: AsyncPipe, name: "async" }], encapsulation: i0.ViewEncapsulation.None, preserveWhitespaces: true }); }
|
|
522
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnalogMarkdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
523
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.0", type: AnalogMarkdownComponent, isStandalone: true, selector: "analog-markdown", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, classes: { classPropertyName: "classes", publicName: "classes", isSignal: true, isRequired: false, transformFunction: null } }, hostDirectives: [{ directive: AnchorNavigationDirective }], ngImport: i0, template: ` <div [innerHTML]="htmlContent()" [class]="classes()"></div> `, isInline: true, encapsulation: i0.ViewEncapsulation.None, preserveWhitespaces: true }); }
|
|
504
524
|
}
|
|
505
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
525
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AnalogMarkdownComponent, decorators: [{
|
|
506
526
|
type: Component,
|
|
507
527
|
args: [{
|
|
508
528
|
selector: 'analog-markdown',
|
|
509
529
|
standalone: true,
|
|
510
|
-
imports: [AsyncPipe],
|
|
511
530
|
hostDirectives: [AnchorNavigationDirective],
|
|
512
531
|
preserveWhitespaces: true,
|
|
513
532
|
encapsulation: ViewEncapsulation.None,
|
|
514
|
-
template:
|
|
515
|
-
#container
|
|
516
|
-
[innerHTML]="content$ | async"
|
|
517
|
-
[class]="classes"
|
|
518
|
-
></div>`,
|
|
533
|
+
template: ` <div [innerHTML]="htmlContent()" [class]="classes()"></div> `,
|
|
519
534
|
}]
|
|
520
|
-
}], ctorParameters: () => []
|
|
521
|
-
type: Input
|
|
522
|
-
}], classes: [{
|
|
523
|
-
type: Input
|
|
524
|
-
}], container: [{
|
|
525
|
-
type: ViewChild,
|
|
526
|
-
args: ['container', { static: true, read: ViewContainerRef }]
|
|
527
|
-
}] } });
|
|
535
|
+
}], ctorParameters: () => [] });
|
|
528
536
|
|
|
529
537
|
/**
|
|
530
538
|
* Generated bundle index. Do not edit.
|
|
531
539
|
*/
|
|
532
540
|
|
|
533
|
-
export { AnchorNavigationDirective, ContentRenderer, MERMAID_IMPORT_TOKEN, AnalogMarkdownComponent as MarkdownComponent, MarkdownContentRendererService, AnalogMarkdownRouteComponent as MarkdownRouteComponent, MarkedContentHighlighter, MarkedSetupService, NoopContentRenderer, injectContent, injectContentFiles, parseRawContentFile, provideContent, withHighlighter, withMarkdownRenderer };
|
|
541
|
+
export { AnchorNavigationDirective, ContentRenderer, MERMAID_IMPORT_TOKEN, AnalogMarkdownComponent as MarkdownComponent, MarkdownContentRendererService, AnalogMarkdownRouteComponent as MarkdownRouteComponent, MarkedContentHighlighter, MarkedSetupService, NoopContentRenderer, injectContent, injectContentFileLoader, injectContentFiles, injectContentFilesMap, injectContentListLoader, parseRawContentFile, provideContent, withContentFileLoader, withContentListLoader, withHighlighter, withMarkdownRenderer };
|
|
534
542
|
//# sourceMappingURL=analogjs-content.mjs.map
|