@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 @@
|
|
|
1
|
+
import{parse}from"@wordpress/block-serialization-spec-parser";import{normalizeContentType}from"../utils/contentType/contentType.js";import{getObjectKeys}from"../utils/object/objectUtils.js";import{getStoreItem,setStoreItem}from"../store/store.js";import{isString,isStringStrict}from"../utils/string/string.js";import{isArrayStrict}from"../utils/array/array.js";import{isObjectStrict}from"../utils/object/object.js";import{isNumber}from"../utils/number/number.js";import{config}from"../config/config.js";const normalRoutes=new Map([["page","pages"],["post","posts"],["taxonomy","taxonomies"],["category","categories"],["tag","tags"],["attachment","media"],["nav_menu","menus"],["nav_menu_item","menu-items"]]),normalMetaKeys=new Map,menusById=new Map,excludeProps=["_links","auto_add"],getTaxonomy=id=>{const taxonomy=getStoreItem("taxonomies")[id],{title:title="",slug:slug="",contentTypes:contentTypes=[]}=isObjectStrict(taxonomy)?taxonomy:{};return{id:id,title:title,slug:slug,contentTypes:contentTypes}},normalizeFile=file=>{const{url:url,filename:filename,alt:alt,width:width,height:height,filesizeInBytes:filesizeInBytes,subtype:subtype,mime:mime,sizes:sizes}=file;let s;if(isObjectStrict(sizes)){s={};for(const[,value]of Object.entries(sizes)){const{width:width,source_url:src}=value;let{url:url}=value;isStringStrict(src)&&(url=src),isNumber(width)&&isStringStrict(url)&&(s[width]=url)}}return{url:isString(url)?url:"",name:isString(filename)?filename:"",alt:isString(alt)?alt:"",width:isNumber(width)?width:0,height:isNumber(height)?height:0,size:isNumber(filesizeInBytes)?filesizeInBytes:0,format:"jpeg"===subtype?"jpg":subtype,type:mime,sizes:s}},normalizeEmbedded=(value,item,newItem)=>{getObjectKeys(value).forEach((k=>{const embeds=value[k];isArrayStrict(embeds)&&("author"===k&&embeds.forEach((embed=>{if(!isObjectStrict(embed))return;const{id:id,name:name,url:url,description:description,link:link,slug:slug}=embed;item.author===id&&(newItem.author={id:id.toString(),name:name,url:url,description:description,link:link,slug:slug})})),"up"===k&&embeds.forEach((embed=>{if(!isObjectStrict(embed))return;const{id:id,title:parentTitle,name:name,type:type,taxonomy:taxonomy,slug:slug}=embed;if(item.parent!==id)return;let title="";isString(parentTitle?.rendered)&&(title=parentTitle.rendered),isString(name)&&(title=name),newItem.parent={id:id.toString(),contentType:isString(taxonomy)?"term":type,title:title,slug:slug}})),"wp:featuredmedia"===k&&embeds.forEach((embed=>{if(!isObjectStrict(embed))return;const{id:id,source_url:url,media_details:details,mime_type:mimeType,alt_text:alt}=embed;if(!isObjectStrict(details))return;const{file:file,filesize:filesize,width:width,height:height,sizes:sizes}=details;item.featured_media===id&&(newItem.featured_media=normalizeFile({url:url,filename:file?.split("/").pop(),alt:alt,width:width,height:height,filesizeInBytes:filesize,subtype:mimeType?.split("/").pop(),mime:mimeType,sizes:sizes}))})),"wp:term"===k&&embeds.forEach((embed=>{isArrayStrict(embed)&&embed.forEach((e=>{if(!isObjectStrict(e))return;const{id:id,link:link,name:name,slug:slug,taxonomy:taxonomy=""}=e;let taxonomyLookup=taxonomy;"category"===taxonomy&&(taxonomyLookup="categories"),"post_tag"===taxonomy&&(taxonomyLookup="tags");const itemTaxonomy=newItem[taxonomyLookup]??item[taxonomyLookup];isArrayStrict(itemTaxonomy)&&(newItem[taxonomyLookup]=itemTaxonomy.map((taxonomyId=>taxonomyId!==id?taxonomyId:{id:id.toString(),link:link,title:name,slug:slug,contentType:"term",taxonomy:getTaxonomy(taxonomy)})))}))})))}))},normalizeBlocks=blocks=>{const newItems=[];return blocks.forEach((block=>{const{blockName:blockName,attrs:attrs,innerBlocks:innerBlocks}=block,contentType=blockName;if(!isStringStrict(contentType))return;const{attributeIsItem:attributeIsItem}=attrs,attrItemArr=(isStringStrict(attributeIsItem)?attributeIsItem:"").split(","),attrItemExists=attrItemArr.length>0;for(const[key,value]of Object.entries(attrs))if(isObjectStrict(value)){if(attrItemExists&&attrItemArr.includes(key)){const itemValue=normalizeItem(value);itemValue.content=void 0,attrs[key]=itemValue}isStringStrict(value.mime)&&(attrs[key]=normalizeFile(value))}const newItem={contentType:contentType,...attrs},renderType=config.renderTypes[contentType];return isString(renderType)&&(newItem.renderType=renderType),isArrayStrict(innerBlocks)&&(newItem.content=normalizeBlocks(innerBlocks)),newItems.push(newItem)})),newItems},normalizeItem=item=>{const newItem={};for(const[key,value]of Object.entries(item)){if(excludeProps.includes(key))continue;let val=value,k=key;const isObj=isObjectStrict(value),isStr=isStringStrict(value);if("id"!==key&&"object_id"!==k||(val=value?.toString()),"type"===key&&isStr)newItem.contentType=normalizeContentType(value),isString(config.renderTypes[value])&&(newItem.renderType=config.renderTypes[value]);else{if("types"===key&&(k="contentTypes"),isObj){const{rendered:rendered}=value;isString(rendered)&&(val=rendered)}if("name"===key&&(k="title"),"_embedded"===key&&isObj)normalizeEmbedded(value,item,newItem);else{if(isStringStrict(val)){if("excerpt"===key&&(val=val.replace(/<[^>]*>|\[.*?\]/g,"").trim()),"content"===key){const normalVal=normalizeBlocks(parse(val));val=normalVal.length>0?normalVal:val}"taxonomy"===key&&(newItem.contentType="term",val=getTaxonomy(val))}if("meta"===key&&isObj)for(const[metaKey,metaValue]of Object.entries(val)){newItem[normalMetaKeys.get(metaKey)??metaKey]=metaValue}else{if("media_details"===k&&isObj){const valObj=val,valFull=valObj.sizes?.full,sourceUrl=item.source_url,mimeType=item.mime_type;val=normalizeFile({url:sourceUrl,filename:sourceUrl?.split("/").pop(),alt:item.alt_text,width:valFull?.width,height:valFull?.height,filesizeInBytes:valObj.filesize,subtype:mimeType?.split("/")[1],mime:mimeType,sizes:valObj.sizes})}newItem[k]=val}}}}return newItem},normalizeWordPressMenuItems=items=>{const itemsObj=Object.fromEntries(items.map((item=>[item.id,item])));menusById.clear(),items.forEach((item=>{const{id:id="",title:title="",menu_order:menu_order=0,menus:menus=0,parent:parent}=item,hasMenuOrder=isNumber(menu_order);if(hasMenuOrder&&isObjectStrict(itemsObj[parent])&&(null==itemsObj[parent].children&&(itemsObj[parent].children=[]),itemsObj[parent].children.push({id:id,menu_order:menu_order,title:title})),hasMenuOrder&&isNumber(menus)&&0===parent){const menuId=menus.toString();null==menusById.get(menuId)&&menusById.set(menuId,[]),menusById.get(menuId)?.push({id:id,menu_order:menu_order,title:title})}}));const newItems=[];for(const[id,obj]of Object.entries(itemsObj)){const{url:url="",title:title="",attr_title:attr_title="",description:description="",contentType:contentType="",children:children=[],object:object="",object_id:object_id="",target:target="",classes:classes=[],xfn:xfn=[],meta:meta=[]}=obj;if(!isString(url)||!isStringStrict(title))continue;const isCustom="custom"===contentType,newItem={id:id,title:title,attr_title:attr_title,description:description,target:target,classes:classes,xfn:xfn,meta:meta};if(!isCustom&&isStringStrict(object)&&isStringStrict(object_id)){const isTerm="taxonomy"===contentType,internalLink={contentType:isTerm?"term":object,id:object_id,slug:url.split("/").filter(Boolean).pop()};isTerm&&(internalLink.taxonomy=getTaxonomy(object)),newItem.link=url,newItem.internalLink=internalLink}if(isCustom){url.startsWith("http")&&!url.startsWith(config.env.prodUrl)?newItem.externalLink=url:newItem.link=url}isArrayStrict(children)&&(newItem.children=children.sort(((a,b)=>a.menu_order-b.menu_order))),newItems.push(newItem)}return newItems},normalizeWordPressMenus=menus=>{const newMenus=[];return menus.forEach((menu=>{const{id:id="",title:title="",description:description="",locations:locations=[],meta:meta=[]}=menu,newMenu={id:id,title:title,description:description,meta:meta,location:locations,items:menusById.get(id)?.sort(((a,b)=>a.menu_order-b.menu_order))??[]};newMenus.push(newMenu)})),newMenus},normalizeWordPressData=(data,route,_newData=[])=>isArrayStrict(data)?("taxonomies"===route&&(data=Object.entries(data[0]).map((([key,value])=>({id:key,type:"taxonomy",...value})))),data.forEach((item=>{isObjectStrict(item)&&_newData.push(normalizeItem(item))})),"taxonomies"===route&&_newData.forEach((item=>{setStoreItem("taxonomies",item,item.id)})),_newData):[];export{normalizeWordPressData,normalizeWordPressMenuItems,normalizeWordPressMenus,normalRoutes,normalMetaKeys};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { Generic, GenericStrings } from '../global/globalTypes.js';
|
|
2
|
+
import type { NavigationItem } from '../components/Navigation/NavigationTypes.js';
|
|
3
|
+
import type { RenderServerlessData, RenderPreviewData, RenderItem, RenderDataMeta } from '../render/renderTypes.js';
|
|
4
|
+
export type WordPressDataParams = Record<string, string | number | boolean>;
|
|
5
|
+
export interface WordPressDataError {
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
status?: number;
|
|
10
|
+
params?: GenericStrings;
|
|
11
|
+
details?: Generic;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export type WordPressDataStatus = 'publish' | 'draft' | 'future' | 'pending' | 'private' | 'trash' | 'auto-draft' | 'inherit';
|
|
15
|
+
export interface WordPressDataRendered {
|
|
16
|
+
rendered?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WordPressDataRenderedProtected {
|
|
19
|
+
rendered?: string;
|
|
20
|
+
protected?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface WordPressDataMenuChild extends NavigationItem {
|
|
23
|
+
menu_order: number;
|
|
24
|
+
}
|
|
25
|
+
export interface WordPressDataMenuItem extends RenderItem {
|
|
26
|
+
children?: WordPressDataMenuChild[];
|
|
27
|
+
}
|
|
28
|
+
export interface WordPressDataMenu extends RenderItem {
|
|
29
|
+
name?: string;
|
|
30
|
+
locations?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface WordPressDataAuthor {
|
|
33
|
+
id: number;
|
|
34
|
+
name?: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
link?: string;
|
|
38
|
+
slug?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface WordPressDataMediaDetails {
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
filesize?: number;
|
|
44
|
+
file?: string;
|
|
45
|
+
sizes?: Record<string, WordPressDataMediaSize>;
|
|
46
|
+
}
|
|
47
|
+
export interface WordPressDataMediaSize {
|
|
48
|
+
source_url?: string;
|
|
49
|
+
mime_type?: string;
|
|
50
|
+
file?: string;
|
|
51
|
+
filesize?: number;
|
|
52
|
+
width?: number;
|
|
53
|
+
height?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface WordPressDataFeaturedMedia {
|
|
56
|
+
id: number;
|
|
57
|
+
source_url?: string;
|
|
58
|
+
alt_text?: string;
|
|
59
|
+
caption?: WordPressDataRendered;
|
|
60
|
+
media_type?: string;
|
|
61
|
+
mime_type?: string;
|
|
62
|
+
media_details?: WordPressDataMediaDetails;
|
|
63
|
+
}
|
|
64
|
+
export interface WordPressDataTerm {
|
|
65
|
+
id: number;
|
|
66
|
+
link?: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
slug?: string;
|
|
69
|
+
taxonomy?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface WordPressDataAttachment {
|
|
72
|
+
id: number;
|
|
73
|
+
source_url?: string;
|
|
74
|
+
title?: WordPressDataRendered;
|
|
75
|
+
media_type?: string;
|
|
76
|
+
mime_type?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface WordPressDataParent {
|
|
79
|
+
id: number;
|
|
80
|
+
title?: WordPressDataRendered;
|
|
81
|
+
excerpt?: WordPressDataRendered;
|
|
82
|
+
slug?: string;
|
|
83
|
+
type?: string;
|
|
84
|
+
link?: string;
|
|
85
|
+
author?: number;
|
|
86
|
+
featured_media?: number;
|
|
87
|
+
name?: string;
|
|
88
|
+
taxonomy?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface WordPressDataEmbedded {
|
|
91
|
+
author?: WordPressDataAuthor[];
|
|
92
|
+
up?: WordPressDataParent[];
|
|
93
|
+
'wp:featuredmedia'?: WordPressDataFeaturedMedia[];
|
|
94
|
+
'wp:attachment'?: WordPressDataAttachment[];
|
|
95
|
+
'wp:term'?: WordPressDataTerm[][];
|
|
96
|
+
}
|
|
97
|
+
export interface WordPressDataLink {
|
|
98
|
+
href: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
templated?: boolean;
|
|
101
|
+
count?: number;
|
|
102
|
+
taxonomy?: string;
|
|
103
|
+
embeddable?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface WordPressDataLinks {
|
|
106
|
+
self: WordPressDataLink[];
|
|
107
|
+
collection: WordPressDataLink[];
|
|
108
|
+
about: WordPressDataLink[];
|
|
109
|
+
'version-history': WordPressDataLink[];
|
|
110
|
+
'wp:attachment': WordPressDataLink[];
|
|
111
|
+
'wp:term': WordPressDataLink[];
|
|
112
|
+
curies: WordPressDataLink[];
|
|
113
|
+
}
|
|
114
|
+
export interface WordPressDataFileSize {
|
|
115
|
+
height?: number;
|
|
116
|
+
width?: number;
|
|
117
|
+
url?: string;
|
|
118
|
+
source_url?: string;
|
|
119
|
+
orientation?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface WordPressDataFile {
|
|
122
|
+
contentType?: string;
|
|
123
|
+
id?: number;
|
|
124
|
+
title?: string;
|
|
125
|
+
filename?: string;
|
|
126
|
+
url?: string;
|
|
127
|
+
link?: string;
|
|
128
|
+
alt?: string;
|
|
129
|
+
author?: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
caption?: string;
|
|
132
|
+
name?: string;
|
|
133
|
+
status?: string;
|
|
134
|
+
uploadedTo?: number;
|
|
135
|
+
date?: string;
|
|
136
|
+
modified?: string;
|
|
137
|
+
menuOrder?: number;
|
|
138
|
+
mime?: string;
|
|
139
|
+
type?: string;
|
|
140
|
+
subtype?: string;
|
|
141
|
+
icon?: string;
|
|
142
|
+
dateFormatted?: string;
|
|
143
|
+
nonces?: {
|
|
144
|
+
update: string;
|
|
145
|
+
delete: string;
|
|
146
|
+
edit: string;
|
|
147
|
+
};
|
|
148
|
+
editLink?: string;
|
|
149
|
+
meta?: boolean;
|
|
150
|
+
authorName?: string;
|
|
151
|
+
authorLink?: string;
|
|
152
|
+
filesizeInBytes?: number;
|
|
153
|
+
filesizeHumanReadable?: string;
|
|
154
|
+
context?: string;
|
|
155
|
+
height?: number;
|
|
156
|
+
width?: number;
|
|
157
|
+
orientation?: string;
|
|
158
|
+
sizes?: Record<string, WordPressDataFileSize>;
|
|
159
|
+
}
|
|
160
|
+
export interface WordPressDataMeta extends Generic {
|
|
161
|
+
footnotes?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface WordPressDataItem extends Partial<WordPressDataFeaturedMedia>, Generic {
|
|
164
|
+
id?: number;
|
|
165
|
+
date?: string;
|
|
166
|
+
date_gmt?: string;
|
|
167
|
+
guid?: WordPressDataRendered;
|
|
168
|
+
modified?: string;
|
|
169
|
+
modified_gmt?: string;
|
|
170
|
+
slug?: string;
|
|
171
|
+
status?: WordPressDataStatus;
|
|
172
|
+
type?: string;
|
|
173
|
+
link?: string;
|
|
174
|
+
title?: WordPressDataRendered;
|
|
175
|
+
content?: WordPressDataRenderedProtected;
|
|
176
|
+
excerpt?: WordPressDataRenderedProtected;
|
|
177
|
+
author?: number;
|
|
178
|
+
featured_media?: number;
|
|
179
|
+
parent?: number;
|
|
180
|
+
menu_order?: number;
|
|
181
|
+
comment_status?: string;
|
|
182
|
+
ping_status?: string;
|
|
183
|
+
sticky?: boolean;
|
|
184
|
+
template?: string;
|
|
185
|
+
format?: string;
|
|
186
|
+
meta?: WordPressDataMeta;
|
|
187
|
+
categories?: number[];
|
|
188
|
+
tags?: number[];
|
|
189
|
+
class_list?: string[];
|
|
190
|
+
taxonomy?: string;
|
|
191
|
+
name?: string;
|
|
192
|
+
_links?: WordPressDataLinks;
|
|
193
|
+
_embedded?: WordPressDataEmbedded;
|
|
194
|
+
}
|
|
195
|
+
export interface WordPressDataArgs {
|
|
196
|
+
key: string;
|
|
197
|
+
route: string;
|
|
198
|
+
params?: WordPressDataParams;
|
|
199
|
+
meta?: RenderDataMeta;
|
|
200
|
+
fetcher?: typeof fetch;
|
|
201
|
+
options?: RequestInit;
|
|
202
|
+
}
|
|
203
|
+
export interface AllWordPressDataArgs {
|
|
204
|
+
serverlessData?: RenderServerlessData;
|
|
205
|
+
previewData?: RenderPreviewData;
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alanizcreative/formation-static",
|
|
3
|
+
"version": "1.3.0-beta.29",
|
|
4
|
+
"description": "Foundation and utilities to build static sites using local JSON files, Contentful, or WordPress",
|
|
5
|
+
"main": "./lib/config/config.js",
|
|
6
|
+
"packageManager": "pnpm@10.6.2",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"./lib",
|
|
10
|
+
"./cjs"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./*": {
|
|
14
|
+
"import": "./lib/*",
|
|
15
|
+
"require": "./cjs/*"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build:lib": "npx tsc --project tsconfig.build.json",
|
|
23
|
+
"build:cjs": "npx tsc --project tsconfig.build.json --moduleResolution node --module commonjs --esModuleInterop --outDir cjs/",
|
|
24
|
+
"build": "pnpm build:lib && pnpm build:cjs && node scripts/packageFile.js && pnpm minify",
|
|
25
|
+
"minify": "find lib cjs -name \"*.js\" -exec terser {} -o {} --compress \\;",
|
|
26
|
+
"test": "vitest --run --reporter verbose --coverage",
|
|
27
|
+
"lint": "npx eslint .",
|
|
28
|
+
"release": "release-it",
|
|
29
|
+
"release:beta": "release-it --preRelease=beta"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/galaniz/formation-static.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/galaniz/formation-static/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/galaniz/formation-static#readme",
|
|
39
|
+
"author": "Graciela Alaniz (https://alanizcreative.com/)",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@cloudflare/workers-types": "4.20250310.0",
|
|
43
|
+
"@types/contentful-resolve-response": "^0.1.33",
|
|
44
|
+
"@types/node": "^22.13.10",
|
|
45
|
+
"@types/uuid": "^10.0.0",
|
|
46
|
+
"@types/wordpress__block-serialization-spec-parser": "^3.1.3",
|
|
47
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
48
|
+
"eslint": "9.22.0",
|
|
49
|
+
"memfs": "4.17.0",
|
|
50
|
+
"release-it": "^18.1.2",
|
|
51
|
+
"terser": "5.37.0",
|
|
52
|
+
"typescript": "^5.8.2",
|
|
53
|
+
"typescript-eslint": "8.26.1",
|
|
54
|
+
"vitest": "^3.0.8"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"uuid": "^11.1.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@wordpress/block-serialization-spec-parser": "^5.11.0",
|
|
61
|
+
"contentful-resolve-response": "^1.9.0",
|
|
62
|
+
"sharp": "0.33.5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@wordpress/block-serialization-spec-parser": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"contentful-resolve-response": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"sharp": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"release-it": {
|
|
76
|
+
"git": {
|
|
77
|
+
"requireCommits": true,
|
|
78
|
+
"commitMessage": "chore: release ${version} [ci skip]"
|
|
79
|
+
},
|
|
80
|
+
"github": {
|
|
81
|
+
"release": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
}
|
|
87
|
+
}
|