@acdh-oeaw/keystatic-lib 0.5.1 → 0.5.2

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.
@@ -31,5 +31,5 @@ function createSingleton(path, createLocalisedSingletonFactory) {
31
31
  }
32
32
 
33
33
  export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
34
- //# sourceMappingURL=chunk-FK3EHKPW.js.map
35
- //# sourceMappingURL=chunk-FK3EHKPW.js.map
34
+ //# sourceMappingURL=chunk-54FVKF5V.js.map
35
+ //# sourceMappingURL=chunk-54FVKF5V.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;AAIO,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-54FVKF5V.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\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,8 +1,8 @@
1
- import { createAssetOptions } from './chunk-PU3H6JFY.js';
1
+ import { createAssetOptions } from './chunk-ENT7N2ZS.js';
2
2
 
3
3
  // src/create-content-field-options.ts
4
4
  function createContentFieldOptions(paths) {
5
- const assetPaths = createAssetOptions(paths);
5
+ const assetPaths = createAssetOptions(paths.assetPath);
6
6
  const headingLevels = [2, 3, 4, 5];
7
7
  return {
8
8
  heading: headingLevels,
@@ -11,5 +11,5 @@ function createContentFieldOptions(paths) {
11
11
  }
12
12
 
13
13
  export { createContentFieldOptions };
14
- //# sourceMappingURL=chunk-H5A2VGUF.js.map
15
- //# sourceMappingURL=chunk-H5A2VGUF.js.map
14
+ //# sourceMappingURL=chunk-EEB35F4L.js.map
15
+ //# sourceMappingURL=chunk-EEB35F4L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create-content-field-options.ts"],"names":[],"mappings":";;;AAGO,SAAS,0BAAuD,KAAqB,EAAA;AAC3F,EAAM,MAAA,UAAA,GAAa,kBAAmB,CAAA,KAAA,CAAM,SAAS,CAAA;AACrD,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-EEB35F4L.js","sourcesContent":["import { createAssetOptions } from \"./create-asset-options\";\nimport type { Paths } from \"./resources\";\n\nexport function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>) {\n\tconst assetPaths = createAssetOptions(paths.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,10 +1,10 @@
1
1
  import slugify from '@sindresorhus/slugify';
2
2
 
3
3
  // src/create-asset-options.ts
4
- function createAssetOptions(paths) {
4
+ function createAssetOptions(path) {
5
5
  return {
6
- directory: `./public/assets${paths.assetPath}`,
7
- publicPath: `/assets${paths.assetPath}`,
6
+ directory: `./public/assets${path}`,
7
+ publicPath: `/assets${path}`,
8
8
  transformFilename(originalFilename) {
9
9
  return slugify(originalFilename, { preserveCharacters: ["."] });
10
10
  }
@@ -12,5 +12,5 @@ function createAssetOptions(paths) {
12
12
  }
13
13
 
14
14
  export { createAssetOptions };
15
- //# sourceMappingURL=chunk-PU3H6JFY.js.map
16
- //# sourceMappingURL=chunk-PU3H6JFY.js.map
15
+ //# sourceMappingURL=chunk-ENT7N2ZS.js.map
16
+ //# sourceMappingURL=chunk-ENT7N2ZS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create-asset-options.ts"],"names":[],"mappings":";;;AAIO,SAAS,mBACf,IACC,EAAA;AACD,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-ENT7N2ZS.js","sourcesContent":["import slugify from \"@sindresorhus/slugify\";\n\nimport type { Paths } from \"./resources\";\n\nexport function createAssetOptions<TPath extends `/${string}/`>(\n\tpath: Paths<TPath>[\"assetPath\"] | Paths<TPath>[\"downloadPath\"],\n) {\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"]}
@@ -2,9 +2,9 @@ import { Paths } from './resources.js';
2
2
  import '@keystatic/core';
3
3
  import './config.js';
4
4
 
5
- declare function createAssetOptions<TPath extends `/${string}/`>(paths: Paths<TPath>): {
6
- directory: `./public/assets/content/assets/${string}${TPath}`;
7
- publicPath: `/assets/content/assets/${string}${TPath}`;
5
+ declare function createAssetOptions<TPath extends `/${string}/`>(path: Paths<TPath>["assetPath"] | Paths<TPath>["downloadPath"]): {
6
+ directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
7
+ publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
8
8
  transformFilename(originalFilename: string): string;
9
9
  };
10
10
 
@@ -1,3 +1,3 @@
1
- export { createAssetOptions } from './chunk-PU3H6JFY.js';
1
+ export { createAssetOptions } from './chunk-ENT7N2ZS.js';
2
2
  //# sourceMappingURL=create-asset-options.js.map
3
3
  //# sourceMappingURL=create-asset-options.js.map
@@ -5,8 +5,8 @@ import './config.js';
5
5
  declare function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>): {
6
6
  heading: readonly [2, 3, 4, 5];
7
7
  image: {
8
- directory: `./public/assets/content/assets/${string}${TPath}`;
9
- publicPath: `/assets/content/assets/${string}${TPath}`;
8
+ directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
9
+ publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
10
10
  transformFilename(originalFilename: string): string;
11
11
  };
12
12
  };
@@ -1,4 +1,4 @@
1
- export { createContentFieldOptions } from './chunk-H5A2VGUF.js';
2
- import './chunk-PU3H6JFY.js';
1
+ export { createContentFieldOptions } from './chunk-EEB35F4L.js';
2
+ import './chunk-ENT7N2ZS.js';
3
3
  //# sourceMappingURL=create-content-field-options.js.map
4
4
  //# sourceMappingURL=create-content-field-options.js.map
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { createComponent } from './chunk-ZWZCXCMD.js';
2
- export { createContentFieldOptions } from './chunk-H5A2VGUF.js';
3
- export { createAssetOptions } from './chunk-PU3H6JFY.js';
2
+ export { createContentFieldOptions } from './chunk-EEB35F4L.js';
3
+ export { createAssetOptions } from './chunk-ENT7N2ZS.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-FK3EHKPW.js';
6
+ export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './chunk-54FVKF5V.js';
7
7
  //# sourceMappingURL=index.js.map
8
8
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,6 @@ declare function createPaths<TPath extends `/${string}/`>(path: TPath, locale: L
6
6
  readonly assetPath: `/content/assets/${string}${TPath}`;
7
7
  readonly downloadPath: `/content/downloads/${string}${TPath}`;
8
8
  };
9
- /** @private */
10
9
  type Paths<TPath extends `/${string}/`> = ReturnType<typeof createPaths<TPath>>;
11
10
  declare function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
12
11
  readonly contentPath: `./content/${string}${TPath}*/`;
package/dist/resources.js CHANGED
@@ -1,3 +1,3 @@
1
- export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths } from './chunk-FK3EHKPW.js';
1
+ export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths } from './chunk-54FVKF5V.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.5.1",
3
+ "version": "0.5.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
package/readme.md CHANGED
@@ -30,7 +30,7 @@ declare module "@acdh-oeaw/keystatic-lib" {
30
30
  import { createComponent } from "@acdh-oeaw/keystatic-lib";
31
31
  import { wrapper } from "@keystatic/core/content-components";
32
32
 
33
- export const Video = createComponent((assetPath, locale) => {
33
+ export const Video = createComponent((paths, locale) => {
34
34
  return wrapper({
35
35
  label: "Video",
36
36
  schema: {
@@ -78,9 +78,9 @@ export const pages = createCollection("/pages/", (paths, locale) => {
78
78
  }),
79
79
  content: fields.mdx({
80
80
  label: "Content",
81
- options: createContentFieldOptions(paths.assetPath),
81
+ options: createContentFieldOptions(paths),
82
82
  components: {
83
- Video: Video(paths.assetPath, locale),
83
+ Video: Video(paths, locale),
84
84
  },
85
85
  }),
86
86
  },
@@ -1 +0,0 @@
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 +0,0 @@
1
- {"version":3,"sources":["../src/create-content-field-options.ts"],"names":[],"mappings":";;;AAGO,SAAS,0BAAuD,KAAqB,EAAA;AAC3F,EAAM,MAAA,UAAA,GAAa,mBAAmB,KAAK,CAAA;AAC3C,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-H5A2VGUF.js","sourcesContent":["import { createAssetOptions } from \"./create-asset-options\";\nimport type { Paths } from \"./resources\";\n\nexport function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>) {\n\tconst assetPaths = createAssetOptions(paths);\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 +0,0 @@
1
- {"version":3,"sources":["../src/create-asset-options.ts"],"names":[],"mappings":";;;AAIO,SAAS,mBAAgD,KAAqB,EAAA;AACpF,EAAO,OAAA;AAAA,IACN,SAAA,EAAW,CAAkB,eAAA,EAAA,KAAA,CAAM,SAAS,CAAA,CAAA;AAAA,IAC5C,UAAA,EAAY,CAAU,OAAA,EAAA,KAAA,CAAM,SAAS,CAAA,CAAA;AAAA,IACrC,kBAAkB,gBAA0B,EAAA;AAC3C,MAAA,OAAO,QAAQ,gBAAkB,EAAA,EAAE,oBAAoB,CAAC,GAAG,GAAG,CAAA;AAAA;AAC/D,GACD;AACD","file":"chunk-PU3H6JFY.js","sourcesContent":["import slugify from \"@sindresorhus/slugify\";\n\nimport type { Paths } from \"./resources\";\n\nexport function createAssetOptions<TPath extends `/${string}/`>(paths: Paths<TPath>) {\n\treturn {\n\t\tdirectory: `./public/assets${paths.assetPath}` as const,\n\t\tpublicPath: `/assets${paths.assetPath}` as const,\n\t\ttransformFilename(originalFilename: string) {\n\t\t\treturn slugify(originalFilename, { preserveCharacters: [\".\"] });\n\t\t},\n\t};\n}\n"]}