nextpress-core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acf-functions/core/acf-builder.d.ts +50 -0
- package/{lib/acf-functions/core/acf-builder.ts → dist/acf-functions/core/acf-builder.js} +17 -41
- package/dist/acf-functions/core/acf-component-autoloader.d.ts +11 -0
- package/{lib/acf-functions/core/acf-component-autoloader.ts → dist/acf-functions/core/acf-component-autoloader.js} +7 -13
- package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +9 -0
- package/{lib/acf-functions/core/acf-field-group-autoloader.ts → dist/acf-functions/core/acf-field-group-autoloader.js} +4 -9
- package/dist/acf-functions/services/define-field-group.d.ts +8 -0
- package/{lib/acf-functions/services/define-field-group.ts → dist/acf-functions/services/define-field-group.js} +1 -1
- package/dist/acf-functions/services/define-layout.d.ts +8 -0
- package/{lib/acf-functions/services/define-layout.ts → dist/acf-functions/services/define-layout.js} +1 -1
- package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +2 -0
- package/dist/acf-functions/services/map-fields/helpers/map-choice-object.js +18 -0
- package/dist/acf-functions/services/map-fields/map-fields.d.ts +18 -0
- package/{lib/acf-functions/services/map-fields/map-fields.ts → dist/acf-functions/services/map-fields/map-fields.js} +88 -124
- package/dist/entities/option/option.d.ts +19 -0
- package/{lib/entities/option/option.ts → dist/entities/option/option.js} +13 -20
- package/dist/entities/post/post.d.ts +50 -0
- package/dist/entities/post/post.js +184 -0
- package/dist/entities/term/term.d.ts +28 -0
- package/dist/entities/term/term.js +67 -0
- package/dist/entities/user/user.d.ts +27 -0
- package/dist/entities/user/user.js +74 -0
- package/dist/globals/entity-loader/entity-loader-base.d.ts +65 -0
- package/{lib/globals/entity-loader/entity-loader-base.ts → dist/globals/entity-loader/entity-loader-base.js} +10 -64
- package/dist/globals/entity-loader/option-loader.d.ts +15 -0
- package/dist/globals/entity-loader/option-loader.js +31 -0
- package/dist/globals/entity-loader/post-loader.d.ts +21 -0
- package/dist/globals/entity-loader/post-loader.js +28 -0
- package/dist/globals/entity-loader/term-loader.d.ts +21 -0
- package/dist/globals/entity-loader/term-loader.js +28 -0
- package/dist/globals/entity-loader/user-loader.d.ts +21 -0
- package/dist/globals/entity-loader/user-loader.js +28 -0
- package/dist/globals/get-field/get-field.d.ts +17 -0
- package/dist/globals/get-field/get-field.js +44 -0
- package/dist/globals/globals.d.ts +18 -0
- package/{lib/globals/globals.ts → dist/globals/globals.js} +3 -8
- package/dist/globals/nextpress-config/nextpress-config.d.ts +4 -0
- package/{lib/globals/nextpress-config/nextpress-config.ts → dist/globals/nextpress-config/nextpress-config.js} +0 -5
- package/dist/globals/queried-object/queried-object.d.ts +62 -0
- package/dist/globals/queried-object/queried-object.js +56 -0
- package/dist/repository/optionquery/option-query.d.ts +12 -0
- package/dist/repository/optionquery/option-query.js +20 -0
- package/dist/repository/postquery/post-query.d.ts +12 -0
- package/dist/repository/postquery/post-query.js +272 -0
- package/dist/repository/termquery/term-query.d.ts +11 -0
- package/dist/repository/termquery/term-query.js +213 -0
- package/dist/repository/userquery/user-query.d.ts +12 -0
- package/{lib/repository/userquery/user-query.ts → dist/repository/userquery/user-query.js} +75 -91
- package/dist/router/helpers.d.ts +14 -0
- package/{lib/router/helpers.ts → dist/router/helpers.js} +4 -4
- package/dist/router/nextpress-layout.d.ts +11 -0
- package/{lib/router/nextpress-layout.tsx → dist/router/nextpress-layout.js} +6 -23
- package/dist/router/nextpress-proxy.d.ts +8 -0
- package/{lib/router/nextpress-proxy.ts → dist/router/nextpress-proxy.js} +3 -15
- package/dist/router/nextpress-static-params.d.ts +9 -0
- package/{lib/router/nextpress-static-params.ts → dist/router/nextpress-static-params.js} +5 -17
- package/dist/router/router.d.ts +23 -0
- package/{lib/router/router.tsx → dist/router/router.js} +21 -29
- package/dist/router/routes/api/api-get-admin-bar.d.ts +8 -0
- package/{lib/router/routes/api/api-get-admin-bar.ts → dist/router/routes/api/api-get-admin-bar.js} +6 -8
- package/dist/router/routes/api/api-get-draft-mode.d.ts +8 -0
- package/{lib/router/routes/api/api-get-draft-mode.ts → dist/router/routes/api/api-get-draft-mode.js} +6 -15
- package/dist/router/routes/api/api-get-field-groups.d.ts +7 -0
- package/{lib/router/routes/api/api-get-field-groups.ts → dist/router/routes/api/api-get-field-groups.js} +6 -11
- package/dist/router/routes/api/api-post-revalidate.d.ts +7 -0
- package/{lib/router/routes/api/api-post-revalidate.ts → dist/router/routes/api/api-post-revalidate.js} +4 -6
- package/dist/router/routes/api/helpers.d.ts +8 -0
- package/{lib/router/routes/api/helpers.ts → dist/router/routes/api/helpers.js} +3 -4
- package/dist/router/routes/author-archive.d.ts +25 -0
- package/{lib/router/routes/author-archive.tsx → dist/router/routes/author-archive.js} +11 -37
- package/dist/router/routes/not-found-page.d.ts +15 -0
- package/{lib/router/routes/not-found-page.tsx → dist/router/routes/not-found-page.js} +3 -5
- package/dist/router/routes/post-index-page.d.ts +25 -0
- package/dist/router/routes/post-index-page.js +33 -0
- package/dist/router/routes/singular-page.d.ts +29 -0
- package/dist/router/routes/singular-page.js +51 -0
- package/dist/router/routes/site-front-page.d.ts +27 -0
- package/dist/router/routes/site-front-page.js +26 -0
- package/dist/router/routes/term-archive.d.ts +29 -0
- package/{lib/router/routes/term-archive.tsx → dist/router/routes/term-archive.js} +17 -45
- package/dist/services/get-menu.d.ts +13 -0
- package/{lib/services/get-menu.ts → dist/services/get-menu.js} +32 -56
- package/dist/services/get-theme-mods.d.ts +7 -0
- package/{lib/services/get-theme-mods.ts → dist/services/get-theme-mods.js} +4 -6
- package/dist/services/metadata/get-blogname.d.ts +6 -0
- package/{lib/services/metadata/get-blogname.ts → dist/services/metadata/get-blogname.js} +2 -2
- package/dist/services/metadata/get-favicon-url.d.ts +6 -0
- package/{lib/services/metadata/get-favicon-url.ts → dist/services/metadata/get-favicon-url.js} +4 -5
- package/dist/services/metadata/get-language-attribute.d.ts +6 -0
- package/{lib/services/metadata/get-language-attribute.ts → dist/services/metadata/get-language-attribute.js} +1 -1
- package/{lib/services/services.ts → dist/services/services.d.ts} +1 -5
- package/dist/services/services.js +3 -0
- package/dist/services/utilities/capitalise-first-letter.d.ts +7 -0
- package/{lib/services/utilities/capitalise-first-letter.ts → dist/services/utilities/capitalise-first-letter.js} +3 -2
- package/dist/services/utilities/esc-html.d.ts +7 -0
- package/{lib/services/utilities/esc-html.ts → dist/services/utilities/esc-html.js} +1 -3
- package/dist/services/utilities/get-date-time-formatter.d.ts +6 -0
- package/{lib/services/utilities/get-date-time-formatter.ts → dist/services/utilities/get-date-time-formatter.js} +6 -16
- package/dist/services/utilities/index.js +1 -0
- package/dist/services/utilities/kses-post.d.ts +7 -0
- package/{lib/services/utilities/kses-post.ts → dist/services/utilities/kses-post.js} +1 -2
- package/dist/services/utilities/process-url.d.ts +7 -0
- package/{lib/services/utilities/process-url.ts → dist/services/utilities/process-url.js} +3 -4
- package/dist/template-heirarchy/_autoloader/template-autoloader.d.ts +9 -0
- package/{lib/template-heirarchy/_autoloader/template-autoloader.ts → dist/template-heirarchy/_autoloader/template-autoloader.js} +9 -18
- package/dist/template-heirarchy/archive/archive.d.ts +16 -0
- package/{lib/template-heirarchy/archive/archive.tsx → dist/template-heirarchy/archive/archive.js} +7 -10
- package/dist/template-heirarchy/archive/author.d.ts +16 -0
- package/{lib/template-heirarchy/archive/author.tsx → dist/template-heirarchy/archive/author.js} +7 -10
- package/dist/template-heirarchy/archive/category.d.ts +16 -0
- package/{lib/template-heirarchy/archive/category.tsx → dist/template-heirarchy/archive/category.js} +7 -11
- package/dist/template-heirarchy/archive/posttypearchive.d.ts +24 -0
- package/{lib/template-heirarchy/archive/posttypearchive.tsx → dist/template-heirarchy/archive/posttypearchive.js} +7 -10
- package/dist/template-heirarchy/archive/tag.d.ts +16 -0
- package/{lib/template-heirarchy/archive/tag.tsx → dist/template-heirarchy/archive/tag.js} +7 -12
- package/dist/template-heirarchy/archive/taxonomy.d.ts +16 -0
- package/{lib/template-heirarchy/archive/taxonomy.tsx → dist/template-heirarchy/archive/taxonomy.js} +7 -10
- package/dist/template-heirarchy/home/home.d.ts +16 -0
- package/{lib/template-heirarchy/home/home.tsx → dist/template-heirarchy/home/home.js} +7 -10
- package/dist/template-heirarchy/index.d.ts +17 -0
- package/{lib/template-heirarchy/index.tsx → dist/template-heirarchy/index.js} +5 -9
- package/dist/template-heirarchy/not-found.tsx/not-found.d.ts +16 -0
- package/{lib/template-heirarchy/not-found.tsx/not-found.tsx → dist/template-heirarchy/not-found.tsx/not-found.js} +7 -10
- package/dist/template-heirarchy/page/page.d.ts +16 -0
- package/{lib/template-heirarchy/page/page.tsx → dist/template-heirarchy/page/page.js} +7 -10
- package/dist/template-heirarchy/page/posttype.d.ts +24 -0
- package/{lib/template-heirarchy/page/posttype.tsx → dist/template-heirarchy/page/posttype.js} +7 -11
- package/dist/template-heirarchy/page/single.d.ts +16 -0
- package/{lib/template-heirarchy/page/single.tsx → dist/template-heirarchy/page/single.js} +7 -10
- package/dist/template-heirarchy/page/singular.d.ts +16 -0
- package/{lib/template-heirarchy/page/singular.tsx → dist/template-heirarchy/page/singular.js} +7 -10
- package/dist/ui/render-attachment-image.d.ts +12 -0
- package/dist/ui/render-attachment-image.js +24 -0
- package/{lib/ui/render-components.tsx → dist/ui/render-components.d.ts} +4 -7
- package/dist/ui/render-components.js +7 -0
- package/dist/ui/render-the-admin-bar.d.ts +8 -0
- package/dist/ui/render-the-admin-bar.js +36 -0
- package/dist/ui/render-the-logo.d.ts +10 -0
- package/dist/ui/render-the-logo.js +16 -0
- package/dist/wpdb/wpdb.d.ts +3 -0
- package/{lib/wpdb/wpdb.ts → dist/wpdb/wpdb.js} +5 -9
- package/package.json +7 -3
- package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +0 -20
- package/lib/acf-functions/types/acf-field-group.d.ts +0 -118
- package/lib/acf-functions/types/acf-field.d.ts +0 -2851
- package/lib/acf-functions/types/acf-layout.d.ts +0 -20
- package/lib/acf-functions/types/acf-values.d.ts +0 -4
- package/lib/acf-functions/types/components/field-props.d.ts +0 -189
- package/lib/acf-functions/types/components/nextpress-component.d.ts +0 -11
- package/lib/ambient.d.ts +0 -15
- package/lib/entities/common.d.ts +0 -30
- package/lib/entities/option/option.interface.d.ts +0 -8
- package/lib/entities/post/post.interface.d.ts +0 -72
- package/lib/entities/post/post.ts +0 -209
- package/lib/entities/term/term.interface.d.ts +0 -8
- package/lib/entities/term/term.ts +0 -82
- package/lib/entities/user/user.interface.d.ts +0 -10
- package/lib/entities/user/user.ts +0 -86
- package/lib/globals/entity-loader/entity-loader.d.ts +0 -50
- package/lib/globals/entity-loader/option-loader.ts +0 -56
- package/lib/globals/entity-loader/post-loader.ts +0 -59
- package/lib/globals/entity-loader/term-loader.ts +0 -59
- package/lib/globals/entity-loader/user-loader.ts +0 -60
- package/lib/globals/get-field/get-field.ts +0 -75
- package/lib/globals/nextpress-config/nextpress-config.interface.d.ts +0 -18
- package/lib/globals/queried-object/queried-object.ts +0 -124
- package/lib/repository/optionquery/option-query-args.d.ts +0 -21
- package/lib/repository/optionquery/option-query.ts +0 -29
- package/lib/repository/postquery/post-query-args.d.ts +0 -108
- package/lib/repository/postquery/post-query.ts +0 -281
- package/lib/repository/termquery/term-query-args.d.ts +0 -61
- package/lib/repository/termquery/term-query.ts +0 -243
- package/lib/repository/userquery/user-query-args.d.ts +0 -75
- package/lib/router/routes/post-index-page.tsx +0 -58
- package/lib/router/routes/singular-page.tsx +0 -78
- package/lib/router/routes/site-front-page.tsx +0 -51
- package/lib/router/types.d.ts +0 -9
- package/lib/ui/render-attachment-image.tsx +0 -29
- package/lib/ui/render-the-admin-bar.tsx +0 -79
- package/lib/ui/render-the-logo.tsx +0 -24
- package/lib/wpdb/wpdb.interface.d.ts +0 -171
- /package/{lib/services/utilities/index.ts → dist/services/utilities/index.d.ts} +0 -0
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPageNumber } from "../helpers";
|
|
3
3
|
import { notFound } from "next/navigation";
|
|
4
4
|
import { CategoryMetadata, CategoryTemplate } from "@/template-heirarchy/archive/category";
|
|
5
5
|
import { TagMetadata, TagTemplate } from "@/template-heirarchy/archive/tag";
|
|
6
6
|
import { TaxonomyMetadata, TaxonomyTemplate } from "@/template-heirarchy/archive/taxonomy";
|
|
7
7
|
import { queriedObjectState } from "@/globals/globals";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Resolves the term archive route and maps it to the template hierarchy to return Metadata.
|
|
11
|
-
* * Routing Behavior:
|
|
12
|
-
* - If the taxonomy is 'category', it routes to `CategoryMetadata`.
|
|
13
|
-
* - If the taxonomy is 'tag', it routes to `TagMetadata`.
|
|
14
|
-
* - For all other taxonomies, it routes to `TaxonomyMetadata`.
|
|
15
|
-
*
|
|
16
|
-
* @param {{ path: string[], metadata: true }} props - Route properties requesting metadata.
|
|
17
|
-
* @returns {Promise<MetadataResult>} The generated metadata.
|
|
18
|
-
*/
|
|
19
|
-
export function TermArchive(props: { path: string[], metadata: true }): Promise<MetadataResult>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Resolves the term archive route and maps it to the template hierarchy to return a Template.
|
|
23
|
-
* * Routing Behavior:
|
|
24
|
-
* - If the taxonomy is 'category', it routes to `CategoryTemplate`.
|
|
25
|
-
* - If the taxonomy is 'tag', it routes to `TagTemplate`.
|
|
26
|
-
* - For all other taxonomies, it routes to `TaxonomyTemplate`.
|
|
27
|
-
*
|
|
28
|
-
* @param {{ path: string[], metadata?: false }} props - Route properties requesting a template.
|
|
29
|
-
* @returns {Promise<TemplateResult>} The rendered template component.
|
|
30
|
-
*/
|
|
31
|
-
export function TermArchive(props: { path: string[], metadata?: false }): Promise<TemplateResult>;
|
|
32
|
-
|
|
33
8
|
/**
|
|
34
9
|
* Core implementation for the term archive route.
|
|
35
10
|
* Retrieves posts for a specific taxonomy term and updates the queried object state.
|
|
@@ -38,25 +13,24 @@ export function TermArchive(props: { path: string[], metadata?: false }): Promis
|
|
|
38
13
|
* @returns {Promise<MetadataResult | TemplateResult>} The metadata or template result based on the hierarchy.
|
|
39
14
|
* @throws {Error} Throws a Next.js notFound error if the term does not exist.
|
|
40
15
|
*/
|
|
41
|
-
export async function TermArchive({ path, metadata = false }
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
export async function TermArchive({ path, metadata = false }) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const postsPerPage = (_a = Number(await getOption('posts_per_page'))) !== null && _a !== void 0 ? _a : 10;
|
|
44
19
|
let page = getPageNumber(path);
|
|
45
20
|
if (page) {
|
|
46
21
|
path = path.slice(0, -2);
|
|
47
|
-
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
48
24
|
page = 1;
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
const taxonomy = path[0] ?? '';
|
|
26
|
+
const taxonomy = (_b = path[0]) !== null && _b !== void 0 ? _b : '';
|
|
52
27
|
const pathString = path.slice(1).join('/');
|
|
53
|
-
|
|
54
28
|
const termQuery = await termLoader.findAndPrime({
|
|
55
29
|
taxonomy,
|
|
56
30
|
path: `/${pathString}`
|
|
57
31
|
});
|
|
58
|
-
if (!termQuery.ids.length)
|
|
59
|
-
|
|
32
|
+
if (!termQuery.ids.length)
|
|
33
|
+
notFound();
|
|
60
34
|
const postIds = await postLoader.findAndPrime({
|
|
61
35
|
termIn: termQuery.ids,
|
|
62
36
|
noFoundRows: false,
|
|
@@ -67,10 +41,8 @@ export async function TermArchive({ path, metadata = false }: RouteProps) {
|
|
|
67
41
|
postStatus: 'publish',
|
|
68
42
|
orderBy: 'date'
|
|
69
43
|
});
|
|
70
|
-
|
|
71
44
|
const terms = await getTerms(termQuery.ids);
|
|
72
|
-
const mainTerm = terms.find(term => term.slug === path[path.length - 1])
|
|
73
|
-
|
|
45
|
+
const mainTerm = terms.find(term => term.slug === path[path.length - 1]);
|
|
74
46
|
const currentQueriedObject = {
|
|
75
47
|
objectType: 'term',
|
|
76
48
|
posts: postIds.ids,
|
|
@@ -79,15 +51,15 @@ export async function TermArchive({ path, metadata = false }: RouteProps) {
|
|
|
79
51
|
mainTerm: mainTerm.termId,
|
|
80
52
|
terms: termQuery.ids
|
|
81
53
|
};
|
|
82
|
-
|
|
83
54
|
const state = queriedObjectState();
|
|
84
55
|
state.currentState = currentQueriedObject;
|
|
85
|
-
|
|
86
56
|
if (taxonomy === 'category') {
|
|
87
|
-
return metadata ? await CategoryMetadata() :
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
57
|
+
return metadata ? await CategoryMetadata() : _jsx(CategoryTemplate, {});
|
|
58
|
+
}
|
|
59
|
+
else if (taxonomy === 'tag') {
|
|
60
|
+
return metadata ? await TagMetadata() : _jsx(TagTemplate, {});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return metadata ? await TaxonomyMetadata() : _jsx(TaxonomyTemplate, {});
|
|
92
64
|
}
|
|
93
65
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IMenuItem } from "../entities/post/post.interface";
|
|
2
|
+
type Menu = {
|
|
3
|
+
menuItem: IMenuItem;
|
|
4
|
+
children: Menu[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves a menu by its location identifier.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} menuLocation - The location identifier of the menu.
|
|
10
|
+
* @returns {Promise<Menu[] | undefined>} An array of menu items representing the menu tree, or undefined if the menu is not found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getMenu(menuLocation: string): Promise<Menu[] | undefined>;
|
|
13
|
+
export {};
|
|
@@ -1,104 +1,80 @@
|
|
|
1
|
-
import { IMenuItem } from "../entities/post/post.interface";
|
|
2
1
|
import { getThemeMods } from "./get-theme-mods";
|
|
3
|
-
|
|
4
|
-
type Menu = {
|
|
5
|
-
menuItem: IMenuItem,
|
|
6
|
-
children: Menu[]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
2
|
/**
|
|
10
3
|
* Retrieves a menu by its location identifier.
|
|
11
4
|
*
|
|
12
5
|
* @param {string} menuLocation - The location identifier of the menu.
|
|
13
6
|
* @returns {Promise<Menu[] | undefined>} An array of menu items representing the menu tree, or undefined if the menu is not found.
|
|
14
7
|
*/
|
|
15
|
-
export async function getMenu(menuLocation
|
|
8
|
+
export async function getMenu(menuLocation) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
16
10
|
const navMenuLocations = await getThemeMods('nav_menu_locations');
|
|
17
|
-
if (!navMenuLocations || typeof navMenuLocations !== 'object')
|
|
18
|
-
|
|
19
|
-
const menuTermId = Number(
|
|
20
|
-
if (!menuTermId)
|
|
21
|
-
|
|
11
|
+
if (!navMenuLocations || typeof navMenuLocations !== 'object')
|
|
12
|
+
return;
|
|
13
|
+
const menuTermId = Number(navMenuLocations[menuLocation]) || undefined;
|
|
14
|
+
if (!menuTermId)
|
|
15
|
+
return;
|
|
22
16
|
const postQuery = await postLoader.findAndPrime({
|
|
23
17
|
termId: menuTermId,
|
|
24
18
|
postStatus: 'publish',
|
|
25
19
|
postType: 'nav_menu_item',
|
|
26
20
|
noFoundRows: true,
|
|
27
21
|
noPaging: true
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const menuItems: IMenuItem[] = (await getPosts(postQuery.ids)).sort((a, b) => a.menuOrder - b.menuOrder);
|
|
31
|
-
|
|
22
|
+
});
|
|
23
|
+
const menuItems = (await getPosts(postQuery.ids)).sort((a, b) => a.menuOrder - b.menuOrder);
|
|
32
24
|
// Prime cache to get paths in bunch later
|
|
33
25
|
for (const item of menuItems) {
|
|
34
|
-
if (!item.menuItemAttributes)
|
|
35
|
-
|
|
26
|
+
if (!item.menuItemAttributes)
|
|
27
|
+
continue;
|
|
36
28
|
if (item.menuItemAttributes.type === 'post_type') {
|
|
37
|
-
postLoader.prime([item.menuItemAttributes.objectId])
|
|
38
|
-
}
|
|
39
|
-
|
|
29
|
+
postLoader.prime([item.menuItemAttributes.objectId]);
|
|
30
|
+
}
|
|
31
|
+
else if (item.menuItemAttributes.type === 'taxonomy') {
|
|
32
|
+
termLoader.prime([item.menuItemAttributes.objectId]);
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const tree: Menu[] = [];
|
|
45
|
-
|
|
35
|
+
const map = new Map();
|
|
36
|
+
const tree = [];
|
|
46
37
|
for (const item of menuItems) {
|
|
47
|
-
if (!item.menuItemAttributes)
|
|
48
|
-
|
|
49
|
-
const menuItemAttributes = {
|
|
50
|
-
|
|
38
|
+
if (!item.menuItemAttributes)
|
|
39
|
+
continue;
|
|
40
|
+
const menuItemAttributes = Object.assign({}, item.menuItemAttributes);
|
|
51
41
|
if (item.menuItemAttributes.type === 'post_type') {
|
|
52
42
|
const post = await getPost(menuItemAttributes.objectId);
|
|
53
|
-
|
|
54
|
-
menuItemAttributes.url = post?.path ?? '';
|
|
55
|
-
|
|
43
|
+
menuItemAttributes.url = (_a = post === null || post === void 0 ? void 0 : post.path) !== null && _a !== void 0 ? _a : '';
|
|
56
44
|
if (!menuItemAttributes.label) {
|
|
57
|
-
menuItemAttributes.label = post
|
|
45
|
+
menuItemAttributes.label = (_b = post === null || post === void 0 ? void 0 : post.postTitle) !== null && _b !== void 0 ? _b : '';
|
|
58
46
|
}
|
|
59
|
-
}
|
|
47
|
+
}
|
|
48
|
+
else if (item.menuItemAttributes.type === 'taxonomy') {
|
|
60
49
|
const term = await getTerm(menuItemAttributes.objectId);
|
|
61
|
-
|
|
62
|
-
menuItemAttributes.url = term?.path ?? '';
|
|
63
|
-
|
|
50
|
+
menuItemAttributes.url = (_c = term === null || term === void 0 ? void 0 : term.path) !== null && _c !== void 0 ? _c : '';
|
|
64
51
|
if (!menuItemAttributes.label) {
|
|
65
|
-
menuItemAttributes.label = term
|
|
52
|
+
menuItemAttributes.label = (_d = term === null || term === void 0 ? void 0 : term.name) !== null && _d !== void 0 ? _d : '';
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
...item,
|
|
71
|
-
menuItemAttributes
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const node: Menu = {
|
|
55
|
+
const safeItem = Object.assign(Object.assign({}, item), { menuItemAttributes });
|
|
56
|
+
const node = {
|
|
75
57
|
menuItem: safeItem,
|
|
76
58
|
children: []
|
|
77
59
|
};
|
|
78
|
-
|
|
79
60
|
map.set(item.ID, node);
|
|
80
61
|
}
|
|
81
|
-
|
|
82
62
|
for (const item of menuItems) {
|
|
83
|
-
if (!item.menuItemAttributes)
|
|
84
|
-
|
|
63
|
+
if (!item.menuItemAttributes)
|
|
64
|
+
continue;
|
|
85
65
|
const currentNode = map.get(item.ID);
|
|
86
|
-
if (!currentNode)
|
|
87
|
-
|
|
66
|
+
if (!currentNode)
|
|
67
|
+
continue;
|
|
88
68
|
const parentId = item.menuItemAttributes.parentId;
|
|
89
|
-
|
|
90
69
|
if (parentId === 0) {
|
|
91
70
|
tree.push(currentNode);
|
|
92
71
|
continue;
|
|
93
72
|
}
|
|
94
|
-
|
|
95
73
|
const parentNode = map.get(parentId);
|
|
96
|
-
|
|
97
74
|
if (parentNode) {
|
|
98
75
|
parentNode.children.push(currentNode);
|
|
99
76
|
map.set(parentNode.menuItem.ID, parentNode);
|
|
100
77
|
}
|
|
101
78
|
}
|
|
102
|
-
|
|
103
79
|
return tree;
|
|
104
80
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves a theme modification value by key.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} key - The key of the theme modification to retrieve.
|
|
5
|
+
* @returns {Promise<unknown | undefined>} The theme modification value, or undefined if not found.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getThemeMods(key: string): Promise<unknown | undefined>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { unserialize } from "php-serialize";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Retrieves a theme modification value by key.
|
|
5
4
|
*
|
|
6
5
|
* @param {string} key - The key of the theme modification to retrieve.
|
|
7
6
|
* @returns {Promise<unknown | undefined>} The theme modification value, or undefined if not found.
|
|
8
7
|
*/
|
|
9
|
-
export async function getThemeMods(key
|
|
8
|
+
export async function getThemeMods(key) {
|
|
10
9
|
const themeModOption = await getOption('theme_mods_nextpress_theme');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const themeMods = unserialize(themeModOption !== null && themeModOption !== void 0 ? themeModOption : 'a:0:{}');
|
|
11
|
+
if (Array.isArray(themeMods))
|
|
12
|
+
return;
|
|
15
13
|
return themeMods[key];
|
|
16
14
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {Promise<string>} The blog name, defaulting to 'My Blog' if not found.
|
|
5
5
|
*/
|
|
6
|
-
export async function getBlogname()
|
|
6
|
+
export async function getBlogname() {
|
|
7
7
|
const blognameOption = await getOption('blogname');
|
|
8
|
-
return blognameOption
|
|
8
|
+
return blognameOption !== null && blognameOption !== void 0 ? blognameOption : 'My Blog';
|
|
9
9
|
}
|
package/{lib/services/metadata/get-favicon-url.ts → dist/services/metadata/get-favicon-url.js}
RENAMED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {Promise<string|undefined>} The URL of the favicon, or undefined if not set.
|
|
5
5
|
*/
|
|
6
|
-
export async function getFaviconURL()
|
|
6
|
+
export async function getFaviconURL() {
|
|
7
7
|
const iconID = await getOption('site_icon');
|
|
8
|
-
if (!iconID)
|
|
9
|
-
|
|
8
|
+
if (!iconID)
|
|
9
|
+
return;
|
|
10
10
|
const iconMediaPost = await getPost(Number(iconID));
|
|
11
|
-
|
|
12
|
-
return iconMediaPost?.guid;
|
|
11
|
+
return iconMediaPost === null || iconMediaPost === void 0 ? void 0 : iconMediaPost.guid;
|
|
13
12
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns {Promise<string>} The language attribute, defaulting to 'en_US' if not found.
|
|
5
5
|
*/
|
|
6
|
-
export async function getLanguageAttributes()
|
|
6
|
+
export async function getLanguageAttributes() {
|
|
7
7
|
const wplang = await getOption('WPLANG');
|
|
8
8
|
return wplang || 'en_US';
|
|
9
9
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @param {string} string - The string to process.
|
|
5
5
|
* @returns {string} The string with its first letter capitalized.
|
|
6
6
|
*/
|
|
7
|
-
export function capitalizeFirstLetter(string
|
|
8
|
-
if (!string)
|
|
7
|
+
export function capitalizeFirstLetter(string) {
|
|
8
|
+
if (!string)
|
|
9
|
+
return string;
|
|
9
10
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
10
11
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import DOMPurify from "isomorphic-dompurify";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Sanitizes an HTML string.
|
|
5
4
|
*
|
|
6
5
|
* @param {string} string - The string to sanitize.
|
|
7
6
|
* @returns {string} The sanitized string.
|
|
8
7
|
*/
|
|
9
|
-
export function escHtml(string
|
|
8
|
+
export function escHtml(string) {
|
|
10
9
|
return DOMPurify.sanitize(string);
|
|
11
10
|
}
|
|
12
|
-
|
|
@@ -1,49 +1,39 @@
|
|
|
1
1
|
import { getLanguageAttributes } from "../metadata/get-language-attribute";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Creates a DateTimeFormat instance based on WordPress settings.
|
|
5
4
|
*
|
|
6
5
|
* @returns {Promise<Intl.DateTimeFormat>} The formatter instance.
|
|
7
6
|
*/
|
|
8
|
-
export async function getDateTimeFormatter()
|
|
9
|
-
|
|
7
|
+
export async function getDateTimeFormatter() {
|
|
8
|
+
var _a;
|
|
9
|
+
const dateFormat = (_a = await getOption('date_format')) !== null && _a !== void 0 ? _a : 'F j, Y';
|
|
10
10
|
const lang = await getLanguageAttributes();
|
|
11
|
-
|
|
12
|
-
const dateTimeOptionsMap: Record<string, Intl.DateTimeFormatOptions> = {
|
|
11
|
+
const dateTimeOptionsMap = {
|
|
13
12
|
'd': { day: '2-digit' },
|
|
14
13
|
'j': { day: 'numeric' },
|
|
15
|
-
|
|
16
14
|
'l': { weekday: 'long' },
|
|
17
15
|
'D': { weekday: 'short' },
|
|
18
|
-
|
|
19
16
|
'm': { month: '2-digit' },
|
|
20
17
|
'n': { month: 'numeric' },
|
|
21
18
|
'F': { month: 'long' },
|
|
22
19
|
'M': { month: 'short' },
|
|
23
|
-
|
|
24
20
|
'Y': { year: 'numeric' },
|
|
25
21
|
'y': { year: '2-digit' },
|
|
26
|
-
|
|
27
22
|
'a': { hour12: true },
|
|
28
23
|
'A': { hour12: true },
|
|
29
|
-
|
|
30
24
|
'g': { hour: 'numeric', hour12: true },
|
|
31
25
|
'h': { hour: '2-digit', hour12: true },
|
|
32
26
|
'G': { hour: 'numeric', hour12: false },
|
|
33
27
|
'H': { hour: '2-digit', hour12: false },
|
|
34
|
-
|
|
35
28
|
'i': { minute: '2-digit' },
|
|
36
29
|
's': { second: '2-digit' },
|
|
37
|
-
|
|
38
30
|
'T': { timeZoneName: 'short' }
|
|
39
31
|
};
|
|
40
|
-
|
|
41
32
|
const dateTimeOptions = dateFormat.split('').reduce((options, char) => {
|
|
42
33
|
if (dateTimeOptionsMap[char]) {
|
|
43
|
-
return {
|
|
34
|
+
return Object.assign(Object.assign({}, options), dateTimeOptionsMap[char]);
|
|
44
35
|
}
|
|
45
36
|
return options;
|
|
46
|
-
}, {}
|
|
47
|
-
|
|
37
|
+
}, {});
|
|
48
38
|
return new Intl.DateTimeFormat(lang.replace('_', '-'), dateTimeOptions);
|
|
49
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes and parses an HTML string into React elements.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} html - The HTML string to process.
|
|
5
|
+
* @returns {string | JSX.Element | JSX.Element[]} The parsed React elements.
|
|
6
|
+
*/
|
|
7
|
+
export declare function wpKsesPost(html: string): string | import("react").JSX.Element | import("react").JSX.Element[];
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import parse from 'html-react-parser';
|
|
2
2
|
import DOMPurify from "isomorphic-dompurify";
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* Sanitizes and parses an HTML string into React elements.
|
|
6
5
|
*
|
|
7
6
|
* @param {string} html - The HTML string to process.
|
|
8
7
|
* @returns {string | JSX.Element | JSX.Element[]} The parsed React elements.
|
|
9
8
|
*/
|
|
10
|
-
export function wpKsesPost(html
|
|
9
|
+
export function wpKsesPost(html) {
|
|
11
10
|
const cleanHtml = DOMPurify.sanitize(html, { USE_PROFILES: { html: true } });
|
|
12
11
|
return parse(cleanHtml);
|
|
13
12
|
}
|
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* @param {string} url - The URL to process.
|
|
5
5
|
* @returns {string} The processed URL.
|
|
6
6
|
*/
|
|
7
|
-
export function processURL(url
|
|
8
|
-
if (!process.env.WP_SITE_URL)
|
|
9
|
-
|
|
7
|
+
export function processURL(url) {
|
|
8
|
+
if (!process.env.WP_SITE_URL)
|
|
9
|
+
return url;
|
|
10
10
|
if (url.startsWith(process.env.WP_SITE_URL)) {
|
|
11
11
|
url = url.slice(process.env.WP_SITE_URL.length);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
return url || '/';
|
|
15
14
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Metadata } from 'next';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the exported metadata configuration for a given template.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} template - The name of the template file to load metadata from.
|
|
6
|
+
* @returns {Promise<Metadata | undefined>} The metadata object, or undefined if the metadata does not exist.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadMetadata(template: string): Promise<Metadata | undefined>;
|
|
9
|
+
export declare function loadTemplate(template: string): Promise<React.ComponentType<any> | undefined>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { Metadata } from 'next';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Loads a specified export suffix from a given template file.
|
|
7
5
|
*
|
|
@@ -9,46 +7,39 @@ import path from 'path';
|
|
|
9
7
|
* @param {'Metadata' | 'Template'} exportSuffix - The suffix of the export to retrieve from the file.
|
|
10
8
|
* @returns {Promise<any | undefined>} The requested export, or undefined if not found or an error occurs.
|
|
11
9
|
*/
|
|
12
|
-
async function loadFile(template
|
|
10
|
+
async function loadFile(template, exportSuffix) {
|
|
13
11
|
const absolutePath = path.join(process.cwd(), 'src', 'app', '_templates');
|
|
14
12
|
const files = fs.readdirSync(absolutePath);
|
|
15
|
-
|
|
16
|
-
const imports: any[] = [];
|
|
17
|
-
|
|
13
|
+
const imports = [];
|
|
18
14
|
for (const file of files) {
|
|
19
|
-
if (file !== (`${template.toLowerCase()}.tsx`))
|
|
20
|
-
|
|
15
|
+
if (file !== (`${template.toLowerCase()}.tsx`))
|
|
16
|
+
continue;
|
|
21
17
|
try {
|
|
22
18
|
const imported = await import(`@/app/_templates/${file}`);
|
|
23
|
-
|
|
24
19
|
const exported = imported[`${template}${exportSuffix}`];
|
|
25
|
-
|
|
26
20
|
imports.push(exported);
|
|
27
|
-
}
|
|
21
|
+
}
|
|
22
|
+
catch (_error) {
|
|
28
23
|
return undefined;
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
return imports[0];
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
/**
|
|
36
29
|
* Loads the exported metadata configuration for a given template.
|
|
37
30
|
*
|
|
38
31
|
* @param {string} template - The name of the template file to load metadata from.
|
|
39
32
|
* @returns {Promise<Metadata | undefined>} The metadata object, or undefined if the metadata does not exist.
|
|
40
33
|
*/
|
|
41
|
-
export async function loadMetadata(template
|
|
34
|
+
export async function loadMetadata(template) {
|
|
42
35
|
const metadataFn = await loadFile(template, 'Metadata');
|
|
43
36
|
if (metadataFn) {
|
|
44
37
|
return typeof metadataFn === 'function' ? metadataFn() : metadataFn;
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
|
-
export async function loadTemplate(template: string): Promise<React.ComponentType<any> | undefined> {
|
|
40
|
+
export async function loadTemplate(template) {
|
|
49
41
|
const element = await loadFile(template, 'Template');
|
|
50
42
|
if (element) {
|
|
51
|
-
return element
|
|
43
|
+
return element;
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
|
-
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Metadata } from "next";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Loads the metadata for the Archive template.
|
|
5
|
+
* Fallback: Index
|
|
6
|
+
*
|
|
7
|
+
* @returns {Promise<Metadata>} The merged metadata object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ArchiveMetadata(): Promise<Metadata>;
|
|
10
|
+
/**
|
|
11
|
+
* Renders the Archive template. Falls back to the Index template if not found.
|
|
12
|
+
* Fallback: Index
|
|
13
|
+
*
|
|
14
|
+
* @returns {Promise<JSX.Element>} The rendered template component.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ArchiveTemplate(): Promise<JSX.Element>;
|