@analogjs/content 3.0.0-alpha.2 → 3.0.0-alpha.4

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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/fesm2022/analogjs-content-og.mjs +34 -46
  3. package/fesm2022/analogjs-content-prism-highlighter.mjs +81 -68
  4. package/fesm2022/analogjs-content-resources.mjs +107 -122
  5. package/fesm2022/analogjs-content-shiki-highlighter.mjs +9 -14
  6. package/fesm2022/analogjs-content.mjs +735 -618
  7. package/og/package.json +2 -2
  8. package/package.json +11 -11
  9. package/plugin/package.json +1 -2
  10. package/plugin/src/index.d.ts +1 -1
  11. package/plugin/src/index.js +3 -1
  12. package/plugin/src/migrations/update-markdown-version/compat.d.ts +2 -1
  13. package/plugin/src/migrations/update-markdown-version/compat.js +4 -2
  14. package/plugin/src/migrations/update-markdown-version/update-markdown-version.d.ts +1 -1
  15. package/prism-highlighter/package.json +2 -2
  16. package/resources/package.json +2 -2
  17. package/shiki-highlighter/package.json +2 -2
  18. package/types/og/src/index.d.ts +2 -0
  19. package/types/og/src/lib/og.d.ts +5 -0
  20. package/types/og/src/lib/options.d.ts +11 -0
  21. package/types/prism-highlighter/src/index.d.ts +8 -0
  22. package/types/prism-highlighter/src/lib/prism/angular.d.ts +1 -0
  23. package/types/prism-highlighter/src/lib/prism-highlighter.d.ts +8 -0
  24. package/types/resources/src/content-file-resource.d.ts +14 -0
  25. package/types/resources/src/content-files-resource.d.ts +3 -0
  26. package/types/resources/src/index.d.ts +2 -0
  27. package/types/shiki-highlighter/src/index.d.ts +7 -0
  28. package/types/src/index.d.ts +15 -0
  29. package/types/src/lib/anchor-navigation.directive.d.ts +9 -0
  30. package/types/src/lib/content-file-loader.d.ts +6 -0
  31. package/types/src/lib/content-file.d.ts +8 -0
  32. package/types/src/lib/content-files-list-token.d.ts +3 -0
  33. package/types/src/lib/content-files-token.d.ts +3 -0
  34. package/types/src/lib/content-list-loader.d.ts +7 -0
  35. package/types/src/lib/content-renderer.d.ts +33 -0
  36. package/types/src/lib/content.d.ts +14 -0
  37. package/types/src/lib/get-content-files.d.ts +14 -0
  38. package/types/src/lib/inject-content-files.d.ts +4 -0
  39. package/types/src/lib/markdown-content-renderer.service.d.ts +10 -0
  40. package/types/src/lib/markdown-route.component.d.ts +15 -0
  41. package/types/src/lib/markdown.component.d.ts +26 -0
  42. package/types/src/lib/marked-content-highlighter.d.ts +17 -0
  43. package/types/src/lib/marked-setup.service.d.ts +10 -0
  44. package/types/src/lib/parse-raw-content-file.d.ts +4 -0
  45. package/types/src/lib/provide-content.d.ts +7 -0
  46. package/types/src/lib/render-task.service.d.ts +8 -0
  47. package/types/src/lib/utils/zone-wait-for.d.ts +2 -0
  48. package/fesm2022/analogjs-content-og.mjs.map +0 -1
  49. package/fesm2022/analogjs-content-prism-highlighter.mjs.map +0 -1
  50. package/fesm2022/analogjs-content-resources.mjs.map +0 -1
  51. package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +0 -1
  52. package/fesm2022/analogjs-content.mjs.map +0 -1
  53. package/og/README.md +0 -3
  54. package/plugin/src/index.js.map +0 -1
  55. package/plugin/src/migrations/update-markdown-renderer-feature/compat.d.ts +0 -2
  56. package/plugin/src/migrations/update-markdown-renderer-feature/compat.js +0 -6
  57. package/plugin/src/migrations/update-markdown-renderer-feature/compat.js.map +0 -1
  58. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.d.ts +0 -2
  59. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js +0 -48
  60. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js.map +0 -1
  61. package/plugin/src/migrations/update-markdown-version/compat.js.map +0 -1
  62. package/plugin/src/migrations/update-markdown-version/update-markdown-version.js.map +0 -1
  63. package/prism-highlighter/README.md +0 -3
  64. package/resources/README.md +0 -3
  65. package/shiki-highlighter/README.md +0 -3
  66. package/types/analogjs-content-og.d.ts +0 -19
  67. package/types/analogjs-content-prism-highlighter.d.ts +0 -15
  68. package/types/analogjs-content-resources.d.ts +0 -20
  69. package/types/analogjs-content-shiki-highlighter.d.ts +0 -11
  70. 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 'satori';
2
- import { html } from 'satori-html';
3
- import sharp from 'sharp';
4
-
5
- // Credit for modified source: https://github.com/etherCorps/sveltekit-og/blob/main/src/lib/api.ts
6
- const generateImage = async (element, options) => {
7
- const elementHtml = html(element);
8
- const svg = await satori(elementHtml, {
9
- width: options.width || 1200,
10
- height: options.height || 630,
11
- fonts: options.fonts?.length ? options.fonts : [],
12
- tailwindConfig: options.tailwindConfig,
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
- class ImageResponse extends Response {
20
- constructor(element, options = {}) {
21
- super();
22
- const body = new ReadableStream({
23
- async start(controller) {
24
- const buffer = await generateImage(element, options);
25
- controller.enqueue(buffer);
26
- controller.close();
27
- },
28
- });
29
- return new Response(body, {
30
- headers: {
31
- 'Content-Type': 'image/png',
32
- 'Cache-Control': options.debug
33
- ? 'no-cache, no-store'
34
- : 'public, immutable, no-transform, max-age=31536000',
35
- ...options.headers,
36
- },
37
- status: options.status || 200,
38
- statusText: options.statusText,
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
- //# sourceMappingURL=analogjs-content-og.mjs.map
35
+
36
+ //# sourceMappingURL=analogjs-content-og.mjs.map
@@ -1,27 +1,25 @@
1
- import { MarkedContentHighlighter, NoopContentRenderer, ContentRenderer } from '@analogjs/content';
2
- import * as i0 from '@angular/core';
3
- import { Injectable } from '@angular/core';
4
- import { markedHighlight } from 'marked-highlight';
5
- import 'prismjs';
6
- import 'prismjs/plugins/toolbar/prism-toolbar';
7
- import 'prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard';
8
-
9
- class PrismHighlighter extends MarkedContentHighlighter {
10
- augmentCodeBlock(code, lang) {
11
- const classes = lang.startsWith('diff') && Prism.languages['diff']
12
- ? `language-${lang} diff-highlight`
13
- : `language-${lang.replace('diff-', '')}`;
14
- return `<pre class="${classes}"><code class="${classes}">${code}</code></pre>`;
15
- }
16
- getHighlightExtension() {
17
- return markedHighlight({
18
- async: true,
19
- highlight: (code, lang) => {
20
- let diff = lang?.startsWith('diff-');
21
- lang = diff ? lang.replace('diff-', '') : lang || 'typescript';
22
- if (diff && !Prism.languages['diff']) {
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
- if (!Prism.languages[lang]) {
34
- if (lang !== 'mermaid') {
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
- return code;
44
- }
45
- return Prism.highlight(code, diff ? Prism.languages['diff'] : Prism.languages[lang], lang);
46
- },
47
- });
48
- }
49
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: PrismHighlighter, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
50
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: PrismHighlighter }); }
51
- }
52
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: PrismHighlighter, decorators: [{
53
- type: Injectable
54
- }] });
55
-
56
- "use strict";
57
- (function () {
58
- if (typeof Prism === 'undefined') {
59
- return;
60
- }
61
- Prism.languages.angular = Prism.languages.extend('markup', {
62
- keyword: /(?:@if|@for|@switch|@defer|@loading|@error|@placeholder|prefetch)\b/,
63
- operator: /\b(?:on|when)\b/,
64
- number: {
65
- pattern: /\b(minimum|after)\s+\d+(?:s|ms|)/gi,
66
- lookbehind: true,
67
- },
68
- builtin: {
69
- pattern: /\b(?:viewport|timer|minimum|after|hover|idle|immediate|interaction)/,
70
- },
71
- function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
72
- });
73
- Prism.languages.ng = Prism.languages.angular;
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
- return [{ provide: ContentRenderer, useClass: NoopContentRenderer }];
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
- //# sourceMappingURL=analogjs-content-prism-highlighter.mjs.map
97
+
98
+ //# sourceMappingURL=analogjs-content-prism-highlighter.mjs.map
@@ -1,129 +1,114 @@
1
- import { resource, inject, computed } from '@angular/core';
2
- import { injectContentListLoader, parseRawContentFile, injectContentFileLoader, ContentRenderer } 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
-
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
- const contentListLoader = injectContentListLoader();
10
- const contentList = contentListLoader().then((items) => filterFn ? items.filter(filterFn) : items);
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
- // Normalize file keys so both "/src/content/..." and "/<project>/src/content/..." resolve.
18
- // This mirrors normalization used elsewhere in the content pipeline.
19
- const normalizedFiles = {};
20
- for (const [key, resolver] of Object.entries(contentFiles)) {
21
- const normalizedKey = key
22
- // replace any prefix up to the content directory with /src/content
23
- // use a non-greedy match so nested paths containing "/content" are preserved
24
- .replace(/^(?:.*?)\/content(?=\/)/, '/src/content')
25
- // normalize duplicate slashes
26
- .replace(/\/{2,}/g, '/');
27
- normalizedFiles[normalizedKey] = resolver;
28
- }
29
- // Try direct file first, then directory index variants
30
- const base = `/src/content/${slug}`.replace(/\/{2,}/g, '/');
31
- const candidates = [
32
- `${base}.md`,
33
- `${base}.agx`,
34
- `${base}/index.md`,
35
- `${base}/index.agx`,
36
- ];
37
- const matchKey = candidates.find((k) => k in normalizedFiles);
38
- const contentFile = matchKey ? normalizedFiles[matchKey] : undefined;
39
- if (!contentFile) {
40
- return {
41
- filename: base,
42
- attributes: {},
43
- slug: '',
44
- content: fallback,
45
- };
46
- }
47
- const resolvedBase = matchKey.replace(/\.(md|agx)$/, '');
48
- return contentFile().then((contentFile) => {
49
- if (typeof contentFile === 'string') {
50
- const { content, attributes } = parseRawContentFile(contentFile);
51
- return {
52
- filename: resolvedBase,
53
- slug,
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
- * Resource for requesting an individual content file
68
- *
69
- * @param params
70
- * @param fallback
71
- * @returns
72
- */
73
- function contentFileResource(params, fallback = 'No Content Found') {
74
- const loaderPromise = injectContentFileLoader();
75
- const contentRenderer = inject(ContentRenderer);
76
- const contentFilesMap = toSignal(from(loaderPromise()));
77
- const input = params ||
78
- toSignal(inject(ActivatedRoute).paramMap.pipe(map((params) => params.get('slug'))), { requireSync: true });
79
- return resource({
80
- params: computed(() => ({ input: input(), files: contentFilesMap() })),
81
- loader: async ({ params }) => {
82
- const { input: param, files } = params;
83
- if (typeof param === 'string') {
84
- if (param) {
85
- const file = await getContentFile(files, param, fallback);
86
- if (typeof file.content === 'string') {
87
- const rendered = (await contentRenderer.render(file.content));
88
- return {
89
- ...file,
90
- toc: rendered.toc ?? [],
91
- };
92
- }
93
- return {
94
- ...file,
95
- toc: [],
96
- };
97
- }
98
- return {
99
- filename: '',
100
- slug: '',
101
- attributes: {},
102
- content: fallback,
103
- toc: [],
104
- };
105
- }
106
- else {
107
- const file = await getContentFile(files, param.customFilename, fallback);
108
- if (typeof file.content === 'string') {
109
- const rendered = (await contentRenderer.render(file.content));
110
- return {
111
- ...file,
112
- toc: rendered.toc ?? [],
113
- };
114
- }
115
- return {
116
- ...file,
117
- toc: [],
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
- //# sourceMappingURL=analogjs-content-resources.mjs.map
113
+
114
+ //# sourceMappingURL=analogjs-content-resources.mjs.map
@@ -1,17 +1,12 @@
1
- import { NoopContentRenderer, ContentRenderer } from '@analogjs/content';
2
-
1
+ import { ContentRenderer, NoopContentRenderer } from "@analogjs/content";
2
+ //#region packages/content/shiki-highlighter/src/index.ts
3
3
  function withShikiHighlighter(_opts = {}) {
4
- return [
5
- {
6
- provide: ContentRenderer,
7
- useClass: NoopContentRenderer,
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
- //# sourceMappingURL=analogjs-content-shiki-highlighter.mjs.map
11
+
12
+ //# sourceMappingURL=analogjs-content-shiki-highlighter.mjs.map