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