wpheadless-lib 1.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/dist/api/categories.d.ts +29 -0
- package/dist/api/categories.js +91 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.js +6 -0
- package/dist/api/mappers.d.ts +5 -0
- package/dist/api/mappers.js +30 -0
- package/dist/api/posts.d.ts +44 -0
- package/dist/api/posts.js +104 -0
- package/dist/api/translations.d.ts +16 -0
- package/dist/api/translations.js +28 -0
- package/dist/api/types.d.ts +30 -0
- package/dist/api/types.js +1 -0
- package/dist/api/wpClient.d.ts +31 -0
- package/dist/api/wpClient.js +23 -0
- package/dist/app/config.d.ts +5 -0
- package/dist/app/config.js +28 -0
- package/dist/app/globals.css +326 -0
- package/dist/base/category/index.d.ts +38 -0
- package/dist/base/category/index.js +104 -0
- package/dist/base/category/pagination.d.ts +44 -0
- package/dist/base/category/pagination.js +114 -0
- package/dist/base/home/index.d.ts +13 -0
- package/dist/base/home/index.js +20 -0
- package/dist/base/home/pagination.d.ts +36 -0
- package/dist/base/home/pagination.js +83 -0
- package/dist/base/index.d.ts +7 -0
- package/dist/base/index.js +7 -0
- package/dist/base/layout/RootLayoutBase.d.ts +22 -0
- package/dist/base/layout/RootLayoutBase.js +15 -0
- package/dist/base/legal/index.d.ts +31 -0
- package/dist/base/legal/index.js +167 -0
- package/dist/base/post/index.d.ts +31 -0
- package/dist/base/post/index.js +97 -0
- package/dist/components/Breadcrumbs/index.d.ts +9 -0
- package/dist/components/Breadcrumbs/index.js +11 -0
- package/dist/components/Breadcrumbs/index.module.css +39 -0
- package/dist/components/Paginator/index.d.ts +10 -0
- package/dist/components/Paginator/index.js +16 -0
- package/dist/components/Paginator/index.module.css +13 -0
- package/dist/components/Paginator/index.utils.d.ts +7 -0
- package/dist/components/Paginator/index.utils.js +19 -0
- package/dist/components/PostCard/index.d.ts +10 -0
- package/dist/components/PostCard/index.js +22 -0
- package/dist/components/PostCard/index.module.css +56 -0
- package/dist/components/PostCard/index.types.d.ts +7 -0
- package/dist/components/PostCard/index.types.js +1 -0
- package/dist/components/PostCard/index.utils.d.ts +8 -0
- package/dist/components/PostCard/index.utils.js +23 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/layout/Footer/index.d.ts +12 -0
- package/dist/components/layout/Footer/index.js +36 -0
- package/dist/components/layout/Footer/index.module.css +61 -0
- package/dist/components/layout/Header/index.d.ts +13 -0
- package/dist/components/layout/Header/index.js +36 -0
- package/dist/components/layout/Header/index.module.css +48 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/yoast/index.d.ts +16 -0
- package/dist/plugins/yoast/index.js +44 -0
- package/dist/utils/hreflang.d.ts +37 -0
- package/dist/utils/hreflang.js +95 -0
- package/dist/utils/html.d.ts +4 -0
- package/dist/utils/html.js +8 -0
- package/dist/utils/i18n.d.ts +12 -0
- package/dist/utils/i18n.js +161 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/routing.d.ts +40 -0
- package/dist/utils/routing.js +84 -0
- package/dist/utils/seo.d.ts +75 -0
- package/dist/utils/seo.js +97 -0
- package/dist/utils/sitemap.d.ts +26 -0
- package/dist/utils/sitemap.js +327 -0
- package/dist/views/CategoryListView/index.d.ts +12 -0
- package/dist/views/CategoryListView/index.js +17 -0
- package/dist/views/CategoryListView/index.module.css +39 -0
- package/dist/views/CategoryListView/index.utils.d.ts +5 -0
- package/dist/views/CategoryListView/index.utils.js +14 -0
- package/dist/views/CategoryPaginationView/index.d.ts +13 -0
- package/dist/views/CategoryPaginationView/index.js +18 -0
- package/dist/views/CategoryPaginationView/index.module.css +39 -0
- package/dist/views/CategoryPaginationView/index.utils.d.ts +5 -0
- package/dist/views/CategoryPaginationView/index.utils.js +4 -0
- package/dist/views/HomePaginationView/index.d.ts +13 -0
- package/dist/views/HomePaginationView/index.js +9 -0
- package/dist/views/HomePaginationView/index.module.css +38 -0
- package/dist/views/HomePaginationView/index.utils.d.ts +7 -0
- package/dist/views/HomePaginationView/index.utils.js +10 -0
- package/dist/views/HomeView/index.d.ts +13 -0
- package/dist/views/HomeView/index.js +21 -0
- package/dist/views/HomeView/index.module.css +78 -0
- package/dist/views/HomeView/index.utils.d.ts +23 -0
- package/dist/views/HomeView/index.utils.js +44 -0
- package/dist/views/LegalPageView/index.d.ts +8 -0
- package/dist/views/LegalPageView/index.js +12 -0
- package/dist/views/LegalPageView/index.module.css +39 -0
- package/dist/views/LegalPageView/index.utils.d.ts +11 -0
- package/dist/views/LegalPageView/index.utils.js +16 -0
- package/dist/views/PostView/index.d.ts +10 -0
- package/dist/views/PostView/index.js +26 -0
- package/dist/views/PostView/index.module.css +80 -0
- package/dist/views/PostView/index.types.d.ts +2 -0
- package/dist/views/PostView/index.types.js +1 -0
- package/dist/views/PostView/index.utils.d.ts +15 -0
- package/dist/views/PostView/index.utils.js +22 -0
- package/dist/views/index.d.ts +6 -0
- package/dist/views/index.js +6 -0
- package/package.json +45 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
padding-top: var(--spacing-lg);
|
|
3
|
+
padding-bottom: var(--spacing-lg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.errorBox {
|
|
7
|
+
color: #ef4444;
|
|
8
|
+
padding: var(--spacing-lg);
|
|
9
|
+
text-align: center;
|
|
10
|
+
background: var(--background-alt);
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.errorHint {
|
|
15
|
+
margin-top: 0.5rem;
|
|
16
|
+
font-size: 0.875rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.empty {
|
|
20
|
+
text-align: center;
|
|
21
|
+
color: var(--foreground-light);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.featured {
|
|
25
|
+
margin-bottom: var(--spacing-lg);
|
|
26
|
+
display: grid;
|
|
27
|
+
gap: var(--spacing-lg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.featuredWithImage {
|
|
31
|
+
grid-template-columns: 1fr 1fr;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.featuredNoImage {
|
|
35
|
+
grid-template-columns: 1fr;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.featuredImageLink {
|
|
39
|
+
position: relative;
|
|
40
|
+
min-height: 400px;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.featuredImage {
|
|
45
|
+
object-fit: cover;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.featuredBody {
|
|
49
|
+
padding: var(--spacing-lg);
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.featuredBadge {
|
|
56
|
+
width: fit-content;
|
|
57
|
+
margin-bottom: var(--spacing-sm);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.featuredTitle {
|
|
61
|
+
margin-bottom: var(--spacing-sm);
|
|
62
|
+
font-size: 2rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.featuredExcerpt {
|
|
66
|
+
margin-bottom: var(--spacing-sm);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.featuredDate {
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.postsGrid {
|
|
74
|
+
display: grid;
|
|
75
|
+
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
|
76
|
+
gap: var(--spacing-md);
|
|
77
|
+
margin-bottom: var(--spacing-lg);
|
|
78
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WPPost } from "wpjsapi-lib";
|
|
2
|
+
import { type Locale } from "../../utils";
|
|
3
|
+
export type HomeCopy = {
|
|
4
|
+
title: string;
|
|
5
|
+
empty: string;
|
|
6
|
+
errorTitle: string;
|
|
7
|
+
errorHint: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getHomeCopy: (locale?: Locale) => HomeCopy;
|
|
10
|
+
export type FeaturedViewModel = {
|
|
11
|
+
postUrl: string;
|
|
12
|
+
titleHtml: string;
|
|
13
|
+
excerptHtml: string;
|
|
14
|
+
dateTime: string;
|
|
15
|
+
dateLabel: string;
|
|
16
|
+
badgeLabel?: string;
|
|
17
|
+
badgeUrl?: string | null;
|
|
18
|
+
image?: {
|
|
19
|
+
src: string;
|
|
20
|
+
alt: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare const buildFeaturedViewModel: (post: WPPost, locale?: Locale, dateLocale?: string) => FeaturedViewModel;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getFeaturedMedia, getTranslator, stripTags, } from "../../utils";
|
|
2
|
+
import { buildCategoryUrl, buildPostUrl, formatPostDate, } from "../../components/PostCard/index.utils";
|
|
3
|
+
export const getHomeCopy = (locale) => {
|
|
4
|
+
const t = getTranslator(locale);
|
|
5
|
+
return {
|
|
6
|
+
title: t("home.title"),
|
|
7
|
+
empty: t("home.empty"),
|
|
8
|
+
errorTitle: t("home.error"),
|
|
9
|
+
errorHint: t("home.errorHint"),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export const buildFeaturedViewModel = (post, locale, dateLocale = "en-US") => {
|
|
13
|
+
const t = getTranslator(locale);
|
|
14
|
+
const featuredMedia = getFeaturedMedia(post);
|
|
15
|
+
const imageUrl = featuredMedia?.source_url;
|
|
16
|
+
const categories = (post._embedded?.["wp:term"]?.[0] || []).filter(Boolean);
|
|
17
|
+
const primaryCategory = categories[0];
|
|
18
|
+
const postUrl = buildPostUrl({
|
|
19
|
+
post,
|
|
20
|
+
categorySlug: primaryCategory?.slug,
|
|
21
|
+
locale,
|
|
22
|
+
});
|
|
23
|
+
const badgeUrl = primaryCategory
|
|
24
|
+
? buildCategoryUrl(primaryCategory.slug, locale)
|
|
25
|
+
: null;
|
|
26
|
+
return {
|
|
27
|
+
postUrl,
|
|
28
|
+
titleHtml: post.title.rendered,
|
|
29
|
+
excerptHtml: post.excerpt.rendered,
|
|
30
|
+
dateTime: post.date,
|
|
31
|
+
dateLabel: formatPostDate(post.date, dateLocale),
|
|
32
|
+
badgeLabel: primaryCategory?.name,
|
|
33
|
+
badgeUrl,
|
|
34
|
+
image: imageUrl
|
|
35
|
+
? {
|
|
36
|
+
src: imageUrl,
|
|
37
|
+
alt: featuredMedia?.alt_text ||
|
|
38
|
+
t("post.featuredAlt", {
|
|
39
|
+
title: stripTags(post.title.rendered) || post.title.rendered || "",
|
|
40
|
+
}),
|
|
41
|
+
}
|
|
42
|
+
: undefined,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type WPPage } from "wpjsapi-lib";
|
|
2
|
+
type LegalPageViewProps = {
|
|
3
|
+
page: WPPage;
|
|
4
|
+
dateLocale?: string;
|
|
5
|
+
homeHref: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function LegalPageView({ page, homeHref }: LegalPageViewProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import styles from "./index.module.css";
|
|
4
|
+
import { getLegalContent, getLegalImage } from "./index.utils";
|
|
5
|
+
import { Breadcrumbs } from "../../components";
|
|
6
|
+
import { stripTags } from "../../utils";
|
|
7
|
+
export function LegalPageView({ page, homeHref }) {
|
|
8
|
+
const featuredImage = getLegalImage(page);
|
|
9
|
+
const { titleHtml, contentHtml } = getLegalContent(page);
|
|
10
|
+
const titleText = stripTags(titleHtml) || titleHtml;
|
|
11
|
+
return (_jsxs("article", { className: styles.article, children: [_jsx(Breadcrumbs, { items: [{ label: "Home", href: homeHref }, { label: titleText }] }), featuredImage && (_jsx("div", { className: styles.imageWrapper, children: _jsx(Image, { src: featuredImage.src, alt: featuredImage.alt, width: featuredImage.width, height: featuredImage.height, className: styles.image, priority: true }) })), _jsx("h1", { dangerouslySetInnerHTML: { __html: titleHtml }, className: styles.title }), _jsx("div", { dangerouslySetInnerHTML: { __html: contentHtml }, className: `post-content ${styles.content}` })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.article {
|
|
2
|
+
max-width: 800px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.imageWrapper {
|
|
8
|
+
margin-bottom: 2rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.image {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: auto;
|
|
14
|
+
border-radius: 8px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.title {
|
|
18
|
+
margin-bottom: 1rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.meta {
|
|
22
|
+
font-size: 0.875rem;
|
|
23
|
+
color: #666;
|
|
24
|
+
margin-bottom: 2rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.author {
|
|
28
|
+
margin-top: 1rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.authorBio {
|
|
32
|
+
margin-top: 0.5rem;
|
|
33
|
+
font-style: italic;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.content {
|
|
37
|
+
line-height: 1.8;
|
|
38
|
+
font-size: 1.125rem;
|
|
39
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WPPage } from "wpjsapi-lib";
|
|
2
|
+
export declare const getLegalImage: (page: WPPage) => {
|
|
3
|
+
src: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getLegalContent: (page: WPPage) => {
|
|
9
|
+
titleHtml: string;
|
|
10
|
+
contentHtml: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getFeaturedMedia, stripTags } from "../../utils";
|
|
2
|
+
export const getLegalImage = (page) => {
|
|
3
|
+
const media = getFeaturedMedia(page);
|
|
4
|
+
if (!media?.source_url)
|
|
5
|
+
return null;
|
|
6
|
+
return {
|
|
7
|
+
src: media.source_url,
|
|
8
|
+
alt: media.alt_text || stripTags(page.title.rendered) || page.title.rendered,
|
|
9
|
+
width: media.media_details?.width || 800,
|
|
10
|
+
height: media.media_details?.height || 400,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const getLegalContent = (page) => ({
|
|
14
|
+
titleHtml: page.title.rendered,
|
|
15
|
+
contentHtml: page.content.rendered,
|
|
16
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type WPPost } from "wpjsapi-lib";
|
|
2
|
+
import { type Locale } from "../../utils";
|
|
3
|
+
type PostViewProps = {
|
|
4
|
+
post: WPPost;
|
|
5
|
+
dateLocale?: string;
|
|
6
|
+
categoryBasePath?: string;
|
|
7
|
+
locale?: Locale;
|
|
8
|
+
};
|
|
9
|
+
export declare function PostView({ post, dateLocale, categoryBasePath, locale, }: PostViewProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import styles from "./index.module.css";
|
|
4
|
+
import { getTranslator } from "../../utils";
|
|
5
|
+
import { Breadcrumbs } from "../../components";
|
|
6
|
+
import { buildCategoryUrl, formatPublishedDate, getAuthor, getFeaturedImage, getPrimaryCategory, } from "./index.utils";
|
|
7
|
+
import { stripTags } from "../../utils";
|
|
8
|
+
export function PostView({ post, dateLocale = "en-US", categoryBasePath = "/", locale, }) {
|
|
9
|
+
const t = getTranslator(locale);
|
|
10
|
+
const author = getAuthor(post);
|
|
11
|
+
const primaryCategory = getPrimaryCategory(post);
|
|
12
|
+
const categoryUrl = buildCategoryUrl(categoryBasePath, primaryCategory?.slug);
|
|
13
|
+
const featuredImage = getFeaturedImage(post, locale);
|
|
14
|
+
const publishedDate = formatPublishedDate(post.date, dateLocale);
|
|
15
|
+
const breadcrumbs = primaryCategory && categoryUrl
|
|
16
|
+
? [
|
|
17
|
+
{ label: "Home", href: categoryBasePath },
|
|
18
|
+
{ label: primaryCategory.name, href: categoryUrl },
|
|
19
|
+
{ label: stripTags(post.title.rendered) || post.title.rendered },
|
|
20
|
+
]
|
|
21
|
+
: [
|
|
22
|
+
{ label: "Home", href: categoryBasePath },
|
|
23
|
+
{ label: stripTags(post.title.rendered) || post.title.rendered },
|
|
24
|
+
];
|
|
25
|
+
return (_jsx("div", { className: `container ${styles.container}`, children: _jsxs("article", { className: styles.article, children: [_jsx(Breadcrumbs, { items: breadcrumbs }), _jsxs("header", { className: styles.postHeader, children: [primaryCategory && (_jsx("div", { className: styles.badgeWrapper, children: categoryUrl ? (_jsx("a", { href: categoryUrl, className: "badge", children: primaryCategory.name })) : (_jsx("span", { className: "badge", children: primaryCategory.name })) })), _jsx("h1", { dangerouslySetInnerHTML: { __html: post.title.rendered }, className: styles.title }), _jsxs("div", { className: styles.meta, children: [author && (_jsx("span", { className: styles.authorLabel, children: t("post.authorPrefix", { name: author.name }) })), _jsx("span", { children: "\u2022" }), _jsx("time", { dateTime: post.date, children: publishedDate })] })] }), featuredImage && (_jsx("figure", { className: styles.figure, children: _jsx(Image, { src: featuredImage.src, alt: featuredImage.alt, width: featuredImage.width, height: featuredImage.height, className: styles.image, priority: true, sizes: "(max-width: 900px) 100vw, 900px" }) })), _jsx("div", { dangerouslySetInnerHTML: { __html: post.content.rendered }, className: `post-content ${styles.content}` }), author && author.description && (_jsxs("aside", { className: `card ${styles.authorCard}`, children: [_jsx("h2", { className: styles.authorTitle, children: t("post.aboutAuthor") }), _jsxs("address", { className: styles.authorAddress, children: [_jsx("strong", { className: styles.authorName, children: author.name }), _jsx("p", { className: styles.authorBio, children: author.description })] })] }))] }) }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
padding-top: var(--spacing-xl);
|
|
3
|
+
padding-bottom: var(--spacing-xl);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.article {
|
|
7
|
+
max-width: 900px;
|
|
8
|
+
margin: 0 auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.badgeWrapper {
|
|
12
|
+
margin-bottom: var(--spacing-sm);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.title {
|
|
16
|
+
font-size: clamp(2rem, 5vw, 3rem);
|
|
17
|
+
font-weight: 800;
|
|
18
|
+
line-height: 1.2;
|
|
19
|
+
margin-bottom: var(--spacing-md);
|
|
20
|
+
color: var(--foreground);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.meta {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: var(--spacing-sm);
|
|
27
|
+
margin-bottom: var(--spacing-lg);
|
|
28
|
+
color: var(--foreground-light);
|
|
29
|
+
font-size: 0.9375rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.authorLabel {
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.figure {
|
|
37
|
+
margin-bottom: var(--spacing-lg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.image {
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: auto;
|
|
43
|
+
border-radius: 12px;
|
|
44
|
+
box-shadow: 0 4px 12px var(--shadow);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.content {
|
|
48
|
+
font-size: 1.125rem;
|
|
49
|
+
line-height: 1.8;
|
|
50
|
+
color: var(--foreground);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.authorCard {
|
|
54
|
+
margin-top: var(--spacing-xl);
|
|
55
|
+
padding: var(--spacing-lg);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.authorAddress {
|
|
59
|
+
font-style: normal;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.authorTitle {
|
|
63
|
+
font-size: 1.25rem;
|
|
64
|
+
font-weight: 700;
|
|
65
|
+
margin-top: 0;
|
|
66
|
+
margin-bottom: var(--spacing-md);
|
|
67
|
+
color: var(--foreground);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.authorName {
|
|
71
|
+
display: block;
|
|
72
|
+
margin-bottom: var(--spacing-xs);
|
|
73
|
+
font-size: 1.125rem;
|
|
74
|
+
color: var(--foreground);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.authorBio {
|
|
78
|
+
color: var(--foreground-light);
|
|
79
|
+
line-height: 1.6;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WPPost } from "wpjsapi-lib";
|
|
2
|
+
import { type Locale } from "../../utils";
|
|
3
|
+
import type { EmbeddedAuthor } from "./index.types";
|
|
4
|
+
import type { EmbeddedCategory } from "../../api";
|
|
5
|
+
export declare const getCategories: (post: WPPost) => EmbeddedCategory[];
|
|
6
|
+
export declare const getPrimaryCategory: (post: WPPost) => EmbeddedCategory | undefined;
|
|
7
|
+
export declare const buildCategoryUrl: (basePath: string, slug?: string) => string | null;
|
|
8
|
+
export declare const getAuthor: (post: WPPost) => EmbeddedAuthor | undefined;
|
|
9
|
+
export declare const getFeaturedImage: (post: WPPost, locale?: Locale) => {
|
|
10
|
+
src: string;
|
|
11
|
+
alt: string;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const formatPublishedDate: (date: string, dateLocale?: string) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getFeaturedMedia, getTranslator, stripTags, } from "../../utils";
|
|
2
|
+
import { formatPostDate } from "../../components/PostCard/index.utils";
|
|
3
|
+
export const getCategories = (post) => (post._embedded?.["wp:term"]?.[0] || []).filter(Boolean);
|
|
4
|
+
export const getPrimaryCategory = (post) => getCategories(post)[0];
|
|
5
|
+
export const buildCategoryUrl = (basePath, slug) => (slug ? `${basePath}${slug}`.replace(/\/+/g, "/") : null);
|
|
6
|
+
export const getAuthor = (post) => post._embedded?.author?.[0];
|
|
7
|
+
export const getFeaturedImage = (post, locale) => {
|
|
8
|
+
const t = getTranslator(locale);
|
|
9
|
+
const featuredMedia = getFeaturedMedia(post);
|
|
10
|
+
if (!featuredMedia?.source_url)
|
|
11
|
+
return null;
|
|
12
|
+
return {
|
|
13
|
+
src: featuredMedia.source_url,
|
|
14
|
+
alt: featuredMedia.alt_text ||
|
|
15
|
+
t("post.articleAlt", {
|
|
16
|
+
title: stripTags(post.title.rendered) || post.title.rendered || "",
|
|
17
|
+
}),
|
|
18
|
+
width: featuredMedia.media_details?.width || 900,
|
|
19
|
+
height: featuredMedia.media_details?.height || 500,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const formatPublishedDate = (date, dateLocale) => formatPostDate(date, dateLocale);
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wpheadless-lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json && pnpm run copy:assets",
|
|
11
|
+
"copy:assets": "node ./scripts/copy-assets.mjs",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"prepare": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"**/*.css"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"wpjsapi-lib": "3.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20",
|
|
32
|
+
"@types/react": "^19",
|
|
33
|
+
"@types/react-dom": "^19",
|
|
34
|
+
"next": "^16.0.3",
|
|
35
|
+
"react": "^19",
|
|
36
|
+
"react-dom": "^19",
|
|
37
|
+
"tsc-alias": "^1.8.10",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"next": "16.0.3",
|
|
42
|
+
"react": "^19",
|
|
43
|
+
"react-dom": "^19"
|
|
44
|
+
}
|
|
45
|
+
}
|