@acdh-oeaw/keystatic-lib 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5ZKY25OZ.js.map +1 -1
- package/dist/chunk-CI4JBTGG.js.map +1 -1
- package/dist/chunk-EAFZLNV4.js.map +1 -1
- package/dist/{chunk-TQSIK35I.js → chunk-FK3EHKPW.js} +11 -5
- package/dist/chunk-FK3EHKPW.js.map +1 -0
- package/dist/chunk-M7J4ISS4.js.map +1 -1
- package/dist/chunk-ZWZCXCMD.js +10 -0
- package/dist/chunk-ZWZCXCMD.js.map +1 -0
- package/dist/create-component.d.ts +3 -1
- package/dist/create-component.js +1 -1
- package/dist/index.js +2 -2
- package/dist/preview/index.d.ts +1 -1
- package/dist/preview/index.js.map +1 -1
- package/dist/reader.js.map +1 -1
- package/dist/resources.d.ts +12 -3
- package/dist/resources.js +1 -1
- package/package.json +16 -16
- package/dist/chunk-TQSIK35I.js.map +0 -1
- package/dist/chunk-X5LBXMLP.js +0 -10
- package/dist/chunk-X5LBXMLP.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-asset-options.ts"],"names":[],"mappings":";;;AAEO,SAAS,mBAAgD,IAAa,EAAA;AAC5E,EAAO,OAAA;AAAA,IACN,SAAA,EAAW,kBAAkB,IAAI,CAAA,CAAA;AAAA,IACjC,UAAA,EAAY,UAAU,IAAI,CAAA,CAAA;AAAA,IAC1B,kBAAkB,gBAA0B,EAAA;AAC3C,MAAA,OAAO,QAAQ,gBAAkB,EAAA,EAAE,oBAAoB,CAAC,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"sources":["../src/create-asset-options.ts"],"names":[],"mappings":";;;AAEO,SAAS,mBAAgD,IAAa,EAAA;AAC5E,EAAO,OAAA;AAAA,IACN,SAAA,EAAW,kBAAkB,IAAI,CAAA,CAAA;AAAA,IACjC,UAAA,EAAY,UAAU,IAAI,CAAA,CAAA;AAAA,IAC1B,kBAAkB,gBAA0B,EAAA;AAC3C,MAAA,OAAO,QAAQ,gBAAkB,EAAA,EAAE,oBAAoB,CAAC,GAAG,GAAG,CAAA;AAAA;AAC/D,GACD;AACD","file":"chunk-5ZKY25OZ.js","sourcesContent":["import slugify from \"@sindresorhus/slugify\";\n\nexport function createAssetOptions<TPath extends `/${string}/`>(path: TPath) {\n\treturn {\n\t\tdirectory: `./public/assets${path}` as const,\n\t\tpublicPath: `/assets${path}` as const,\n\t\ttransformFilename(originalFilename: string) {\n\t\t\treturn slugify(originalFilename, { preserveCharacters: [\".\"] });\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-label.ts"],"names":[],"mappings":";AAEO,SAAS,WAAA,CAAY,OAAe,MAAgB,EAAA;AAC1D,EAAO,OAAA,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,CAAA
|
|
1
|
+
{"version":3,"sources":["../src/create-label.ts"],"names":[],"mappings":";AAEO,SAAS,WAAA,CAAY,OAAe,MAAgB,EAAA;AAC1D,EAAO,OAAA,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,CAAA;AAC3B","file":"chunk-CI4JBTGG.js","sourcesContent":["import type { Locale } from \"./config\";\n\nexport function createLabel(label: string, locale: Locale) {\n\treturn `${label} (${locale})`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-content-field-options.ts"],"names":[],"mappings":";;;AAEO,SAAS,0BAAuD,SAAkB,EAAA;AACxF,EAAM,MAAA,UAAA,GAAa,mBAAmB,SAAS,CAAA
|
|
1
|
+
{"version":3,"sources":["../src/create-content-field-options.ts"],"names":[],"mappings":";;;AAEO,SAAS,0BAAuD,SAAkB,EAAA;AACxF,EAAM,MAAA,UAAA,GAAa,mBAAmB,SAAS,CAAA;AAC/C,EAAA,MAAM,aAAgB,GAAA,CAAC,CAAG,EAAA,CAAA,EAAG,GAAG,CAAC,CAAA;AAEjC,EAAO,OAAA;AAAA,IACN,OAAS,EAAA,aAAA;AAAA,IACT,KAAO,EAAA;AAAA,GACR;AACD","file":"chunk-EAFZLNV4.js","sourcesContent":["import { createAssetOptions } from \"./create-asset-options\";\n\nexport function createContentFieldOptions<TPath extends `/${string}/`>(assetPath: TPath) {\n\tconst assetPaths = createAssetOptions(assetPath);\n\tconst headingLevels = [2, 3, 4, 5] as const;\n\n\treturn {\n\t\theading: headingLevels,\n\t\timage: assetPaths,\n\t};\n}\n"]}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// src/resources.ts
|
|
2
|
+
function createPaths(path, locale) {
|
|
3
|
+
return {
|
|
4
|
+
assetPath: `/content/assets/${locale}${path}`,
|
|
5
|
+
downloadPath: `/content/downloads/${locale}${path}`
|
|
6
|
+
};
|
|
7
|
+
}
|
|
2
8
|
function createCollectionPaths(path, locale) {
|
|
3
9
|
return {
|
|
4
|
-
|
|
10
|
+
...createPaths(path, locale),
|
|
5
11
|
contentPath: `./content/${locale}${path}*/`
|
|
6
12
|
};
|
|
7
13
|
}
|
|
8
14
|
function createSingletonPaths(path, locale) {
|
|
9
15
|
return {
|
|
10
|
-
|
|
16
|
+
...createPaths(path, locale),
|
|
11
17
|
contentPath: `./content/${locale}${path}`
|
|
12
18
|
};
|
|
13
19
|
}
|
|
@@ -24,6 +30,6 @@ function createSingleton(path, createLocalisedSingletonFactory) {
|
|
|
24
30
|
};
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths };
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
33
|
+
export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
|
|
34
|
+
//# sourceMappingURL=chunk-FK3EHKPW.js.map
|
|
35
|
+
//# sourceMappingURL=chunk-FK3EHKPW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources.ts"],"names":[],"mappings":";AAKO,SAAS,WAAA,CAAyC,MAAa,MAAgB,EAAA;AACrF,EAAO,OAAA;AAAA,IACN,SAAW,EAAA,CAAA,gBAAA,EAAmB,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,IAC3C,YAAc,EAAA,CAAA,mBAAA,EAAsB,MAAM,CAAA,EAAG,IAAI,CAAA;AAAA,GAClD;AACD;AAKO,SAAS,qBAAA,CAAmD,MAAa,MAAgB,EAAA;AAC/F,EAAO,OAAA;AAAA,IACN,GAAG,WAAY,CAAA,IAAA,EAAM,MAAM,CAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA,EAAA;AAAA,GACxC;AACD;AAEO,SAAS,oBAAA,CAAkD,MAAa,MAAgB,EAAA;AAC9F,EAAO,OAAA;AAAA,IACN,GAAG,WAAY,CAAA,IAAA,EAAM,MAAM,CAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA;AAAA,GACxC;AACD;AAEO,SAAS,gBAAA,CAMf,MACA,gCAIC,EAAA;AACD,EAAO,OAAA,SAAS,0BAA0B,MAAiB,EAAA;AAC1D,IAAM,MAAA,KAAA,GAAQ,qBAAsB,CAAA,IAAA,EAAM,MAAM,CAAA;AAChD,IAAO,OAAA,gCAAA,CAAiC,OAAO,MAAM,CAAA;AAAA,GACtD;AACD;AAEO,SAAS,eAAA,CAKf,MACA,+BAIC,EAAA;AACD,EAAO,OAAA,SAAS,yBAAyB,MAAiB,EAAA;AACzD,IAAM,MAAA,KAAA,GAAQ,oBAAqB,CAAA,IAAA,EAAM,MAAM,CAAA;AAC/C,IAAO,OAAA,+BAAA,CAAgC,OAAO,MAAM,CAAA;AAAA,GACrD;AACD","file":"chunk-FK3EHKPW.js","sourcesContent":["import type { Collection, ComponentSchema, Singleton } from \"@keystatic/core\";\n\nimport type { Locale } from \"./config\";\n\n/** @private */\nexport function createPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\tassetPath: `/content/assets/${locale}${path}`,\n\t\tdownloadPath: `/content/downloads/${locale}${path}`,\n\t} as const;\n}\n\n/** @private */\nexport type Paths<TPath extends `/${string}/`> = ReturnType<typeof createPaths<TPath>>;\n\nexport function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\t...createPaths(path, locale),\n\t\tcontentPath: `./content/${locale}${path}*/`,\n\t} as const;\n}\n\nexport function createSingletonPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\t...createPaths(path, locale),\n\t\tcontentPath: `./content/${locale}${path}`,\n\t} as const;\n}\n\nexport function createCollection<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n\tTSlugField extends string,\n>(\n\tpath: TPath,\n\tcreateLocalisedCollectionFactory: (\n\t\tpaths: ReturnType<typeof createCollectionPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Collection<TSchema, TSlugField>,\n) {\n\treturn function createLocalisedCollection(locale: TLocale) {\n\t\tconst paths = createCollectionPaths(path, locale);\n\t\treturn createLocalisedCollectionFactory(paths, locale);\n\t};\n}\n\nexport function createSingleton<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n>(\n\tpath: TPath,\n\tcreateLocalisedSingletonFactory: (\n\t\tpaths: ReturnType<typeof createSingletonPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Singleton<TSchema>,\n) {\n\treturn function createLocalisedSingleton(locale: TLocale) {\n\t\tconst paths = createSingletonPaths(path, locale);\n\t\treturn createLocalisedSingletonFactory(paths, locale);\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/with-i18n-prefix.ts"],"names":[],"mappings":";AAEO,SAAS,cAAA,CACf,OACA,MACC,EAAA;AACD,EAAO,OAAA,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA
|
|
1
|
+
{"version":3,"sources":["../src/with-i18n-prefix.ts"],"names":[],"mappings":";AAEO,SAAS,cAAA,CACf,OACA,MACC,EAAA;AACD,EAAO,OAAA,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAC1B","file":"chunk-M7J4ISS4.js","sourcesContent":["import type { Locale } from \"./config\";\n\nexport function withI18nPrefix<TLabel extends string, TLocale extends Locale>(\n\tlabel: TLabel,\n\tlocale: TLocale,\n) {\n\treturn `${locale}:${label}` as const;\n}\n\nexport type WithoutI18nPrefix<\n\tT extends string,\n\tTLocale extends Locale,\n> = T extends `${TLocale}:${infer U}` ? U : T;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/create-component.ts
|
|
2
|
+
function createComponent(createComponentFactory) {
|
|
3
|
+
return function createComponent2(paths, locale) {
|
|
4
|
+
return createComponentFactory(paths, locale);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { createComponent };
|
|
9
|
+
//# sourceMappingURL=chunk-ZWZCXCMD.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-ZWZCXCMD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-component.ts"],"names":["createComponent"],"mappings":";AAKO,SAAS,gBAId,sBAA+E,EAAA;AAChF,EAAO,OAAA,SAASA,gBAAgB,CAAA,KAAA,EAAqB,MAAiB,EAAA;AACrE,IAAO,OAAA,sBAAA,CAAuB,OAAO,MAAM,CAAA;AAAA,GAC5C;AACD","file":"chunk-ZWZCXCMD.js","sourcesContent":["import type { ContentComponent } from \"@keystatic/core/content-components\";\n\nimport type { Locale } from \"./config\";\nimport type { Paths } from \"./resources\";\n\nexport function createComponent<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTComponents extends Record<string, ContentComponent>,\n>(createComponentFactory: (paths: Paths<TPath>, locale: TLocale) => TComponents) {\n\treturn function createComponent(paths: Paths<TPath>, locale: TLocale) {\n\t\treturn createComponentFactory(paths, locale);\n\t};\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ContentComponent } from '@keystatic/core/content-components';
|
|
2
2
|
import { Locale } from './config.js';
|
|
3
|
+
import { Paths } from './resources.js';
|
|
4
|
+
import '@keystatic/core';
|
|
3
5
|
|
|
4
|
-
declare function createComponent<TPath extends `/${string}/`, TLocale extends Locale, TComponents extends Record<string, ContentComponent>>(createComponentFactory: (
|
|
6
|
+
declare function createComponent<TPath extends `/${string}/`, TLocale extends Locale, TComponents extends Record<string, ContentComponent>>(createComponentFactory: (paths: Paths<TPath>, locale: TLocale) => TComponents): (paths: Paths<TPath>, locale: TLocale) => TComponents;
|
|
5
7
|
|
|
6
8
|
export { createComponent };
|
package/dist/create-component.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createComponent } from './chunk-
|
|
1
|
+
export { createComponent } from './chunk-ZWZCXCMD.js';
|
|
2
2
|
export { createContentFieldOptions } from './chunk-EAFZLNV4.js';
|
|
3
3
|
export { createAssetOptions } from './chunk-5ZKY25OZ.js';
|
|
4
4
|
export { createLabel } from './chunk-CI4JBTGG.js';
|
|
5
5
|
export { withI18nPrefix } from './chunk-M7J4ISS4.js';
|
|
6
|
-
export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './chunk-
|
|
6
|
+
export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './chunk-FK3EHKPW.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/preview/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ interface UseObjectUrlParams {
|
|
|
6
6
|
/** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */
|
|
7
7
|
declare function useObjectUrl(params: UseObjectUrlParams | null): string | null;
|
|
8
8
|
|
|
9
|
-
export { useObjectUrl };
|
|
9
|
+
export { type UseObjectUrlParams, useObjectUrl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preview/index.ts"],"names":["url"],"mappings":";;;AASO,SAAS,aAAa,MAAmC,EAAA;AAC/D,EAAA,MAAM,OAAO,MAAQ,EAAA,IAAA
|
|
1
|
+
{"version":3,"sources":["../../src/preview/index.ts"],"names":["url"],"mappings":";;;AASO,SAAS,aAAa,MAAmC,EAAA;AAC/D,EAAA,MAAM,OAAO,MAAQ,EAAA,IAAA;AACrB,EAAA,MAAM,WAAc,GAAA,MAAA,EAAQ,SAAc,KAAA,KAAA,GAAQ,eAAkB,GAAA,KAAA,CAAA;AAEpE,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAAwB,IAAI,CAAA;AAElD,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,IAAI,QAAQ,IAAM,EAAA;AACjB,MAAA,MAAA,CAAO,IAAI,CAAA;AACX,MAAO,OAAA,KAAA,CAAA;AAAA;AAGR,IAAA,MAAMA,OAAM,GAAI,CAAA,eAAA;AAAA,MACf,IAAI,IAAK,CAAA,CAAC,IAAI,CAAA,EAAG,cAAc,EAAE,IAAA,EAAM,WAAY,EAAA,GAAI,KAAS,CAAA;AAAA,KACjE;AACA,IAAA,MAAA,CAAOA,IAAG,CAAA;AAEV,IAAA,OAAO,MAAM;AACZ,MAAA,GAAA,CAAI,gBAAgBA,IAAG,CAAA;AAAA,KACxB;AAAA,GACE,EAAA,CAAC,WAAa,EAAA,IAAI,CAAC,CAAA;AAEtB,EAAO,OAAA,GAAA;AACR","file":"index.js","sourcesContent":["import { useEffect, useState } from \"react\";\n\nexport interface UseObjectUrlParams {\n\tdata: Uint8Array;\n\textension: string;\n\tfilename: string;\n}\n\n/** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */\nexport function useObjectUrl(params: UseObjectUrlParams | null) {\n\tconst data = params?.data;\n\tconst contentType = params?.extension === \"svg\" ? \"image/svg+xml\" : undefined;\n\n\tconst [url, setUrl] = useState<string | null>(null);\n\n\tuseEffect(() => {\n\t\tif (data == null) {\n\t\t\tsetUrl(null);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst url = URL.createObjectURL(\n\t\t\tnew Blob([data], contentType ? { type: contentType } : undefined),\n\t\t);\n\t\tsetUrl(url);\n\n\t\treturn () => {\n\t\t\tURL.revokeObjectURL(url);\n\t\t};\n\t}, [contentType, data]);\n\n\treturn url;\n}\n"]}
|
package/dist/reader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reader.ts"],"names":["createLocalReader"],"mappings":";;;;;;;AAcO,SAAS,YAAA,CAIf,QACA,qBACC,EAAA;AACD,EAAA,MAAM,eAAe,qBAAwB,IAAA
|
|
1
|
+
{"version":3,"sources":["../src/reader.ts"],"names":["createLocalReader"],"mappings":"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","file":"reader.js","sourcesContent":["import assert from \"node:assert/strict\";\nimport { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { Collection, ComponentSchema, Config, Singleton } from \"@keystatic/core\";\nimport { createReader as createLocalReader } from \"@keystatic/core/reader\";\nimport { createGitHubReader } from \"@keystatic/core/reader/github\";\nimport type { MDXModule } from \"mdx/types\";\n\nimport type { Locale } from \"./config\";\nimport { withI18nPrefix, type WithoutI18nPrefix } from \"./with-i18n-prefix\";\n\ntype GitHubReaderConfig = Parameters<typeof createGitHubReader>[1];\n\nexport function createReader<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetGitHubReaderConfig?: () => GitHubReaderConfig | null,\n) {\n\tconst gitHubConfig = getGitHubReaderConfig?.();\n\n\tif (gitHubConfig != null) {\n\t\treturn createGitHubReader(config, gitHubConfig);\n\t}\n\n\treturn createLocalReader(process.cwd(), config);\n}\n\nexport function createReaders<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n\tTLocale extends Locale,\n\tTMdxContent extends MDXModule,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetMdxContent: (code: string, locale: TLocale, baseUrl: URL) => Promise<TMdxContent>,\n) {\n\tfunction createCollectionResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TCollections & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst collectionName = withI18nPrefix(name, locale);\n\n\t\tconst collectionReader = reader.collections[collectionName];\n\t\tconst collectionConfig = reader.config.collections?.[collectionName];\n\n\t\tassert(collectionConfig?.path);\n\n\t\tfunction baseUrl(id: string) {\n\t\t\treturn pathToFileURL(join(process.cwd(), collectionConfig!.path!.replace(/\\*+/, id)));\n\t\t}\n\n\t\tasync function compile(id: string, code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl(id));\n\t\t}\n\n\t\tfunction list() {\n\t\t\treturn collectionReader.list();\n\t\t}\n\n\t\tasync function read(id: string) {\n\t\t\tconst data = await collectionReader.readOrThrow(id, { resolveLinkedFiles: true });\n\n\t\t\treturn {\n\t\t\t\tcollection: name,\n\t\t\t\tid,\n\t\t\t\tdata,\n\t\t\t\tcompile(code: string) {\n\t\t\t\t\treturn compile(id, code);\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tasync function all() {\n\t\t\tconst ids = await list();\n\n\t\t\treturn Promise.all(ids.map(read));\n\t\t}\n\n\t\treturn {\n\t\t\tall,\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tlist,\n\t\t\tread,\n\t\t};\n\t}\n\n\tfunction createSingletonResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TSingletons & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst i18nName = withI18nPrefix(name, locale);\n\n\t\tconst singletonReader = reader.singletons[i18nName];\n\t\tconst singletonConfig = reader.config.singletons?.[i18nName];\n\n\t\tassert(singletonConfig?.path);\n\n\t\tfunction baseUrl() {\n\t\t\treturn pathToFileURL(join(process.cwd(), singletonConfig!.path!));\n\t\t}\n\n\t\tasync function compile(code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl());\n\t\t}\n\n\t\tasync function read() {\n\t\t\tconst data = await singletonReader.readOrThrow({ resolveLinkedFiles: true });\n\n\t\t\treturn {\n\t\t\t\tsingleton: name,\n\t\t\t\tdata,\n\t\t\t\tcompile,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tread,\n\t\t};\n\t}\n\n\treturn {\n\t\tcreateCollectionResource,\n\t\tcreateSingletonResource,\n\t};\n}\n"]}
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { ComponentSchema, Collection, Singleton } from '@keystatic/core';
|
|
2
2
|
import { Locale } from './config.js';
|
|
3
3
|
|
|
4
|
+
/** @private */
|
|
5
|
+
declare function createPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
|
|
6
|
+
readonly assetPath: `/content/assets/${string}${TPath}`;
|
|
7
|
+
readonly downloadPath: `/content/downloads/${string}${TPath}`;
|
|
8
|
+
};
|
|
9
|
+
/** @private */
|
|
10
|
+
type Paths<TPath extends `/${string}/`> = ReturnType<typeof createPaths<TPath>>;
|
|
4
11
|
declare function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
|
|
5
|
-
readonly assetPath: `/content/${string}${TPath}`;
|
|
6
12
|
readonly contentPath: `./content/${string}${TPath}*/`;
|
|
13
|
+
readonly assetPath: `/content/assets/${string}${TPath}`;
|
|
14
|
+
readonly downloadPath: `/content/downloads/${string}${TPath}`;
|
|
7
15
|
};
|
|
8
16
|
declare function createSingletonPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
|
|
9
|
-
readonly assetPath: `/content/${string}${TPath}`;
|
|
10
17
|
readonly contentPath: `./content/${string}${TPath}`;
|
|
18
|
+
readonly assetPath: `/content/assets/${string}${TPath}`;
|
|
19
|
+
readonly downloadPath: `/content/downloads/${string}${TPath}`;
|
|
11
20
|
};
|
|
12
21
|
declare function createCollection<TPath extends `/${string}/`, TLocale extends Locale, TSchema extends Record<string, ComponentSchema>, TSlugField extends string>(path: TPath, createLocalisedCollectionFactory: (paths: ReturnType<typeof createCollectionPaths<TPath>>, locale: TLocale) => Collection<TSchema, TSlugField>): (locale: TLocale) => Collection<TSchema, TSlugField>;
|
|
13
22
|
declare function createSingleton<TPath extends `/${string}/`, TLocale extends Locale, TSchema extends Record<string, ComponentSchema>>(path: TPath, createLocalisedSingletonFactory: (paths: ReturnType<typeof createSingletonPaths<TPath>>, locale: TLocale) => Singleton<TSchema>): (locale: TLocale) => Singleton<TSchema>;
|
|
14
23
|
|
|
15
|
-
export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths };
|
|
24
|
+
export { type Paths, createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
|
package/dist/resources.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './chunk-
|
|
1
|
+
export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths } from './chunk-FK3EHKPW.js';
|
|
2
2
|
//# sourceMappingURL=resources.js.map
|
|
3
3
|
//# sourceMappingURL=resources.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acdh-oeaw/keystatic-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,29 +25,29 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@acdh-oeaw/commitlint-config": "^2.0.0",
|
|
28
|
-
"@acdh-oeaw/eslint-config": "^2.0.
|
|
29
|
-
"@acdh-oeaw/eslint-config-node": "^2.0.
|
|
30
|
-
"@acdh-oeaw/eslint-config-react": "^2.0.
|
|
28
|
+
"@acdh-oeaw/eslint-config": "^2.0.5",
|
|
29
|
+
"@acdh-oeaw/eslint-config-node": "^2.0.5",
|
|
30
|
+
"@acdh-oeaw/eslint-config-react": "^2.0.6",
|
|
31
31
|
"@acdh-oeaw/prettier-config": "^2.0.0",
|
|
32
32
|
"@acdh-oeaw/tsconfig-lib": "^1.1.1",
|
|
33
33
|
"@changesets/changelog-github": "^0.5.0",
|
|
34
|
-
"@changesets/cli": "^2.27.
|
|
35
|
-
"@commitlint/cli": "^19.
|
|
36
|
-
"@keystatic/core": "^0.5.
|
|
37
|
-
"@types/node": "^22.
|
|
38
|
-
"@types/react": "^18.3.
|
|
39
|
-
"eslint": "^9.
|
|
34
|
+
"@changesets/cli": "^2.27.10",
|
|
35
|
+
"@commitlint/cli": "^19.6.0",
|
|
36
|
+
"@keystatic/core": "^0.5.42",
|
|
37
|
+
"@types/node": "^22.10.1",
|
|
38
|
+
"@types/react": "^18.3.13",
|
|
39
|
+
"eslint": "^9.16.0",
|
|
40
40
|
"eslint-config-flat-gitignore": "^0.3.0",
|
|
41
|
-
"globals": "^15.
|
|
41
|
+
"globals": "^15.13.0",
|
|
42
42
|
"is-ci": "^3.0.1",
|
|
43
43
|
"lint-staged": "^15.2.10",
|
|
44
|
-
"npm-run-all2": "^
|
|
45
|
-
"prettier": "^3.
|
|
44
|
+
"npm-run-all2": "^7.0.1",
|
|
45
|
+
"prettier": "^3.4.2",
|
|
46
46
|
"react": "^18.3.1",
|
|
47
47
|
"simple-git-hooks": "^2.11.1",
|
|
48
|
-
"tsup": "^8.
|
|
49
|
-
"tsx": "^4.19.
|
|
50
|
-
"typescript": "^5.
|
|
48
|
+
"tsup": "^8.3.5",
|
|
49
|
+
"tsx": "^4.19.2",
|
|
50
|
+
"typescript": "^5.7.2"
|
|
51
51
|
},
|
|
52
52
|
"commitlint": {
|
|
53
53
|
"extends": "@acdh-oeaw/commitlint-config"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resources.ts"],"names":[],"mappings":";AAIO,SAAS,qBAAA,CAAmD,MAAa,MAAgB,EAAA;AAC/F,EAAO,OAAA;AAAA,IACN,SAAW,EAAA,CAAA,SAAA,EAAY,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,IACpC,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA,EAAA,CAAA;AAAA,GACxC,CAAA;AACD,CAAA;AAEO,SAAS,oBAAA,CAAkD,MAAa,MAAgB,EAAA;AAC9F,EAAO,OAAA;AAAA,IACN,SAAW,EAAA,CAAA,SAAA,EAAY,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,IACpC,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,GACxC,CAAA;AACD,CAAA;AAEO,SAAS,gBAAA,CAMf,MACA,gCAIC,EAAA;AACD,EAAO,OAAA,SAAS,0BAA0B,MAAiB,EAAA;AAC1D,IAAM,MAAA,KAAA,GAAQ,qBAAsB,CAAA,IAAA,EAAM,MAAM,CAAA,CAAA;AAChD,IAAO,OAAA,gCAAA,CAAiC,OAAO,MAAM,CAAA,CAAA;AAAA,GACtD,CAAA;AACD,CAAA;AAEO,SAAS,eAAA,CAKf,MACA,+BAIC,EAAA;AACD,EAAO,OAAA,SAAS,yBAAyB,MAAiB,EAAA;AACzD,IAAM,MAAA,KAAA,GAAQ,oBAAqB,CAAA,IAAA,EAAM,MAAM,CAAA,CAAA;AAC/C,IAAO,OAAA,+BAAA,CAAgC,OAAO,MAAM,CAAA,CAAA;AAAA,GACrD,CAAA;AACD","file":"chunk-TQSIK35I.js","sourcesContent":["import type { Collection, ComponentSchema, Singleton } from \"@keystatic/core\";\n\nimport type { Locale } from \"./config\";\n\nexport function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\tassetPath: `/content/${locale}${path}`,\n\t\tcontentPath: `./content/${locale}${path}*/`,\n\t} as const;\n}\n\nexport function createSingletonPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\tassetPath: `/content/${locale}${path}`,\n\t\tcontentPath: `./content/${locale}${path}`,\n\t} as const;\n}\n\nexport function createCollection<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n\tTSlugField extends string,\n>(\n\tpath: TPath,\n\tcreateLocalisedCollectionFactory: (\n\t\tpaths: ReturnType<typeof createCollectionPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Collection<TSchema, TSlugField>,\n) {\n\treturn function createLocalisedCollection(locale: TLocale) {\n\t\tconst paths = createCollectionPaths(path, locale);\n\t\treturn createLocalisedCollectionFactory(paths, locale);\n\t};\n}\n\nexport function createSingleton<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n>(\n\tpath: TPath,\n\tcreateLocalisedSingletonFactory: (\n\t\tpaths: ReturnType<typeof createSingletonPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Singleton<TSchema>,\n) {\n\treturn function createLocalisedSingleton(locale: TLocale) {\n\t\tconst paths = createSingletonPaths(path, locale);\n\t\treturn createLocalisedSingletonFactory(paths, locale);\n\t};\n}\n"]}
|
package/dist/chunk-X5LBXMLP.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/create-component.ts
|
|
2
|
-
function createComponent(createComponentFactory) {
|
|
3
|
-
return function createComponent2(assetPath, locale) {
|
|
4
|
-
return createComponentFactory(assetPath, locale);
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { createComponent };
|
|
9
|
-
//# sourceMappingURL=chunk-X5LBXMLP.js.map
|
|
10
|
-
//# sourceMappingURL=chunk-X5LBXMLP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-component.ts"],"names":["createComponent"],"mappings":";AAIO,SAAS,gBAId,sBAA4E,EAAA;AAC7E,EAAO,OAAA,SAASA,gBAAgB,CAAA,SAAA,EAAkB,MAAiB,EAAA;AAClE,IAAO,OAAA,sBAAA,CAAuB,WAAW,MAAM,CAAA,CAAA;AAAA,GAChD,CAAA;AACD","file":"chunk-X5LBXMLP.js","sourcesContent":["import type { ContentComponent } from \"@keystatic/core/content-components\";\n\nimport type { Locale } from \"./config\";\n\nexport function createComponent<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTComponents extends Record<string, ContentComponent>,\n>(createComponentFactory: (assetPath: TPath, locale: TLocale) => TComponents) {\n\treturn function createComponent(assetPath: TPath, locale: TLocale) {\n\t\treturn createComponentFactory(assetPath, locale);\n\t};\n}\n"]}
|