@analogjs/content 2.4.0-beta.1 → 2.4.0-beta.11
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-resources.mjs +3 -2
- package/fesm2022/analogjs-content-resources.mjs.map +1 -1
- package/package.json +1 -1
- package/plugin/package.json +16 -0
- package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js +0 -1
- package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js.map +1 -1
- package/types/analogjs-content-og.d.ts +1 -1
|
@@ -19,8 +19,9 @@ async function getContentFile(contentFiles, slug, fallback) {
|
|
|
19
19
|
const normalizedFiles = {};
|
|
20
20
|
for (const [key, resolver] of Object.entries(contentFiles)) {
|
|
21
21
|
const normalizedKey = key
|
|
22
|
-
// replace any prefix up to
|
|
23
|
-
|
|
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')
|
|
24
25
|
// normalize duplicate slashes
|
|
25
26
|
.replace(/\/{2,}/g, '/');
|
|
26
27
|
normalizedFiles[normalizedKey] = resolver;
|
|
@@ -1 +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 ContentRenderer,\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 // Normalize file keys so both \"/src/content/...\" and \"/<project>/src/content/...\" resolve.\n // This mirrors normalization used elsewhere in the content pipeline.\n const normalizedFiles: Record<string, () => Promise<string>> = {};\n for (const [key, resolver] of Object.entries(contentFiles)) {\n const normalizedKey = key\n // replace any prefix up to
|
|
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 ContentRenderer,\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 // Normalize file keys so both \"/src/content/...\" and \"/<project>/src/content/...\" resolve.\n // This mirrors normalization used elsewhere in the content pipeline.\n const normalizedFiles: Record<string, () => Promise<string>> = {};\n for (const [key, resolver] of Object.entries(contentFiles)) {\n const normalizedKey = key\n // replace any prefix up to the content directory with /src/content\n // use a non-greedy match so nested paths containing \"/content\" are preserved\n .replace(/^(?:.*?)\\/content(?=\\/)/, '/src/content')\n // normalize duplicate slashes\n .replace(/\\/{2,}/g, '/');\n normalizedFiles[normalizedKey] = resolver;\n }\n\n // Try direct file first, then directory index variants\n const base = `/src/content/${slug}`.replace(/\\/{2,}/g, '/');\n const candidates = [\n `${base}.md`,\n `${base}.agx`,\n `${base}/index.md`,\n `${base}/index.agx`,\n ];\n\n const matchKey = candidates.find((k) => k in normalizedFiles);\n const contentFile = matchKey ? normalizedFiles[matchKey] : undefined;\n\n if (!contentFile) {\n return {\n filename: base,\n attributes: {},\n slug: '',\n content: fallback,\n } as ContentFile<Attributes | Record<string, never>>;\n }\n\n const resolvedBase = matchKey!.replace(/\\.(md|agx)$/, '');\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: resolvedBase,\n slug,\n attributes,\n content,\n } as ContentFile<Attributes | Record<string, never>>;\n }\n\n return {\n filename: resolvedBase,\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 contentRenderer = inject(ContentRenderer);\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 const file = await getContentFile<Attributes>(\n files!,\n param,\n fallback,\n );\n if (typeof file.content === 'string') {\n const rendered = (await contentRenderer.render(file.content)) as {\n toc?: Array<{ id: string; level: number; text: string }>;\n };\n return {\n ...file,\n toc: rendered.toc ?? [],\n };\n }\n return {\n ...file,\n toc: [],\n };\n }\n\n return {\n filename: '',\n slug: '',\n attributes: {},\n content: fallback,\n toc: [],\n } as ContentFile<Attributes | Record<string, never>>;\n } else {\n const file = await getContentFile<Attributes>(\n files!,\n param.customFilename,\n fallback,\n );\n if (typeof file.content === 'string') {\n const rendered = (await contentRenderer.render(file.content)) as {\n toc?: Array<{ id: string; level: number; text: string }>;\n };\n return {\n ...file,\n toc: rendered.toc ?? [],\n };\n }\n return {\n ...file,\n toc: [],\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;;ACGA,eAAe,cAAc,CAG3B,YAAmD,EACnD,IAAY,EACZ,QAAgB,EAAA;;;IAIhB,MAAM,eAAe,GAA0C,EAAE;AACjE,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,QA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AAI,CAAC,OAAO,CAAC,CAE3D;wBACD,OAAO;AACL,4BAAA,GAAG,IAAI;AACP,4BAAA,GAAG,EAAE,QAAQ,CAAC,GAAG,IAAI,EAAE;yBACxB;;oBAEH,OAAO;AACL,wBAAA,GAAG,IAAI;AACP,wBAAA,GAAG,EAAE,EAAE;qBACR;;gBAGH,OAAO;AACL,oBAAA,QAAQ,EAAE,EAAE;AACZ,oBAAA,IAAI,EAAE,EAAE;AACR,oBAAA,UAAU,EAAE,EAAE;AACd,oBAAA,OAAO,EAAE,QAAQ;AACjB,oBAAA,GAAG,EAAE,EAAE;iBAC2C;;iBAC/C;AACL,gBAAA,MAAM,IAAI,GAAG,MAAM,cAAc,CAC/B,KAAM,EACN,KAAK,CAAC,cAAc,EACpB,QAAQ,CACT;AACD,gBAAA,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;AACpC,oBAAA,MAAM,QAAQ,IAAI,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAE3D;oBACD,OAAO;AACL,wBAAA,GAAG,IAAI;AACP,wBAAA,GAAG,EAAE,QAAQ,CAAC,GAAG,IAAI,EAAE;qBACxB;;gBAEH,OAAO;AACL,oBAAA,GAAG,IAAI;AACP,oBAAA,GAAG,EAAE,EAAE;iBACR;;SAEJ;AACF,KAAA,CAAC;AACJ;;ACrKA;;AAEG;;;;"}
|
package/package.json
CHANGED
package/plugin/package.json
CHANGED
|
@@ -3,5 +3,21 @@
|
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"ts-morph": "^27.0.0",
|
|
8
|
+
"tslib": "^2.8.1"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@nx/devkit": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0 || ^22",
|
|
12
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependenciesMeta": {
|
|
15
|
+
"@nx/devkit": {
|
|
16
|
+
"optional": true
|
|
17
|
+
},
|
|
18
|
+
"vite": {
|
|
19
|
+
"optional": true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
6
22
|
"types": "./src/index.d.ts"
|
|
7
23
|
}
|
package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const ts_morph_1 = require("ts-morph");
|
|
7
6
|
async function update(host) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-markdown-renderer-feature.js","sourceRoot":"","sources":["../../../../../../../packages/content-plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"update-markdown-renderer-feature.js","sourceRoot":"","sources":["../../../../../../../packages/content-plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.ts"],"names":[],"mappings":";;AASA,yBAuDC;AAhED,uCAMoB;AACpB,uCAAyD;AAE1C,KAAK,UAAU,MAAM,CAAC,IAAU;IAC7C,IAAI,OAAgB,CAAC;IAErB,IAAA,6BAAoB,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,IACE,OAAO;gBACP,OAAO,CAAC,QAAQ,CAAC,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