@alanizcreative/formation-static 1.3.0-beta.29
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/LICENSE +21 -0
- package/README.md +3 -0
- package/cjs/components/Navigation/Navigation.d.ts +16 -0
- package/cjs/components/Navigation/Navigation.js +1 -0
- package/cjs/components/Navigation/NavigationTypes.d.ts +85 -0
- package/cjs/components/Navigation/NavigationTypes.js +1 -0
- package/cjs/components/Pagination/Pagination.d.ts +3 -0
- package/cjs/components/Pagination/Pagination.js +1 -0
- package/cjs/components/Pagination/PaginationTypes.d.ts +44 -0
- package/cjs/components/Pagination/PaginationTypes.js +1 -0
- package/cjs/config/config.d.ts +5 -0
- package/cjs/config/config.js +1 -0
- package/cjs/config/configTypes.d.ts +64 -0
- package/cjs/config/configTypes.js +1 -0
- package/cjs/contentful/contentfulData.d.ts +5 -0
- package/cjs/contentful/contentfulData.js +1 -0
- package/cjs/contentful/contentfulDataNormal.d.ts +4 -0
- package/cjs/contentful/contentfulDataNormal.js +1 -0
- package/cjs/contentful/contentfulDataTypes.d.ts +67 -0
- package/cjs/contentful/contentfulDataTypes.js +1 -0
- package/cjs/global/globalTypes.d.ts +32 -0
- package/cjs/global/globalTypes.js +1 -0
- package/cjs/layouts/Column/Column.d.ts +3 -0
- package/cjs/layouts/Column/Column.js +1 -0
- package/cjs/layouts/Column/ColumnTypes.d.ts +16 -0
- package/cjs/layouts/Column/ColumnTypes.js +1 -0
- package/cjs/layouts/Container/Container.d.ts +3 -0
- package/cjs/layouts/Container/Container.js +1 -0
- package/cjs/layouts/Container/ContainerTypes.d.ts +15 -0
- package/cjs/layouts/Container/ContainerTypes.js +1 -0
- package/cjs/local/localData.d.ts +5 -0
- package/cjs/local/localData.js +1 -0
- package/cjs/local/localDataNormal.d.ts +3 -0
- package/cjs/local/localDataNormal.js +1 -0
- package/cjs/local/localDataTypes.d.ts +14 -0
- package/cjs/local/localDataTypes.js +1 -0
- package/cjs/objects/Form/Form.d.ts +3 -0
- package/cjs/objects/Form/Form.js +1 -0
- package/cjs/objects/Form/FormField.d.ts +3 -0
- package/cjs/objects/Form/FormField.js +1 -0
- package/cjs/objects/Form/FormOption.d.ts +3 -0
- package/cjs/objects/Form/FormOption.js +1 -0
- package/cjs/objects/Form/FormTypes.d.ts +74 -0
- package/cjs/objects/Form/FormTypes.js +1 -0
- package/cjs/package.json +1 -0
- package/cjs/redirects/redirects.d.ts +4 -0
- package/cjs/redirects/redirects.js +1 -0
- package/cjs/redirects/redirectsFile.d.ts +2 -0
- package/cjs/redirects/redirectsFile.js +1 -0
- package/cjs/render/render.d.ts +11 -0
- package/cjs/render/render.js +1 -0
- package/cjs/render/renderInline.d.ts +4 -0
- package/cjs/render/renderInline.js +1 -0
- package/cjs/render/renderTypes.d.ts +198 -0
- package/cjs/render/renderTypes.js +1 -0
- package/cjs/serverless/Ajax/Ajax.d.ts +3 -0
- package/cjs/serverless/Ajax/Ajax.js +1 -0
- package/cjs/serverless/Ajax/AjaxTypes.d.ts +11 -0
- package/cjs/serverless/Ajax/AjaxTypes.js +1 -0
- package/cjs/serverless/Contact/Contact.d.ts +3 -0
- package/cjs/serverless/Contact/Contact.js +1 -0
- package/cjs/serverless/Contact/ContactTypes.d.ts +13 -0
- package/cjs/serverless/Contact/ContactTypes.js +1 -0
- package/cjs/serverless/Preview/Preview.d.ts +5 -0
- package/cjs/serverless/Preview/Preview.js +1 -0
- package/cjs/serverless/Reload/Reload.d.ts +5 -0
- package/cjs/serverless/Reload/Reload.js +1 -0
- package/cjs/serverless/Reload/ReloadTypes.d.ts +5 -0
- package/cjs/serverless/Reload/ReloadTypes.js +1 -0
- package/cjs/serverless/serverless.d.ts +6 -0
- package/cjs/serverless/serverless.js +1 -0
- package/cjs/serverless/serverlessFiles.d.ts +3 -0
- package/cjs/serverless/serverlessFiles.js +1 -0
- package/cjs/serverless/serverlessTypes.d.ts +50 -0
- package/cjs/serverless/serverlessTypes.js +1 -0
- package/cjs/store/store.d.ts +9 -0
- package/cjs/store/store.js +1 -0
- package/cjs/store/storeFiles.d.ts +2 -0
- package/cjs/store/storeFiles.js +1 -0
- package/cjs/store/storeTypes.d.ts +35 -0
- package/cjs/store/storeTypes.js +1 -0
- package/cjs/text/RichText/RichText.d.ts +4 -0
- package/cjs/text/RichText/RichText.js +1 -0
- package/cjs/text/RichText/RichTextTypes.d.ts +54 -0
- package/cjs/text/RichText/RichTextTypes.js +1 -0
- package/cjs/utils/ResponseError/ResponseError.d.ts +5 -0
- package/cjs/utils/ResponseError/ResponseError.js +1 -0
- package/cjs/utils/action/action.d.ts +8 -0
- package/cjs/utils/action/action.js +1 -0
- package/cjs/utils/action/actionTypes.d.ts +10 -0
- package/cjs/utils/action/actionTypes.js +1 -0
- package/cjs/utils/archive/archive.d.ts +7 -0
- package/cjs/utils/archive/archive.js +1 -0
- package/cjs/utils/archive/archiveTypes.d.ts +18 -0
- package/cjs/utils/archive/archiveTypes.js +1 -0
- package/cjs/utils/array/array.d.ts +3 -0
- package/cjs/utils/array/array.js +1 -0
- package/cjs/utils/boolean/boolean.d.ts +2 -0
- package/cjs/utils/boolean/boolean.js +1 -0
- package/cjs/utils/contentType/contentType.d.ts +2 -0
- package/cjs/utils/contentType/contentType.js +1 -0
- package/cjs/utils/dataSource/dataSource.d.ts +3 -0
- package/cjs/utils/dataSource/dataSource.js +1 -0
- package/cjs/utils/dataSource/dataSourceTypes.d.ts +9 -0
- package/cjs/utils/dataSource/dataSourceTypes.js +1 -0
- package/cjs/utils/escape/escape.d.ts +2 -0
- package/cjs/utils/escape/escape.js +1 -0
- package/cjs/utils/excerpt/excerpt.d.ts +3 -0
- package/cjs/utils/excerpt/excerpt.js +1 -0
- package/cjs/utils/excerpt/excerptTypes.d.ts +14 -0
- package/cjs/utils/excerpt/excerptTypes.js +1 -0
- package/cjs/utils/file/filePath.d.ts +2 -0
- package/cjs/utils/file/filePath.js +1 -0
- package/cjs/utils/filter/filter.d.ts +8 -0
- package/cjs/utils/filter/filter.js +1 -0
- package/cjs/utils/filter/filterTypes.d.ts +62 -0
- package/cjs/utils/filter/filterTypes.js +1 -0
- package/cjs/utils/function/function.d.ts +3 -0
- package/cjs/utils/function/function.js +1 -0
- package/cjs/utils/heading/heading.d.ts +2 -0
- package/cjs/utils/heading/heading.js +1 -0
- package/cjs/utils/image/image.d.ts +5 -0
- package/cjs/utils/image/image.js +1 -0
- package/cjs/utils/image/imageLocal.d.ts +3 -0
- package/cjs/utils/image/imageLocal.js +1 -0
- package/cjs/utils/image/imageRemote.d.ts +3 -0
- package/cjs/utils/image/imageRemote.js +1 -0
- package/cjs/utils/image/imageTypes.d.ts +60 -0
- package/cjs/utils/image/imageTypes.js +1 -0
- package/cjs/utils/json/json.d.ts +3 -0
- package/cjs/utils/json/json.js +1 -0
- package/cjs/utils/link/link.d.ts +6 -0
- package/cjs/utils/link/link.js +1 -0
- package/cjs/utils/link/linkShare.d.ts +3 -0
- package/cjs/utils/link/linkShare.js +1 -0
- package/cjs/utils/link/linkTypes.d.ts +31 -0
- package/cjs/utils/link/linkTypes.js +1 -0
- package/cjs/utils/map/map.d.ts +2 -0
- package/cjs/utils/map/map.js +1 -0
- package/cjs/utils/minify/minify.d.ts +2 -0
- package/cjs/utils/minify/minify.js +1 -0
- package/cjs/utils/number/number.d.ts +2 -0
- package/cjs/utils/number/number.js +1 -0
- package/cjs/utils/object/object.d.ts +4 -0
- package/cjs/utils/object/object.js +1 -0
- package/cjs/utils/object/objectUtils.d.ts +2 -0
- package/cjs/utils/object/objectUtils.js +1 -0
- package/cjs/utils/path/path.d.ts +3 -0
- package/cjs/utils/path/path.js +1 -0
- package/cjs/utils/print/print.d.ts +2 -0
- package/cjs/utils/print/print.js +1 -0
- package/cjs/utils/scriptStyle/scriptStyle.d.ts +8 -0
- package/cjs/utils/scriptStyle/scriptStyle.js +1 -0
- package/cjs/utils/scriptStyle/scriptStyleTypes.d.ts +12 -0
- package/cjs/utils/scriptStyle/scriptStyleTypes.js +1 -0
- package/cjs/utils/set/set.d.ts +3 -0
- package/cjs/utils/set/set.js +1 -0
- package/cjs/utils/shortcode/shortcode.d.ts +10 -0
- package/cjs/utils/shortcode/shortcode.js +1 -0
- package/cjs/utils/shortcode/shortcodeTypes.d.ts +20 -0
- package/cjs/utils/shortcode/shortcodeTypes.js +1 -0
- package/cjs/utils/string/string.d.ts +3 -0
- package/cjs/utils/string/string.js +1 -0
- package/cjs/utils/tag/tag.d.ts +4 -0
- package/cjs/utils/tag/tag.js +1 -0
- package/cjs/utils/tag/tagTypes.d.ts +7 -0
- package/cjs/utils/tag/tagTypes.js +1 -0
- package/cjs/utils/year/year.d.ts +2 -0
- package/cjs/utils/year/year.js +1 -0
- package/cjs/wordpress/wordpressData.d.ts +6 -0
- package/cjs/wordpress/wordpressData.js +1 -0
- package/cjs/wordpress/wordpressDataNormal.d.ts +9 -0
- package/cjs/wordpress/wordpressDataNormal.js +1 -0
- package/cjs/wordpress/wordpressDataTypes.d.ts +206 -0
- package/cjs/wordpress/wordpressDataTypes.js +1 -0
- package/lib/components/Navigation/Navigation.d.ts +16 -0
- package/lib/components/Navigation/Navigation.js +1 -0
- package/lib/components/Navigation/NavigationTypes.d.ts +85 -0
- package/lib/components/Navigation/NavigationTypes.js +1 -0
- package/lib/components/Pagination/Pagination.d.ts +3 -0
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/PaginationTypes.d.ts +44 -0
- package/lib/components/Pagination/PaginationTypes.js +1 -0
- package/lib/config/config.d.ts +5 -0
- package/lib/config/config.js +1 -0
- package/lib/config/configTypes.d.ts +64 -0
- package/lib/config/configTypes.js +1 -0
- package/lib/contentful/contentfulData.d.ts +5 -0
- package/lib/contentful/contentfulData.js +1 -0
- package/lib/contentful/contentfulDataNormal.d.ts +4 -0
- package/lib/contentful/contentfulDataNormal.js +1 -0
- package/lib/contentful/contentfulDataTypes.d.ts +67 -0
- package/lib/contentful/contentfulDataTypes.js +1 -0
- package/lib/global/globalTypes.d.ts +32 -0
- package/lib/global/globalTypes.js +1 -0
- package/lib/layouts/Column/Column.d.ts +3 -0
- package/lib/layouts/Column/Column.js +1 -0
- package/lib/layouts/Column/ColumnTypes.d.ts +16 -0
- package/lib/layouts/Column/ColumnTypes.js +1 -0
- package/lib/layouts/Container/Container.d.ts +3 -0
- package/lib/layouts/Container/Container.js +1 -0
- package/lib/layouts/Container/ContainerTypes.d.ts +15 -0
- package/lib/layouts/Container/ContainerTypes.js +1 -0
- package/lib/local/localData.d.ts +5 -0
- package/lib/local/localData.js +1 -0
- package/lib/local/localDataNormal.d.ts +3 -0
- package/lib/local/localDataNormal.js +1 -0
- package/lib/local/localDataTypes.d.ts +14 -0
- package/lib/local/localDataTypes.js +1 -0
- package/lib/objects/Form/Form.d.ts +3 -0
- package/lib/objects/Form/Form.js +1 -0
- package/lib/objects/Form/FormField.d.ts +3 -0
- package/lib/objects/Form/FormField.js +1 -0
- package/lib/objects/Form/FormOption.d.ts +3 -0
- package/lib/objects/Form/FormOption.js +1 -0
- package/lib/objects/Form/FormTypes.d.ts +74 -0
- package/lib/objects/Form/FormTypes.js +1 -0
- package/lib/package.json +1 -0
- package/lib/redirects/redirects.d.ts +4 -0
- package/lib/redirects/redirects.js +1 -0
- package/lib/redirects/redirectsFile.d.ts +2 -0
- package/lib/redirects/redirectsFile.js +1 -0
- package/lib/render/render.d.ts +11 -0
- package/lib/render/render.js +1 -0
- package/lib/render/renderInline.d.ts +4 -0
- package/lib/render/renderInline.js +1 -0
- package/lib/render/renderTypes.d.ts +198 -0
- package/lib/render/renderTypes.js +1 -0
- package/lib/serverless/Ajax/Ajax.d.ts +3 -0
- package/lib/serverless/Ajax/Ajax.js +1 -0
- package/lib/serverless/Ajax/AjaxTypes.d.ts +11 -0
- package/lib/serverless/Ajax/AjaxTypes.js +1 -0
- package/lib/serverless/Contact/Contact.d.ts +3 -0
- package/lib/serverless/Contact/Contact.js +1 -0
- package/lib/serverless/Contact/ContactTypes.d.ts +13 -0
- package/lib/serverless/Contact/ContactTypes.js +1 -0
- package/lib/serverless/Preview/Preview.d.ts +5 -0
- package/lib/serverless/Preview/Preview.js +1 -0
- package/lib/serverless/Reload/Reload.d.ts +5 -0
- package/lib/serverless/Reload/Reload.js +1 -0
- package/lib/serverless/Reload/ReloadTypes.d.ts +5 -0
- package/lib/serverless/Reload/ReloadTypes.js +1 -0
- package/lib/serverless/serverless.d.ts +6 -0
- package/lib/serverless/serverless.js +1 -0
- package/lib/serverless/serverlessFiles.d.ts +3 -0
- package/lib/serverless/serverlessFiles.js +1 -0
- package/lib/serverless/serverlessTypes.d.ts +50 -0
- package/lib/serverless/serverlessTypes.js +1 -0
- package/lib/store/store.d.ts +9 -0
- package/lib/store/store.js +1 -0
- package/lib/store/storeFiles.d.ts +2 -0
- package/lib/store/storeFiles.js +1 -0
- package/lib/store/storeTypes.d.ts +35 -0
- package/lib/store/storeTypes.js +1 -0
- package/lib/text/RichText/RichText.d.ts +4 -0
- package/lib/text/RichText/RichText.js +1 -0
- package/lib/text/RichText/RichTextTypes.d.ts +54 -0
- package/lib/text/RichText/RichTextTypes.js +1 -0
- package/lib/utils/ResponseError/ResponseError.d.ts +5 -0
- package/lib/utils/ResponseError/ResponseError.js +1 -0
- package/lib/utils/action/action.d.ts +8 -0
- package/lib/utils/action/action.js +1 -0
- package/lib/utils/action/actionTypes.d.ts +10 -0
- package/lib/utils/action/actionTypes.js +1 -0
- package/lib/utils/archive/archive.d.ts +7 -0
- package/lib/utils/archive/archive.js +1 -0
- package/lib/utils/archive/archiveTypes.d.ts +18 -0
- package/lib/utils/archive/archiveTypes.js +1 -0
- package/lib/utils/array/array.d.ts +3 -0
- package/lib/utils/array/array.js +1 -0
- package/lib/utils/boolean/boolean.d.ts +2 -0
- package/lib/utils/boolean/boolean.js +1 -0
- package/lib/utils/contentType/contentType.d.ts +2 -0
- package/lib/utils/contentType/contentType.js +1 -0
- package/lib/utils/dataSource/dataSource.d.ts +3 -0
- package/lib/utils/dataSource/dataSource.js +1 -0
- package/lib/utils/dataSource/dataSourceTypes.d.ts +9 -0
- package/lib/utils/dataSource/dataSourceTypes.js +1 -0
- package/lib/utils/escape/escape.d.ts +2 -0
- package/lib/utils/escape/escape.js +1 -0
- package/lib/utils/excerpt/excerpt.d.ts +3 -0
- package/lib/utils/excerpt/excerpt.js +1 -0
- package/lib/utils/excerpt/excerptTypes.d.ts +14 -0
- package/lib/utils/excerpt/excerptTypes.js +1 -0
- package/lib/utils/file/filePath.d.ts +2 -0
- package/lib/utils/file/filePath.js +1 -0
- package/lib/utils/filter/filter.d.ts +8 -0
- package/lib/utils/filter/filter.js +1 -0
- package/lib/utils/filter/filterTypes.d.ts +62 -0
- package/lib/utils/filter/filterTypes.js +1 -0
- package/lib/utils/function/function.d.ts +3 -0
- package/lib/utils/function/function.js +1 -0
- package/lib/utils/heading/heading.d.ts +2 -0
- package/lib/utils/heading/heading.js +1 -0
- package/lib/utils/image/image.d.ts +5 -0
- package/lib/utils/image/image.js +1 -0
- package/lib/utils/image/imageLocal.d.ts +3 -0
- package/lib/utils/image/imageLocal.js +1 -0
- package/lib/utils/image/imageRemote.d.ts +3 -0
- package/lib/utils/image/imageRemote.js +1 -0
- package/lib/utils/image/imageTypes.d.ts +60 -0
- package/lib/utils/image/imageTypes.js +1 -0
- package/lib/utils/json/json.d.ts +3 -0
- package/lib/utils/json/json.js +1 -0
- package/lib/utils/link/link.d.ts +6 -0
- package/lib/utils/link/link.js +1 -0
- package/lib/utils/link/linkShare.d.ts +3 -0
- package/lib/utils/link/linkShare.js +1 -0
- package/lib/utils/link/linkTypes.d.ts +31 -0
- package/lib/utils/link/linkTypes.js +1 -0
- package/lib/utils/map/map.d.ts +2 -0
- package/lib/utils/map/map.js +1 -0
- package/lib/utils/minify/minify.d.ts +2 -0
- package/lib/utils/minify/minify.js +1 -0
- package/lib/utils/number/number.d.ts +2 -0
- package/lib/utils/number/number.js +1 -0
- package/lib/utils/object/object.d.ts +4 -0
- package/lib/utils/object/object.js +1 -0
- package/lib/utils/object/objectUtils.d.ts +2 -0
- package/lib/utils/object/objectUtils.js +1 -0
- package/lib/utils/path/path.d.ts +3 -0
- package/lib/utils/path/path.js +1 -0
- package/lib/utils/print/print.d.ts +2 -0
- package/lib/utils/print/print.js +1 -0
- package/lib/utils/scriptStyle/scriptStyle.d.ts +8 -0
- package/lib/utils/scriptStyle/scriptStyle.js +1 -0
- package/lib/utils/scriptStyle/scriptStyleTypes.d.ts +12 -0
- package/lib/utils/scriptStyle/scriptStyleTypes.js +1 -0
- package/lib/utils/set/set.d.ts +3 -0
- package/lib/utils/set/set.js +1 -0
- package/lib/utils/shortcode/shortcode.d.ts +10 -0
- package/lib/utils/shortcode/shortcode.js +1 -0
- package/lib/utils/shortcode/shortcodeTypes.d.ts +20 -0
- package/lib/utils/shortcode/shortcodeTypes.js +1 -0
- package/lib/utils/string/string.d.ts +3 -0
- package/lib/utils/string/string.js +1 -0
- package/lib/utils/tag/tag.d.ts +4 -0
- package/lib/utils/tag/tag.js +1 -0
- package/lib/utils/tag/tagTypes.d.ts +7 -0
- package/lib/utils/tag/tagTypes.js +1 -0
- package/lib/utils/year/year.d.ts +2 -0
- package/lib/utils/year/year.js +1 -0
- package/lib/wordpress/wordpressData.d.ts +6 -0
- package/lib/wordpress/wordpressData.js +1 -0
- package/lib/wordpress/wordpressDataNormal.d.ts +9 -0
- package/lib/wordpress/wordpressDataNormal.js +1 -0
- package/lib/wordpress/wordpressDataTypes.d.ts +206 -0
- package/lib/wordpress/wordpressDataTypes.js +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Source, GenericStrings } from '../global/globalTypes.js';
|
|
2
|
+
export interface ConfigMeta {
|
|
3
|
+
description: string;
|
|
4
|
+
image: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ConfigEnv {
|
|
7
|
+
dev: boolean;
|
|
8
|
+
prod: boolean;
|
|
9
|
+
build: boolean;
|
|
10
|
+
cache: boolean;
|
|
11
|
+
dir: string;
|
|
12
|
+
devUrl: string;
|
|
13
|
+
prodUrl: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ConfigCms {
|
|
16
|
+
name: string;
|
|
17
|
+
space: string;
|
|
18
|
+
ssl?: boolean;
|
|
19
|
+
prodUser: string;
|
|
20
|
+
prodCredential: string;
|
|
21
|
+
prodHost: string;
|
|
22
|
+
devUser: string;
|
|
23
|
+
devCredential: string;
|
|
24
|
+
devHost: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ConfigLocal {
|
|
27
|
+
dir: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ConfigAsset {
|
|
30
|
+
inputDir: string;
|
|
31
|
+
outputDir: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ConfigImage {
|
|
34
|
+
inputDir: string;
|
|
35
|
+
outputDir: string;
|
|
36
|
+
localUrl: string;
|
|
37
|
+
remoteUrl: string;
|
|
38
|
+
sizes: number[];
|
|
39
|
+
quality: number;
|
|
40
|
+
}
|
|
41
|
+
export type ConfigFilter = (config: Config, env: GenericStrings | NodeJS.Process['env']) => Config;
|
|
42
|
+
export interface Config {
|
|
43
|
+
namespace: string;
|
|
44
|
+
source: Source;
|
|
45
|
+
title: string;
|
|
46
|
+
meta: ConfigMeta;
|
|
47
|
+
partialTypes: string[];
|
|
48
|
+
wholeTypes: string[];
|
|
49
|
+
renderTypes: GenericStrings;
|
|
50
|
+
normalTypes: GenericStrings;
|
|
51
|
+
hierarchicalTypes: string[];
|
|
52
|
+
localeInSlug: Record<string, string>;
|
|
53
|
+
typeInSlug: Record<string, string | Record<string, string>>;
|
|
54
|
+
taxonomyInSlug: Record<string, string | Record<string, string>>;
|
|
55
|
+
env: ConfigEnv;
|
|
56
|
+
cms: ConfigCms;
|
|
57
|
+
local: ConfigLocal;
|
|
58
|
+
scripts: ConfigAsset;
|
|
59
|
+
styles: ConfigAsset;
|
|
60
|
+
image: ConfigImage;
|
|
61
|
+
filter: ConfigFilter;
|
|
62
|
+
}
|
|
63
|
+
export type ConfigSet = (args: Partial<Config>) => Config;
|
|
64
|
+
export type ConfigSetFilter = (env: GenericStrings | NodeJS.Process['env']) => Config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentfulDataParams, AllContentfulDataArgs } from './contentfulDataTypes.js';
|
|
2
|
+
import type { RenderAllData, RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
declare const getContentfulData: (key: string, params?: ContentfulDataParams) => Promise<RenderItem[]>;
|
|
4
|
+
declare const getAllContentfulData: (args?: AllContentfulDataArgs) => Promise<RenderAllData | undefined>;
|
|
5
|
+
export { getContentfulData, getAllContentfulData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import resolveResponse from"contentful-resolve-response";import{ResponseError}from"../utils/ResponseError/ResponseError.js";import{applyFilters}from"../utils/filter/filter.js";import{isObject,isObjectStrict}from"../utils/object/object.js";import{isStringStrict}from"../utils/string/string.js";import{isArray}from"../utils/array/array.js";import{config}from"../config/config.js";import{getStoreItem}from"../store/store.js";import{normalizeContentfulData}from"./contentfulDataNormal.js";const getContentfulData=async(key,params={})=>{if(!isStringStrict(key))throw new Error("No key");if(config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await applyFilters("cacheData",void 0,cacheDataFilterArgs,!0);if(isObject(cacheData))return structuredClone(cacheData)}const{space:space,devCredential:devCredential,prodCredential:prodCredential,devHost:devHost,prodHost:prodHost}=config.cms;let accessToken=devCredential,host=devHost;if(config.env.prod&&(accessToken=prodCredential,host=prodHost),!isStringStrict(space)||!isStringStrict(accessToken)||!isStringStrict(host))throw new Error("No credentials");let url=`https://${host}/spaces/${space}/environments/master/entries?access_token=${accessToken}`;for(const[key,value]of Object.entries(params))url+=`&${key}=${value.toString()}`;const resp=await fetch(url),data=await resp.json();if(!resp.ok)throw new ResponseError("Bad fetch response",resp);const resolvedData=resolveResponse(data),newData=normalizeContentfulData(resolvedData.items);if(config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await applyFilters("cacheData",newData,cacheDataFilterArgs,!0)}return newData},getAllContentfulData=async(args={})=>{const{serverlessData:serverlessData,previewData:previewData}=args;let allData={navigationItem:[],navigation:[],redirect:[],content:{page:[]}};const isServerless=null!=serverlessData,isPreview=null!=previewData,contentfulDataFilterArgs={serverlessData:serverlessData,previewData:previewData};if(isServerless||isPreview){let contentType="",id="";if(isServerless){const item=getStoreItem("slugs")[serverlessData.path];isObjectStrict(item)&&(id=isStringStrict(item.id)?item.id:"",contentType=isStringStrict(item.contentType)?item.contentType:"")}if(isPreview&&(id=previewData.id,contentType=previewData.contentType),id){const key=`serverless_${id}_${contentType}`,params={"sys.id":id,include:10},data=await getContentfulData(key,params);isArray(data)&&(allData.content[contentType]=data)}}if(!isServerless){const partial=config.partialTypes;for(const contentType of partial){allData[contentType]=[];const key=`all_${contentType}`,params={content_type:contentType};let data=await getContentfulData(key,params);data=applyFilters("contentfulData",data,contentfulDataFilterArgs),isArray(data)&&(allData[contentType]=data)}}if(!isServerless&&!isPreview){const whole=config.wholeTypes;for(const contentType of whole){allData.content[contentType]=[];const key=`all_${contentType}`,params={content_type:contentType,include:10};let data=await getContentfulData(key,params);data=applyFilters("contentfulData",data,contentfulDataFilterArgs),isArray(data)&&(allData.content[contentType]=data)}}return allData=applyFilters("allData",allData,{type:"contentful",serverlessData:serverlessData,previewData:previewData}),allData};export{getContentfulData,getAllContentfulData};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContentfulDataItem } from './contentfulDataTypes.js';
|
|
2
|
+
import type { RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
declare const normalizeContentfulData: (data: ContentfulDataItem[], _newData?: RenderItem[]) => RenderItem[];
|
|
4
|
+
export { normalizeContentfulData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeContentType}from"../utils/contentType/contentType.js";import{isArrayStrict}from"../utils/array/array.js";import{isObjectStrict}from"../utils/object/object.js";import{isString,isStringStrict}from"../utils/string/string.js";import{getObjectKeys}from"../utils/object/objectUtils.js";import{isNumber}from"../utils/number/number.js";import{config}from"../config/config.js";const getTag=(type="text")=>{const tag={br:"br",hr:"hr",paragraph:"p",blockquote:"blockquote",bold:"b",italic:"i",underline:"u",superscript:"sup",subscript:"sub",code:"code",hyperlink:"a","entry-hyperlink":"a","asset-hyperlink":"a","heading-1":"h1","heading-2":"h2","heading-3":"h3","heading-4":"h4","heading-5":"h5","heading-6":"h6","list-item":"li","unordered-list":"ul","ordered-list":"ol",table:"table","table-row":"tr","table-cell":"td","table-header-cell":"th",text:""}[type];return isString(tag)?tag:""},normalizeRichText=items=>{const newItems=[];return items.forEach((item=>{if(!isObjectStrict(item))return;const{nodeType:nodeType,data:data,value:value,marks:marks,content:content}=item,tag=getTag(nodeType);let contentValue,link,internalLink;if(isStringStrict(value)&&(contentValue=value,contentValue=contentValue.replace(/\n/g,"<br>"),isArrayStrict(marks))){const markTags=marks.map((m=>getTag(m.type)));contentValue=`${markTags.map((m=>`<${m}>`)).join("")}${value}${markTags.map((m=>`</${m}>`)).join("")}`}if(isStringStrict(content)&&(contentValue=content),isArrayStrict(content)){const contentArr=normalizeRichText(content);contentArr.length>0&&(contentValue=contentArr)}if(isObjectStrict(data)&&(link=isString(data.uri)?data.uri:"",isObjectStrict(data.target))){const target=data.target;"entry-hyperlink"===nodeType&&(internalLink=target);const url=target.fields?.file?.url;"asset-hyperlink"===nodeType&&isString(url)&&(link=url)}if(!contentValue)return;const newItem={content:contentValue};return isStringStrict(tag)&&(newItem.tag=tag),isStringStrict(link)&&(newItem.link=link),isObjectStrict(internalLink)&&(newItem.internalLink=normalizeItem(internalLink,[],!0)),newItems.push(newItem)})),newItems},normalizeFile=(file,fields)=>{const type=isString(file.contentType)?file.contentType:"",format=type?type.split("/")[1]:"";return{url:isString(file.url)?`https:${file.url}`:"",name:isString(file.fileName)?file.fileName:"",alt:isString(fields.description)?fields.description:"",width:isNumber(file.details?.image?.width)?file.details.image.width:0,height:isNumber(file.details?.image?.height)?file.details.image.height:0,size:isNumber(file.details?.size)?file.details.size:0,format:"jpeg"===format?"jpg":format,type:type}},normalizeItem=(item,data,isInternalLink=!1)=>{let newItem={};const itemCopy={...item};isString(itemCopy.sys?.id)&&(newItem.id=itemCopy.sys.id);let type="";if(isString(itemCopy.sys?.type)&&(type=itemCopy.sys.type),isString(itemCopy.sys?.contentType?.sys?.id)&&(type=itemCopy.sys.contentType.sys.id),type&&"Link"!==type&&(newItem.contentType=normalizeContentType(type),isString(config.renderTypes[type])&&(newItem.renderType=config.renderTypes[type])),isArrayStrict(itemCopy.metadata?.tags)&&(newItem.metadata={tags:itemCopy.metadata.tags.map((t=>({id:isString(t.sys?.id)?t.sys.id:"",name:isString(t.sys?.name)?t.sys.name:""})))}),isObjectStrict(itemCopy.fields)){const fields=itemCopy.fields,file=fields.file;if(isObjectStrict(file))return Object.assign(normalizeFile(file,fields),newItem);getObjectKeys(fields).forEach((prop=>{const field=fields[prop];if("content"!==prop||!isInternalLink)if(isObjectStrict(field))if("document"===field.nodeType){const{content:content}=field;isArrayStrict(content)&&(newItem[prop]=content.map((c=>isObjectStrict(c)?normalizeItem(c,data,isInternalLink):c)))}else newItem[prop]=normalizeItem(field,data,"internalLink"===prop);else isArrayStrict(field)?newItem[prop]=field.map((f=>isObjectStrict(f)?normalizeItem(f,data,isInternalLink):f)):newItem[prop]=field}))}if(isString(itemCopy.nodeType)){const nodeType=itemCopy.nodeType;if("embedded-entry-block"===nodeType||"embedded-asset-block"===nodeType){const content=isObjectStrict(itemCopy.data?.target)?itemCopy.data.target:item;newItem=normalizeItem(content,data,isInternalLink)}else newItem.renderType="richText",newItem.tag=getTag(itemCopy.nodeType),isString(itemCopy.content)&&(newItem.content=itemCopy.content),isArrayStrict(itemCopy.content)&&(newItem.content=normalizeRichText(itemCopy.content))}return newItem},normalizeContentfulData=(data,_newData=[])=>isArrayStrict(data)?(data.forEach((item=>{isObjectStrict(item)&&_newData.push(normalizeItem(item,_newData))})),_newData):[];export{normalizeContentfulData};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Generic } from '../global/globalTypes.js';
|
|
2
|
+
import type { RenderServerlessData, RenderPreviewData, RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
export type ContentfulDataParams = Record<string, string | number | boolean>;
|
|
4
|
+
export interface ContentfulDataTag {
|
|
5
|
+
sys?: {
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ContentfulDataMark {
|
|
11
|
+
type: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentfulDataFile {
|
|
14
|
+
url?: string;
|
|
15
|
+
contentType?: string;
|
|
16
|
+
fileName?: string;
|
|
17
|
+
details?: {
|
|
18
|
+
size?: number;
|
|
19
|
+
image?: {
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface ContentfulDataFields extends Generic {
|
|
26
|
+
content?: ContentfulDataItem[] | ContentfulDataItem;
|
|
27
|
+
internalLink?: ContentfulDataItem;
|
|
28
|
+
file?: ContentfulDataFile;
|
|
29
|
+
description?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ContentfulDataSys {
|
|
33
|
+
id?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
contentType?: {
|
|
36
|
+
sys?: {
|
|
37
|
+
id?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ContentfulDataItem {
|
|
42
|
+
value?: string;
|
|
43
|
+
nodeType?: string;
|
|
44
|
+
marks?: ContentfulDataMark[];
|
|
45
|
+
data?: {
|
|
46
|
+
uri?: string;
|
|
47
|
+
target?: ContentfulDataItem;
|
|
48
|
+
};
|
|
49
|
+
content?: ContentfulDataItem[] | string;
|
|
50
|
+
metadata?: {
|
|
51
|
+
tags?: ContentfulDataTag[];
|
|
52
|
+
};
|
|
53
|
+
sys?: ContentfulDataSys;
|
|
54
|
+
fields?: ContentfulDataFields;
|
|
55
|
+
}
|
|
56
|
+
export interface ContentfulData extends Generic {
|
|
57
|
+
items?: ContentfulDataItem[];
|
|
58
|
+
errors?: Generic[];
|
|
59
|
+
}
|
|
60
|
+
export interface ContentfulDataReturn extends Generic {
|
|
61
|
+
items?: RenderItem[];
|
|
62
|
+
errors?: Generic[];
|
|
63
|
+
}
|
|
64
|
+
export interface AllContentfulDataArgs {
|
|
65
|
+
serverlessData?: RenderServerlessData;
|
|
66
|
+
previewData?: RenderPreviewData;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface Taxonomy {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
contentTypes: string[];
|
|
5
|
+
slug?: string;
|
|
6
|
+
link?: string;
|
|
7
|
+
isPage?: boolean;
|
|
8
|
+
usePrimaryContentTypeSlug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface InternalLinkBase {
|
|
11
|
+
id?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
slug?: string;
|
|
14
|
+
link?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
taxonomy?: Taxonomy;
|
|
17
|
+
}
|
|
18
|
+
export interface InternalLink extends InternalLinkBase, Partial<Taxonomy> {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface ParentArgs<T = Generic> {
|
|
22
|
+
renderType: string;
|
|
23
|
+
args: T;
|
|
24
|
+
}
|
|
25
|
+
export interface HtmlString {
|
|
26
|
+
html: string;
|
|
27
|
+
}
|
|
28
|
+
export type Source = 'cms' | 'local' | (string & Record<never, never>);
|
|
29
|
+
export type Generic = Record<string, unknown>;
|
|
30
|
+
export type GenericFunction<T extends (...args: any[]) => any = (...args: any[]) => any> = T;
|
|
31
|
+
export type GenericStrings = Record<string, string>;
|
|
32
|
+
export type GenericNumbers = Record<string, number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyFilters}from"../../utils/filter/filter.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";const Column=props=>{if(!isObjectStrict(props))return[];if(props=applyFilters("columnProps",props),!isObjectStrict(props))return[];const{args:args}=props,{tag:tag="div",classes:classes,style:style,attr:attr}=isObjectStrict(args)?args:{};if(!isStringStrict(tag))return[];let styles="";isStringStrict(style)&&(styles=` style="${style}"`);let attrs="";return isStringStrict(classes)&&(attrs+=` class="${classes}"`),isStringStrict(attr)&&(attrs+=` ${attr}`),[`<${tag}${attrs}${styles}>`,`</${tag}>`]};export{Column};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Generic } from '../../global/globalTypes.js';
|
|
2
|
+
import type { RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
|
|
3
|
+
export interface ColumnArgs extends Generic {
|
|
4
|
+
tag?: string;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
widthSmall?: string | number;
|
|
7
|
+
widthMedium?: string | number;
|
|
8
|
+
widthLarge?: string | number;
|
|
9
|
+
classes?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
attr?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnProps<T = ColumnArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
14
|
+
args: ColumnArgs & T;
|
|
15
|
+
}
|
|
16
|
+
export type ColumnPropsFilter<T = ColumnArgs, R = RenderItem> = (props: ColumnProps<T, R>) => ColumnProps<T, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyFilters}from"../../utils/filter/filter.js";import{isObjectStrict}from"../../utils/object/object.js";import{isStringStrict}from"../../utils/string/string.js";const Container=props=>{if(!isObjectStrict(props))return[];if(props=applyFilters("containerProps",props),!isObjectStrict(props))return[];const{args:args}=props,{tag:tag="div",layoutClasses:layoutClasses,classes:classes,style:style,attr:attr,nest:nest=!1}=isObjectStrict(args)?args:{};if(!isStringStrict(tag))return[];const isSemanticParent=["ul","ol","dl","figure"].includes(tag),hasLayoutClasses=isStringStrict(layoutClasses),hasClasses=isStringStrict(classes),attrs=[],innerAttrs=[],isNested=nest&&hasLayoutClasses,isNestedSemanticParent=isSemanticParent&&isNested,innerClassesArr=[];isNested&&hasLayoutClasses&&innerClassesArr.push(layoutClasses);const outerClassesArr=[];isNested&&hasClasses&&outerClassesArr.push(classes),!isNested&&hasClasses&&outerClassesArr.push(classes),!isNested&&hasLayoutClasses&&outerClassesArr.push(layoutClasses),outerClassesArr.length>0&&attrs.push(`class="${outerClassesArr.join(" ")}"`),innerClassesArr.length>0&&innerAttrs.push(`class="${innerClassesArr.join(" ")}"`);const att=isNestedSemanticParent?innerAttrs:attrs;isStringStrict(attr)&&att.push(attr),isStringStrict(style)&&att.push(`style="${style}"`);let outerTag=tag,innerTag="";isNested&&(outerTag=isSemanticParent?"div":tag,innerTag=isSemanticParent?tag:"div");let start=`<${outerTag}${attrs.length>0?` ${attrs.join(" ")}`:""}>`,end=`</${outerTag}>`;return innerTag&&(start=`${start}<${innerTag}${innerAttrs.length>0?` ${innerAttrs.join(" ")}`:""}>`,end=`</${innerTag}>${end}`),[start,end]};export{Container};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Generic } from '../../global/globalTypes.js';
|
|
2
|
+
import type { RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
|
|
3
|
+
export interface ContainerArgs extends Generic {
|
|
4
|
+
tag?: string;
|
|
5
|
+
maxWidth?: string | number;
|
|
6
|
+
layoutClasses?: string;
|
|
7
|
+
classes?: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
attr?: string;
|
|
10
|
+
nest?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ContainerProps<T = ContainerArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
13
|
+
args: ContainerArgs & T;
|
|
14
|
+
}
|
|
15
|
+
export type ContainerPropsFilter<T = ContainerArgs, R = RenderItem> = (props: ContainerProps<T, R>) => ContainerProps<T, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LocalData, LocalDataArgs, AllLocalDataArgs } from './localDataTypes.js';
|
|
2
|
+
import type { RenderAllData } from '../render/renderTypes.js';
|
|
3
|
+
declare const getLocalData: (args: LocalDataArgs) => Promise<LocalData>;
|
|
4
|
+
declare const getAllLocalData: (args?: AllLocalDataArgs) => Promise<RenderAllData | undefined>;
|
|
5
|
+
export { getLocalData, getAllLocalData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir,readFile}from"node:fs/promises";import{extname,basename,resolve}from"node:path";import{isObject,isObjectStrict}from"../utils/object/object.js";import{isStringStrict}from"../utils/string/string.js";import{applyFilters}from"../utils/filter/filter.js";import{getJson}from"../utils/json/json.js";import{config}from"../config/config.js";import{normalizeLocalData}from"./localDataNormal.js";const getLocalData=async args=>{if(!isObjectStrict(args))throw new Error("No args");const{key:key,refProps:refProps,imageProps:imageProps,unsetProps:unsetProps}=args;if(!isStringStrict(key))throw new Error("No key");if(config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await applyFilters("cacheData",void 0,cacheDataFilterArgs,!0),cacheObj=cacheData?.data;if(isObject(cacheObj))return structuredClone(cacheObj)}const dir=config.local.dir,data={};let hasData=!1;const files=await readdir(resolve(dir));for(const file of files){const fileExt=extname(file),fileName=basename(file,fileExt);if(".json"!==fileExt)continue;const fileContents=await readFile(resolve(dir,file),{encoding:"utf8"}),fileJson=getJson(fileContents);fileJson&&(data[fileName]=fileJson,hasData=!0)}if(!hasData)throw new Error("No data");const newData=normalizeLocalData(data,refProps,imageProps,unsetProps);if(config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await applyFilters("cacheData",{data:newData},cacheDataFilterArgs,!0)}return newData},getAllLocalData=async args=>{const data=await getLocalData({key:"all_file_data",refProps:args?.refProps,imageProps:args?.imageProps,unsetProps:args?.unsetProps});let allData={navigationItem:[],navigation:[],content:{page:[]}};for(const[,value]of Object.entries(data)){const{contentType:contentType}=value;if(!isStringStrict(contentType))continue;const isPartial=config.partialTypes.includes(contentType),isWhole=config.wholeTypes.includes(contentType);if(!isPartial&&!isWhole)continue;const val=applyFilters("localData",value);isPartial&&(null==allData[contentType]&&(allData[contentType]=[]),allData[contentType].push(val)),isWhole&&(null==allData.content[contentType]&&(allData.content[contentType]=[]),allData.content[contentType].push(val))}return allData=applyFilters("allData",allData,{type:"local"}),allData};export{getLocalData,getAllLocalData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject,isObjectStrict}from"../utils/object/object.js";import{isArray,isArrayStrict}from"../utils/array/array.js";import{isStringStrict}from"../utils/string/string.js";import{getStoreItem}from"../store/store.js";const normalizeLocalRefs=(data,refData,imageData,refProps=["internalLink","term","taxonomy"],imageProps=["image"],unsetProps=["content"],contentType)=>{const newData=isArray(data)?[]:{},isTemplate="contentTemplate"===data.renderType,isNavigation="navigation"===contentType,isNavigationItem="navigationItem"===contentType;for(const[key,value]of Object.entries(data)){const isRef=refProps.includes(key),isImage=imageProps.includes(key),isStr=isStringStrict(value),isArr=isArrayStrict(value);let newValue=value;if(isTemplate&&"content"===key&&isArr&&(newValue=value.map((item=>{if(!isStringStrict(item))return item;const ref=refData[item];return isObjectStrict(ref)?{...ref}:void 0}))),(isNavigation&&"items"===key||isNavigationItem&&"children"===key)&&isArr&&(newValue=value.map((id=>isStringStrict(id)?{id:id,title:refData[id]?.title}:null)).filter(Boolean)),isImage&&isStr&&(newValue=imageData[value]?{...imageData[value]}:null),isRef&&isStr){const ref=refData[value];isObjectStrict(ref)&&(newValue={...ref},unsetProps.forEach((prop=>{newValue[prop]&&(newValue[prop]=void 0)})))}isRef&&isArrayStrict(value)&&(newValue=value.map((refKey=>{if(!isStringStrict(refKey))return null;const ref=refData[refKey];if(!isObjectStrict(ref))return null;const newRef={...ref};return unsetProps.forEach((prop=>{newRef[prop]&&(newRef[prop]=void 0)})),newRef})).filter(Boolean)),isObject(newValue)&&(newValue=normalizeLocalRefs(newValue,refData,imageData,refProps,imageProps,unsetProps)),newData[key]=newValue}return newData},normalizeLocalData=(data,refProps,imageProps,unsetProps)=>{const newData={},imageMeta=getStoreItem("imageMeta"),refData={};for(const[key,item]of Object.entries(data))isObjectStrict(item)&&(refData[key]={id:key,...item});for(const[key,item]of Object.entries(refData))newData[key]=normalizeLocalRefs(item,refData,imageMeta,refProps,imageProps,unsetProps,item.contentType);return newData};export{normalizeLocalData};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RenderItem } from '../render/renderTypes.js';
|
|
2
|
+
export type LocalData = Record<string, RenderItem>;
|
|
3
|
+
export type LocalDataItem = Record<string | number, unknown>;
|
|
4
|
+
export interface LocalDataArgs {
|
|
5
|
+
key: string;
|
|
6
|
+
refProps?: string[];
|
|
7
|
+
imageProps?: string[];
|
|
8
|
+
unsetProps?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface AllLocalDataArgs {
|
|
11
|
+
refProps?: string[];
|
|
12
|
+
imageProps?: string[];
|
|
13
|
+
unsetProps?: string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v4 as uuid}from"uuid";import{applyFilters}from"../../utils/filter/filter.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";import{config}from"../../config/config.js";const Form=props=>{if(!isObjectStrict(props))return[];if(props=applyFilters("formProps",props),!isObjectStrict(props))return[];const{args:args}=props,{id:id,formTag:formTag="form",formClasses:formClasses,formAttr:formAttr,fieldsClasses:fieldsClasses,fieldsAttr:fieldsAttr,submitFieldClasses:submitFieldClasses,submitFieldAttr:submitFieldAttr,submitLabel:submitLabel="Submit",submitClasses:submitClasses,submitAttr:submitAttr,honeypot:honeypot=!1,honeypotFieldClasses:honeypotFieldClasses,honeypotFieldAttr:honeypotFieldAttr,honeypotLabelClasses:honeypotLabelClasses,honeypotLabel:honeypotLabel="Website",honeypotClasses:honeypotClasses,honeypotAttr:honeypotAttr}=isObjectStrict(args)?args:{};if(!isStringStrict(id)||!isStringStrict(formTag)||!isStringStrict(submitLabel))return[];const formAttrs=(isStringStrict(formClasses)?` class="${formClasses}"`:"")+(isStringStrict(formAttr)?` ${formAttr}`:""),fieldsTag="form"===formTag?"div":"form",fieldsAttrs=(isStringStrict(fieldsClasses)?` class="${fieldsClasses}"`:"")+(isStringStrict(fieldsAttr)?` ${fieldsAttr}`:"");let honeypotOutput="";if(honeypot){const honeypotId=uuid(),honeypotName=`${config.namespace}_asi`,honeypotFieldAttrs=(isStringStrict(honeypotFieldClasses)?` class="${honeypotFieldClasses}"`:"")+(isStringStrict(honeypotFieldAttr)?` ${honeypotFieldAttr}`:""),honeypotAttrs=(isStringStrict(honeypotClasses)?` class="${honeypotClasses}"`:"")+(isStringStrict(honeypotAttr)?` ${honeypotAttr}`:"");honeypotOutput=`\n <div${honeypotFieldAttrs}>\n <label for="${honeypotId}"${isStringStrict(honeypotLabelClasses)?` class="${honeypotLabelClasses}"`:""}>\n ${honeypotLabel}\n </label>\n <input type="url" name="${honeypotName}" id="${honeypotId}" autocomplete="off"${honeypotAttrs}>\n </div>\n `}return[`\n <${formTag} id="${id}"${formAttrs}>\n <${fieldsTag}${fieldsAttrs}>`,`${honeypotOutput}\n <div${(isStringStrict(submitFieldClasses)?` class="${submitFieldClasses}"`:"")+(isStringStrict(submitFieldAttr)?` ${submitFieldAttr}`:"")}>\n <button type="submit"${(isStringStrict(submitClasses)?` class="${submitClasses}"`:"")+(isStringStrict(submitAttr)?` ${submitAttr}`:"")}>\n ${submitLabel}\n </button>\n </div>\n </${fieldsTag}>\n </${formTag}>\n `]};export{Form};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v4 as uuid}from"uuid";import{applyFilters}from"../../utils/filter/filter.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";const FormField=props=>{if(!isObjectStrict(props))return[];if(props=applyFilters("formFieldProps",props),!isObjectStrict(props))return[];const{args:args}=props,{type:type="text",name:name,label:label,hint:hint,value:value,required:required=!1,attributes:attributes,emptyError:emptyError,invalidError:invalidError,fieldClasses:fieldClasses,fieldAttr:fieldAttr,fieldsetClasses:fieldsetClasses,fieldsetAttr:fieldsetAttr,labelClasses:labelClasses,classes:classes,radioIcon:radioIcon,checkboxIcon:checkboxIcon}=isObjectStrict(args)?args:{},isHidden="hidden"===type;if(!isStringStrict(label)&&!isHidden)return[];let isFieldset="fieldset"===type;if(!isFieldset&&!isStringStrict(name))return[];const isOption="checkbox"===type||"radio"===type,isSelect="select"===type;("checkbox-group"===type||"radio-group"===type)&&(isFieldset=!0);const isTextarea="textarea"===type,hasValue=isStringStrict(value),id=uuid();let optionIcon="",selectIcon="";"radio"===type&&isStringStrict(radioIcon)&&(optionIcon=radioIcon),"checkbox"===type&&isStringStrict(checkboxIcon)&&(optionIcon=checkboxIcon),"select"===type&&isStringStrict(args.selectIcon)&&(selectIcon=args.selectIcon);const requiredIcon=required&&isStringStrict(args.requiredIcon)?args.requiredIcon:"",fieldAttrs=["data-form-field"],fieldsetAttrs=[],attrs=["data-form-input"];if(isStringStrict(attributes)){const attrsArr=attributes.split("\n");for(const attr of attrsArr){const[attrName,attrValue]=attr.split(" : ");isStringStrict(attrName)&&isStringStrict(attrValue)&&attrs.push(`${attrName}="${attrValue}"`)}}isTextarea||isSelect||!hasValue||attrs.push(`value="${value}"`),isStringStrict(classes)&&attrs.push(`class="${classes}"`),isStringStrict(fieldClasses)&&fieldAttrs.push(`class="${fieldClasses}"`),isStringStrict(fieldsetClasses)&&fieldsetAttrs.push(`class="${fieldsetClasses}"`),isStringStrict(fieldAttr)&&fieldAttrs.push(fieldAttr),isStringStrict(fieldsetAttr)&&fieldsetAttrs.push(fieldsetAttr),isStringStrict(emptyError)&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(`data-form-empty="${emptyError}"`),isStringStrict(invalidError)&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(`data-form-invalid="${invalidError}"`),required&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(isFieldset?"data-form-required":"required");const fieldAtts=` ${fieldAttrs.join(" ")}`,fieldsetAtts=fieldsetAttrs.length>0?` ${fieldsetAttrs.join(" ")}`:"",atts=` ${attrs.join(" ")}`;let hintOutput="";isStringStrict(hint)&&(hintOutput=`<small data-form-hint>${hint}</small>`);let labelBefore="",labelAfter="";const labelClass=isStringStrict(labelClasses)?` class="${labelClasses}"`:"";isFieldset?labelBefore=`\n <legend id="${uuid()}"${labelClass}>\n <span data-form-legend>\n <span data-form-legend-text>${label}</span>\n ${requiredIcon}\n </span>\n ${hintOutput}\n </legend>\n `:isOption?labelAfter=`\n <label for="${id}"${labelClass}>\n <span data-form-option>\n ${optionIcon}\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${requiredIcon}\n </span>\n </span>\n ${hintOutput}\n </label>\n `:labelBefore=`\n <label for="${id}"${labelClass}>\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${requiredIcon}\n </span>\n ${hintOutput}\n </label>\n `;let beforeOutput="",afterOutput="";switch(type){case"text":case"email":case"checkbox":case"radio":case"number":case"password":case"tel":case"url":case"hidden":beforeOutput=`<input type="${type}" name="${name}" id="${id}"${atts}>`;break;case"textarea":beforeOutput=`<textarea name="${name}" id="${id}"${atts}>${hasValue?value:""}</textarea>`;break;case"select":beforeOutput=`\n <div data-form-select>\n <select name="${name}" id="${id}"${atts}>`,afterOutput=`\n </select>\n ${selectIcon}\n </div>`}return isHidden?[beforeOutput]:[`\n <div${fieldAtts}>\n ${isFieldset?`<fieldset${fieldsetAtts}>`:""}\n ${labelBefore}\n ${isFieldset?"<div data-form-group>":""}\n ${beforeOutput}`,`${afterOutput}\n ${labelAfter}\n ${isFieldset?"</div></fieldset>":""}\n </div>\n `]};export{FormField};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v4 as uuid}from"uuid";import{applyFilters}from"../../utils/filter/filter.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";import{isArrayStrict}from"../../utils/array/array.js";const FormOption=props=>{if(!isObjectStrict(props))return"";if(props=applyFilters("formOptionProps",props),!isObjectStrict(props))return"";const{args:args,parents:parents}=props,{label:label,value:value="",name:name,hint:hint,selected:selected,radioIcon:radioIcon,checkboxIcon:checkboxIcon,optionClasses:optionClasses,labelClasses:labelClasses,classes:classes}=isObjectStrict(args)?args:{};if(!isStringStrict(label))return"";if(!isArrayStrict(parents))return"";const fieldParent=parents[0];if(!isObjectStrict(fieldParent))return"";const{renderType:renderType,args:fieldArgs}=fieldParent;if("formField"!==renderType)return"";const{name:fieldName,type:fieldType}=fieldArgs,isRadioGroup="radio-group"===fieldType,isCheckboxGroup="checkbox-group"===fieldType,isSelect="select"===fieldType;if(!isRadioGroup&&!isCheckboxGroup&&!isSelect)return"";if(isSelect)return`<option value="${value}"${selected?" selected":""}>${label}</option>`;const inputName=name||fieldName;if(!isStringStrict(inputName))return"";const id=uuid();let optionIcon="";isRadioGroup&&isStringStrict(radioIcon)&&(optionIcon=radioIcon),isCheckboxGroup&&isStringStrict(checkboxIcon)&&(optionIcon=checkboxIcon);let hintOutput="";return isStringStrict(hint)&&(hintOutput=`<small data-form-hint>${hint}</small>`),`\n <div${isStringStrict(optionClasses)?` class="${optionClasses}"`:""}>\n <input\n type="${isRadioGroup?"radio":"checkbox"}"\n value="${value}"\n name="${inputName}"\n id="${id}"\n ${isStringStrict(classes)?` class="${classes}"`:""}\n data-form-input\n ${selected?" checked":""}\n >\n <label for="${id}"${isStringStrict(labelClasses)?` class="${labelClasses}"`:""}>\n <span data-form-option>\n ${optionIcon}\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${hintOutput}\n </span>\n </span>\n </label>\n </div>\n `};export{FormOption};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Generic, ParentArgs } from '../../global/globalTypes.js';
|
|
2
|
+
import type { RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
|
|
3
|
+
export interface FormArgs extends Generic {
|
|
4
|
+
id?: string;
|
|
5
|
+
formTag?: string;
|
|
6
|
+
formClasses?: string;
|
|
7
|
+
formAttr?: string;
|
|
8
|
+
fieldsClasses?: string;
|
|
9
|
+
fieldsAttr?: string;
|
|
10
|
+
submitFieldClasses?: string;
|
|
11
|
+
submitFieldAttr?: string;
|
|
12
|
+
submitLabel?: string;
|
|
13
|
+
submitClasses?: string;
|
|
14
|
+
submitAttr?: string;
|
|
15
|
+
honeypot?: boolean;
|
|
16
|
+
honeypotFieldClasses?: string;
|
|
17
|
+
honeypotFieldAttr?: string;
|
|
18
|
+
honeypotLabelClasses?: string;
|
|
19
|
+
honeypotClasses?: string;
|
|
20
|
+
honeypotLabel?: string;
|
|
21
|
+
honeypotAttr?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FormProps<T = FormArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
24
|
+
args: FormArgs & T;
|
|
25
|
+
}
|
|
26
|
+
export interface FormMeta {
|
|
27
|
+
subject?: string;
|
|
28
|
+
toEmail?: string;
|
|
29
|
+
senderEmail?: string;
|
|
30
|
+
}
|
|
31
|
+
export type FormPropsFilter<T = FormArgs, R = RenderItem> = (props: FormProps<T, R>) => FormProps<T, R>;
|
|
32
|
+
export type FormFieldType = 'text' | 'email' | 'checkbox' | 'radio' | 'number' | 'password' | 'tel' | 'url' | 'textarea' | 'select' | 'radio-group' | 'checkbox-group' | 'fieldset' | 'hidden';
|
|
33
|
+
export interface FormFieldArgs extends Generic {
|
|
34
|
+
type?: FormFieldType;
|
|
35
|
+
name?: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
hint?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
required?: boolean;
|
|
40
|
+
attributes?: string;
|
|
41
|
+
emptyError?: string;
|
|
42
|
+
invalidError?: string;
|
|
43
|
+
fieldsetClasses?: string;
|
|
44
|
+
fieldsetAttr?: string;
|
|
45
|
+
fieldClasses?: string;
|
|
46
|
+
fieldAttr?: string;
|
|
47
|
+
labelClasses?: string;
|
|
48
|
+
classes?: string;
|
|
49
|
+
radioIcon?: string;
|
|
50
|
+
checkboxIcon?: string;
|
|
51
|
+
selectIcon?: string;
|
|
52
|
+
requiredIcon?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface FormFieldProps<T = FormFieldArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
55
|
+
args: FormFieldArgs & T;
|
|
56
|
+
}
|
|
57
|
+
export type FormFieldPropsFilter<T = FormFieldArgs, R = RenderItem> = (props: FormFieldProps<T, R>) => FormFieldProps<T, R>;
|
|
58
|
+
export interface FormOptionArgs extends Generic {
|
|
59
|
+
label?: string;
|
|
60
|
+
value?: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
hint?: string;
|
|
63
|
+
selected?: boolean;
|
|
64
|
+
optionClasses?: string;
|
|
65
|
+
labelClasses?: string;
|
|
66
|
+
classes?: string;
|
|
67
|
+
radioIcon?: string;
|
|
68
|
+
checkboxIcon?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface FormOptionProps<T = FormOptionArgs, R = RenderItem, P = ParentArgs & FormFieldProps> extends RenderFunctionArgs<T, R, P> {
|
|
71
|
+
args: FormOptionArgs & T;
|
|
72
|
+
parents?: P[];
|
|
73
|
+
}
|
|
74
|
+
export type FormOptionPropsFilter<T = FormOptionArgs, R = RenderItem> = (props: FormOptionProps<T, R>) => FormOptionProps<T, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/lib/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isArrayStrict}from"../utils/array/array.js";import{isObjectStrict}from"../utils/object/object.js";let redirects=[];const setRedirects=data=>!!isArrayStrict(data)&&(redirects=[],data.forEach((item=>{if(!isObjectStrict(item))return;const{redirect:redirect}=item;isArrayStrict(redirect)&&(redirects=redirects.concat(redirect))})),redirects.length>1);export{redirects,setRedirects};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir,writeFile}from"node:fs/promises";import{resolve,dirname}from"node:path";import{print}from"../utils/print/print.js";import{redirects}from"./redirects.js";const createRedirectsFile=async(path="site/_redirects")=>{const redirectsPath=resolve(path),redirectsDir=dirname(redirectsPath);await mkdir(redirectsDir,{recursive:!0}),await writeFile(redirectsPath,redirects.join("\n").trimEnd()),print("[FRM] Successfully wrote",redirectsPath,"success")};export{createRedirectsFile};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RenderContentArgs, RenderItemArgs, RenderItemReturn, RenderArgs, RenderReturn, RenderFunctions, RenderLayout, RenderHttpError, RenderNavigations, RenderFunctionsArgs } from './renderTypes.js';
|
|
2
|
+
import type { HtmlString } from '../global/globalTypes.js';
|
|
3
|
+
declare let renderFunctions: RenderFunctions;
|
|
4
|
+
declare let renderLayout: RenderLayout;
|
|
5
|
+
declare let renderHttpError: RenderHttpError;
|
|
6
|
+
declare let renderNavigations: RenderNavigations;
|
|
7
|
+
declare const setRenderFunctions: (args: RenderFunctionsArgs) => boolean;
|
|
8
|
+
declare const renderContent: (args: RenderContentArgs, _output?: HtmlString) => Promise<string>;
|
|
9
|
+
declare const renderItem: (args: RenderItemArgs, _contentType?: string) => Promise<RenderItemReturn | null>;
|
|
10
|
+
declare const render: (args: RenderArgs) => Promise<RenderReturn[] | RenderReturn>;
|
|
11
|
+
export { render, renderItem, renderContent, renderFunctions, renderLayout, renderNavigations, renderHttpError, setRenderFunctions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{doActions}from"../utils/action/action.js";import{applyFilters}from"../utils/filter/filter.js";import{getSlug,getPermalink}from"../utils/link/link.js";import{isString,isStringStrict}from"../utils/string/string.js";import{isArray,isArrayStrict}from"../utils/array/array.js";import{isObjectStrict}from"../utils/object/object.js";import{isNumber}from"../utils/number/number.js";import{isFunction}from"../utils/function/function.js";import{doShortcodes}from"../utils/shortcode/shortcode.js";import{tagExists}from"../utils/tag/tag.js";import{setStoreData,setStoreItem,getStoreItem}from"../store/store.js";import{setRedirects}from"../redirects/redirects.js";import{serverlessRoutes}from"../serverless/serverless.js";import{scripts,styles}from"../utils/scriptStyle/scriptStyle.js";import{Container}from"../layouts/Container/Container.js";import{Column}from"../layouts/Column/Column.js";import{Form}from"../objects/Form/Form.js";import{FormField}from"../objects/Form/FormField.js";import{FormOption}from"../objects/Form/FormOption.js";import{RichText}from"../text/RichText/RichText.js";const defaultRenderFunctions={container:Container,column:Column,form:Form,formField:FormField,formOption:FormOption,richText:RichText};let renderFunctions={...defaultRenderFunctions},renderLayout=()=>"",renderHttpError=()=>"",renderNavigations=()=>{};const setRenderFunctions=args=>{if(!isObjectStrict(args))return!1;const{functions:functions,layout:layout,navigations:navigations,httpError:httpError}=args;return!(!isObjectStrict(functions)||!isFunction(layout))&&(renderFunctions={...defaultRenderFunctions,...functions},renderLayout=layout,isFunction(navigations)&&(renderNavigations=navigations),isFunction(httpError)&&(renderHttpError=httpError),!0)},getContentTemplate=(content,templates=[],named=!1)=>{if(!isArrayStrict(content))return{content:[],namedContent:{},templates:templates};const namedContent={};return{content:content.map((c=>(named&&isString(c.name)&&(namedContent[c.name]={...c}),tagExists(c,"template")?(templates.push({...c}),{metadata:{tags:[{id:"templateBreak",name:""}]}}):c))),namedContent:namedContent,templates:templates}},mapContentTemplate=(templates,content=[],namedContent={},named=!1)=>{if(!isArrayStrict(templates))return templates;const lastTemplateIndex=templates.length-1;return templates.forEach(((t,i)=>{content[0]&&tagExists(content[0],"templateBreak")&&content.length>=1&&content.shift();if(tagExists(t,"templateOptional")&&i===lastTemplateIndex&&!content.length)return void templates.pop();const isSlot=tagExists(t,"templateSlot");let children=t.content;if(isArrayStrict(children)&&!isSlot){let repeat;const newChildren=[...children],repeatIndex=children.findIndex((c=>{const isRepeat=tagExists(c,"templateRepeat");return isRepeat&&(repeat=c),isRepeat}));if(-1!==repeatIndex&&repeat){let breakIndex=content.findIndex((c=>tagExists(c,"templateBreak")));breakIndex=-1===breakIndex?content.length:breakIndex;let insertIndex=repeatIndex;for(let j=insertIndex;j<breakIndex-1;j+=1)newChildren.splice(insertIndex,0,{...repeat}),insertIndex=j}children=newChildren}if(isSlot&&content.length>=1){let fill=null;return fill=named?namedContent[t.name]:content.shift(),void(fill&&(templates[i]=fill))}isArray(children)&&templates[i]&&(templates[i].content=mapContentTemplate(children,content,namedContent,named))})),templates},renderContent=async(args,_output={html:""})=>{if(!isObjectStrict(args))return _output.html;const{content:content=[],serverlessData:serverlessData,previewData:previewData,pageData:pageData,pageContains:pageContains=[],pageHeadings:pageHeadings=[],navigations:navigations,parents:parents=[],depth:depth=0}=args;let{headingsIndex:headingsIndex=-1}=args;if(!isArrayStrict(content))return _output.html;for(const item of content){if(!isObjectStrict(item))continue;const props={...item},renderType=isString(props.renderType)?props.renderType:"",contentAttr=props.contentIsAttribute,isRichText="richText"===renderType;let childrenArr,children=props.content;if("contentTemplate"===renderType){const isNamed=tagExists(item,"templateNamed"),template=getContentTemplate(isArray(props.content)?props.content:[],[],isNamed);children=mapContentTemplate(template.templates,template.content,template.namedContent,isNamed)}let childrenStr="";isArrayStrict(children)&&!isRichText&&(childrenArr=children),isStringStrict(children)&&!isRichText&&(childrenStr=children),"content"===renderType&&0===depth&&(headingsIndex=pageHeadings.push([])-1),isStringStrict(contentAttr)&&(props[contentAttr]=children,props.content=void 0,childrenArr=void 0);let renderStart="",renderEnd="",filterType="",filterArgs={};const renderFunction=renderFunctions[renderType];if(isFunction(renderFunction)){const renderArgs={args:props,parents:parents,pageData:pageData,pageContains:pageContains,navigations:navigations,serverlessData:serverlessData,previewData:previewData};childrenArr&&(renderArgs.children=childrenArr),"richText"===renderType&&(renderArgs.headings=pageHeadings[headingsIndex]);let renderOutput=await renderFunction(renderArgs);if(isArrayStrict(renderOutput)){1===renderOutput.length&&(renderOutput=renderOutput[0]?.split("%content")??["",""]);const[start,end]=renderOutput;isString(start)&&(renderStart=start),isString(end)&&(renderEnd=end)}isString(renderOutput)&&(renderStart=renderOutput),pageContains.push(renderType),filterType=renderType,filterArgs={...props,content:void 0}}const renderContentFilterArgs={renderType:filterType,args:filterArgs},[filterRenderStart,filterRenderEnd]=await applyFilters("renderContent",[renderStart,renderEnd],renderContentFilterArgs,!0);if(isString(filterRenderStart)&&(renderStart=filterRenderStart),isString(filterRenderEnd)&&(renderEnd=filterRenderEnd),_output.html+=renderStart+childrenStr,childrenArr){const parentsCopy=[...parents];renderType&&parentsCopy.unshift({renderType:renderType,args:{...props,content:void 0,parents:void 0}}),await renderContent({content:childrenArr,serverlessData:serverlessData,previewData:previewData,parents:parentsCopy,pageData:pageData,pageContains:pageContains,pageHeadings:pageHeadings,navigations:navigations,headingsIndex:headingsIndex,depth:depth+1},_output)}_output.html+=renderEnd}return _output.html},renderItem=async(args,_contentType)=>{if(!isObjectStrict(args))return null;const{item:item,serverlessData:serverlessData,previewData:previewData}=args;if(!isObjectStrict(item))return null;const contentType=item.contentType;if(!isStringStrict(contentType))return null;if("taxonomy"===contentType&&!0!==item.isPage)return null;const id=item.id;if(!isStringStrict(id))return null;if(!isStringStrict(item.slug))return null;let serverlessRender=!1;const pageContains=[],pageHeadings=[];scripts.deps.clear(),scripts.item.clear(),scripts.meta={},styles.deps.clear(),styles.item.clear();const renderItemStartArgs={id:id,pageData:{...item},contentType:contentType,pageContains:[],pageHeadings:[],serverlessData:serverlessData,previewData:previewData};await doActions("renderItemStart",renderItemStartArgs,!0);const title=item.title,meta={title:"",description:"",url:"",image:"",canonical:"",prev:"",next:"",noIndex:!1,isIndex:!1,...item.meta};isStringStrict(item.metaTitle)&&(meta.title=item.metaTitle),isStringStrict(item.metaDescription)&&(meta.description=item.metaDescription),isStringStrict(item.metaImage?.url)&&(meta.image=item.metaImage.url),!isStringStrict(meta.title)&&isStringStrict(title)&&(meta.title=title);const taxonomy="term"===contentType?item.taxonomy:"taxonomy"===contentType?item:{},slugArgs={id:id,contentType:contentType,slug:item.slug,returnParents:!0,pageData:item,page:0},s=getSlug(slugArgs,!0),slug=s.slug,slugIsHtml=slug.includes(".html"),permalink=getPermalink(slug,!slugIsHtml),parents=s.parents;item.baseUrl=permalink,meta.url=permalink,meta.canonical=permalink;let formattedSlug="index"!==slug&&""!==slug?`/${slug}/`:"/";slugIsHtml&&(formattedSlug=slug),setStoreItem("slugs",{id:id,contentType:isStringStrict(_contentType)?_contentType:contentType},slugIsHtml?`/${slug}`:formattedSlug);const index="index"===item.slug;let navigations,itemServerlessData;if(meta.isIndex=index,isFunction(renderNavigations)){let currentType=contentType;isObjectStrict(taxonomy)&&isArrayStrict(taxonomy.contentTypes)&&(currentType=taxonomy.contentTypes),navigations=await renderNavigations({navigations:getStoreItem("navigations"),items:getStoreItem("navigationItems"),currentLink:permalink,currentType:currentType,title:title,parents:parents})}if(isObjectStrict(serverlessData)){if(!(serverlessData.path===formattedSlug&&null!=serverlessData.query))return{serverlessRender:!1};itemServerlessData=serverlessData}const pageData={...item};pageData.id=id,pageData.parents=parents,pageData.content=void 0;let contentOutput="";const contentData=item.content;isStringStrict(contentData)&&(contentOutput=contentData),isArrayStrict(contentData)&&(contentOutput=await renderContent({content:contentData,serverlessData:itemServerlessData,parents:[],pageData:pageData,pageContains:pageContains,pageHeadings:pageHeadings,navigations:navigations,previewData:previewData})),contentOutput=await doShortcodes(contentOutput,pageData);const pag=pageData.pagination;if(isObjectStrict(pag)){const{current:current=0,total:total=1,currentFilters:currentFilters,prevFilters:prevFilters,nextFilters:nextFilters}=pag;if(meta.canonicalParams=`${current>1?`?page=${current}`:""}${isString(currentFilters)?currentFilters:""}`,isStringStrict(pag.title)&&(meta.paginationTitle=pag.title),isNumber(pag.prev)&&pag.prev>=1){slugArgs.page=pag.prev;const p=getSlug(slugArgs,!0);meta.prev=`${getPermalink(p.slug,1===pag.prev)}${isString(prevFilters)?prevFilters:""}`}if(isNumber(pag.next)&&pag.next>1&&pag.next<total){slugArgs.page=pag.next;const n=getSlug(slugArgs,!0);meta.next=`${getPermalink(n.slug,!1)}${isString(nextFilters)?nextFilters:""}`}serverlessRender=!0}let layoutOutput="";if(isFunction(renderLayout)){const layoutArgs={id:id,meta:meta,navigations:navigations,contentType:contentType,content:contentOutput,slug:formattedSlug,pageContains:pageContains,pageHeadings:pageHeadings,pageData:pageData,serverlessData:serverlessData,previewData:previewData};layoutOutput=await renderLayout(layoutArgs)}const renderItemFilterArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,pageData:pageData,pageContains:pageContains,pageHeadings:pageHeadings,serverlessData:serverlessData,previewData:previewData};layoutOutput=await applyFilters("renderItem",layoutOutput,renderItemFilterArgs,!0);const renderItemEndArgs={id:id,contentType:contentType,slug:formattedSlug,output:layoutOutput,pageData:pageData,pageContains:pageContains,pageHeadings:pageHeadings,serverlessData:serverlessData,previewData:previewData};return await doActions("renderItemEnd",renderItemEndArgs,!0),{serverlessRender:serverlessRender,pageData:pageData,data:{slug:formattedSlug,output:layoutOutput}}},render=async args=>{if(!isObjectStrict(args))return[];const{allData:allData,serverlessData:serverlessData,previewData:previewData}=args,isServerless=null!=serverlessData,isPreview=null!=previewData;if(scripts.deps.clear(),scripts.item.clear(),scripts.meta={},styles.deps.clear(),styles.item.clear(),!isObjectStrict(allData))return[];const{redirect:redirect,content:content}=allData;await doActions("renderStart",args,!0);const data=[];isServerless||setStoreData(allData),setRedirects(redirect),serverlessRoutes.reload=[];for(const[contentType,contentItems]of Object.entries(content))if(isArrayStrict(contentItems))for(const contentItem of contentItems){const item=await renderItem({item:await applyFilters("renderItemData",contentItem,{contentType:contentType},!0),serverlessData:serverlessData},contentType);if(!item)continue;const{serverlessRender:serverlessRender=!1,data:itemData}=item;itemData&&(data.push(itemData),serverlessRender&&!isServerless&&serverlessRoutes.reload.push({path:itemData.slug.replace(/^\/|\/$/gm,"")}))}const[outputItem]=data,output=(isServerless||isPreview)&&outputItem?outputItem:data;return await doActions("renderEnd",{...args,data:output},!0),output};export{render,renderItem,renderContent,renderFunctions,renderLayout,renderNavigations,renderHttpError,setRenderFunctions};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RenderItem, RenderContentArgs, RenderInlineItem } from './renderTypes.js';
|
|
2
|
+
declare const renderInlineContent: (content: RenderItem[], args?: Partial<Omit<RenderContentArgs, "content">>) => Promise<string>;
|
|
3
|
+
declare const renderInlineItem: (item: RenderInlineItem) => Promise<string>;
|
|
4
|
+
export { renderInlineContent, renderInlineItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{renderContent,renderItem}from"./render.js";import{isObjectStrict}from"../utils/object/object.js";import{isString}from"../utils/string/string.js";const renderInlineContent=async(content,args)=>await renderContent({content:content,parents:[],pageData:{},pageContains:[],pageHeadings:[],navigations:void 0,...args}),renderInlineItem=async item=>{if(!isObjectStrict(item))return"";const res=await renderItem({item:item});return isString(res?.data?.output)?res.data.output:""};export{renderInlineContent,renderInlineItem};
|