wpheadless-lib 1.1.5 → 1.1.7
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/components/PostCard/index.d.ts +2 -1
- package/dist/components/PostCard/index.js +3 -2
- package/dist/components/PostCard/index.types.d.ts +1 -0
- package/dist/components/PostCard/index.utils.d.ts +2 -2
- package/dist/components/PostCard/index.utils.js +13 -3
- package/dist/components/layout/Footer/index.js +7 -1
- package/dist/components/layout/Footer/index.module.css +1 -1
- package/dist/components/layout/Header/HeaderClient.js +7 -1
- package/dist/components/layout/Header/index.module.css +1 -1
- package/dist/views/CategoryListView/index.d.ts +2 -1
- package/dist/views/CategoryListView/index.js +2 -2
- package/dist/views/CategoryPaginationView/index.d.ts +2 -1
- package/dist/views/CategoryPaginationView/index.js +2 -2
- package/dist/views/HomePaginationView/index.d.ts +2 -1
- package/dist/views/HomePaginationView/index.js +2 -2
- package/dist/views/HomeView/index.d.ts +2 -1
- package/dist/views/HomeView/index.js +3 -3
- package/dist/views/HomeView/index.utils.d.ts +1 -1
- package/dist/views/HomeView/index.utils.js +3 -2
- package/dist/views/PostView/index.d.ts +2 -1
- package/dist/views/PostView/index.js +2 -2
- package/dist/views/PostView/index.module.css +12 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ interface PostCardProps {
|
|
|
5
5
|
categorySlug?: string;
|
|
6
6
|
locale?: Locale;
|
|
7
7
|
dateLocale?: string;
|
|
8
|
+
basePath?: string;
|
|
8
9
|
}
|
|
9
|
-
export default function PostCard({ post, categorySlug, locale, dateLocale, }: PostCardProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function PostCard({ post, categorySlug, locale, dateLocale, basePath, }: PostCardProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -8,7 +8,7 @@ function truncateText(text, max = 20) {
|
|
|
8
8
|
const normalized = text.trim();
|
|
9
9
|
return normalized.length > max ? `${normalized.slice(0, max)}...` : normalized;
|
|
10
10
|
}
|
|
11
|
-
export default function PostCard({ post, categorySlug, locale = "en", dateLocale = "en-US", }) {
|
|
11
|
+
export default function PostCard({ post, categorySlug, locale = "en", dateLocale = "en-US", basePath, }) {
|
|
12
12
|
const featuredMedia = getFeaturedMedia(post);
|
|
13
13
|
const imageUrl = featuredMedia?.source_url;
|
|
14
14
|
const categories = (post._embedded?.["wp:term"]?.[0] || []).filter((cat) => Boolean(cat?.slug));
|
|
@@ -17,8 +17,9 @@ export default function PostCard({ post, categorySlug, locale = "en", dateLocale
|
|
|
17
17
|
post,
|
|
18
18
|
categorySlug: resolvedCategory,
|
|
19
19
|
locale,
|
|
20
|
+
basePath,
|
|
20
21
|
});
|
|
21
|
-
return (_jsxs("article", { className: `${styles.card} card`, children: [categories.length > 0 && (_jsx("div", { className: styles.badges, children: categories.map((cat) => (_jsx(Link, { href: buildCategoryUrl(cat.slug, locale), className: `badge ${styles.badge}`, title: cat.name, children: truncateText(cat.name, 20) }, cat.id ?? cat.slug))) })), _jsxs(Link, { href: postUrl, className: styles.postLink, children: [imageUrl && (_jsx("div", { className: styles.imageWrapper, children: _jsx(Image, { src: imageUrl, alt: featuredMedia?.alt_text || post.title.rendered, fill: true, style: { objectFit: "cover" }, sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw" }) })), _jsxs("div", { className: styles.body, children: [_jsx("h2", { className: styles.title, dangerouslySetInnerHTML: {
|
|
22
|
+
return (_jsxs("article", { className: `${styles.card} card`, children: [categories.length > 0 && (_jsx("div", { className: styles.badges, children: categories.map((cat) => (_jsx(Link, { href: buildCategoryUrl(cat.slug, locale, basePath), className: `badge ${styles.badge}`, title: cat.name, children: truncateText(cat.name, 20) }, cat.id ?? cat.slug))) })), _jsxs(Link, { href: postUrl, className: styles.postLink, children: [imageUrl && (_jsx("div", { className: styles.imageWrapper, children: _jsx(Image, { src: imageUrl, alt: featuredMedia?.alt_text || post.title.rendered, fill: true, style: { objectFit: "cover" }, sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw" }) })), _jsxs("div", { className: styles.body, children: [_jsx("h2", { className: styles.title, dangerouslySetInnerHTML: {
|
|
22
23
|
__html: post.title.rendered,
|
|
23
24
|
} }), _jsx("div", { dangerouslySetInnerHTML: {
|
|
24
25
|
__html: post.excerpt.rendered,
|
|
@@ -3,6 +3,6 @@ import { type Locale } from "../../utils";
|
|
|
3
3
|
import type { BuildUrlArgs } from "./index.types";
|
|
4
4
|
export declare const getLangPrefix: (locale?: Locale) => string;
|
|
5
5
|
export declare const resolveCategorySlug: (post: WPPost, categorySlug?: string) => string | undefined;
|
|
6
|
-
export declare const buildPostUrl: ({ post, categorySlug, locale }: BuildUrlArgs) => string;
|
|
7
|
-
export declare const buildCategoryUrl: (slug: string, locale?: Locale) => string;
|
|
6
|
+
export declare const buildPostUrl: ({ post, categorySlug, locale, basePath, }: BuildUrlArgs) => string;
|
|
7
|
+
export declare const buildCategoryUrl: (slug: string, locale?: Locale, basePath?: string) => string;
|
|
8
8
|
export declare const formatPostDate: (date: string, dateLocale?: string) => string;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { ensureTrailingSlash } from "../../utils";
|
|
2
2
|
export const getLangPrefix = (locale) => locale && locale !== "en" ? `/${locale}` : "";
|
|
3
|
+
const normalizeBasePath = (basePath) => {
|
|
4
|
+
if (!basePath)
|
|
5
|
+
return "";
|
|
6
|
+
const withLeadingSlash = basePath.startsWith("/")
|
|
7
|
+
? basePath
|
|
8
|
+
: `/${basePath}`;
|
|
9
|
+
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
10
|
+
return trimmed === "/" ? "" : trimmed;
|
|
11
|
+
};
|
|
12
|
+
const resolveLinkPrefix = (basePath, locale) => basePath !== undefined ? normalizeBasePath(basePath) : getLangPrefix(locale);
|
|
3
13
|
export const resolveCategorySlug = (post, categorySlug) => {
|
|
4
14
|
if (categorySlug)
|
|
5
15
|
return categorySlug;
|
|
6
16
|
const categories = (post._embedded?.["wp:term"]?.[0] || []);
|
|
7
17
|
return categories[0]?.slug;
|
|
8
18
|
};
|
|
9
|
-
export const buildPostUrl = ({ post, categorySlug, locale }) => {
|
|
10
|
-
const langPrefix =
|
|
19
|
+
export const buildPostUrl = ({ post, categorySlug, locale, basePath, }) => {
|
|
20
|
+
const langPrefix = resolveLinkPrefix(basePath, locale);
|
|
11
21
|
const resolvedCategory = categorySlug || resolveCategorySlug(post);
|
|
12
22
|
const postPath = resolvedCategory
|
|
13
23
|
? `/${resolvedCategory}/${post.slug}`
|
|
@@ -15,7 +25,7 @@ export const buildPostUrl = ({ post, categorySlug, locale }) => {
|
|
|
15
25
|
const url = `${langPrefix}${postPath}`.replace(/\/+/g, "/");
|
|
16
26
|
return ensureTrailingSlash(url);
|
|
17
27
|
};
|
|
18
|
-
export const buildCategoryUrl = (slug, locale) => ensureTrailingSlash(`${
|
|
28
|
+
export const buildCategoryUrl = (slug, locale, basePath) => ensureTrailingSlash(`${resolveLinkPrefix(basePath, locale)}/${slug}`.replace(/\/+/g, "/"));
|
|
19
29
|
export const formatPostDate = (date, dateLocale) => new Date(date).toLocaleDateString(dateLocale || "en-US", {
|
|
20
30
|
year: "numeric",
|
|
21
31
|
month: "long",
|
|
@@ -21,6 +21,12 @@ export default async function Footer({ menuId, wpApiUrl, wpUsername, wpAppPasswo
|
|
|
21
21
|
const t = getTranslator(locale);
|
|
22
22
|
const logoData = logo?.src ? logo : null;
|
|
23
23
|
const logoAlt = logoData?.alt || siteName;
|
|
24
|
+
const logoStyle = logoData
|
|
25
|
+
? {
|
|
26
|
+
...(logoData.height ? { height: logoData.height } : {}),
|
|
27
|
+
...(logoData.width ? { width: logoData.width } : {}),
|
|
28
|
+
}
|
|
29
|
+
: undefined;
|
|
24
30
|
try {
|
|
25
31
|
const parsedMenuId = parseInt(menuId);
|
|
26
32
|
const itemsResponse = await menusApi.items.list({
|
|
@@ -34,5 +40,5 @@ export default async function Footer({ menuId, wpApiUrl, wpUsername, wpAppPasswo
|
|
|
34
40
|
catch (e) {
|
|
35
41
|
console.error("Error obteniendo menú footer:", e);
|
|
36
42
|
}
|
|
37
|
-
return (_jsx("footer", { className: styles.footer, children: _jsx("div", { className: "container", children: _jsxs("div", { className: styles.wrapper, children: [_jsxs("div", { className: styles.grid, children: [_jsxs("div", { children: [_jsx("h3", { className: styles.siteName, children: logoData ? (_jsx("img", { src: logoData.src, alt: logoAlt, className: styles.logoImage, width: logoData.width, height: logoData.height })) : (siteName) }), _jsx("p", { className: `${styles.muted} text-muted`, children: t("footer.tagline") })] }), menuItems.length > 0 && (_jsxs("nav", { "aria-label": t("footer.navAria"), className: styles.nav, children: [_jsx("h4", { className: styles.navTitle, children: t("footer.navTitle") }), _jsx("ul", { className: styles.list, children: menuItems.map((item) => (_jsx("li", { children: _jsx(Link, { href: convertWpUrl(item.url, wpApiUrl), className: "footer-link", children: item.title.rendered }) }, item.id))) })] }))] }), _jsxs("div", { className: styles.bottomBar, children: [_jsxs("span", { children: ["\u00A9 ", new Date().getFullYear(), " ", siteName] }), _jsx("span", { children: t("footer.noCookies") })] })] }) }) }));
|
|
43
|
+
return (_jsx("footer", { className: styles.footer, children: _jsx("div", { className: "container", children: _jsxs("div", { className: styles.wrapper, children: [_jsxs("div", { className: styles.grid, children: [_jsxs("div", { children: [_jsx("h3", { className: styles.siteName, children: logoData ? (_jsx("img", { src: logoData.src, alt: logoAlt, className: styles.logoImage, width: logoData.width, height: logoData.height, style: logoStyle })) : (siteName) }), _jsx("p", { className: `${styles.muted} text-muted`, children: t("footer.tagline") })] }), menuItems.length > 0 && (_jsxs("nav", { "aria-label": t("footer.navAria"), className: styles.nav, children: [_jsx("h4", { className: styles.navTitle, children: t("footer.navTitle") }), _jsx("ul", { className: styles.list, children: menuItems.map((item) => (_jsx("li", { children: _jsx(Link, { href: convertWpUrl(item.url, wpApiUrl), className: "footer-link", children: item.title.rendered }) }, item.id))) })] }))] }), _jsxs("div", { className: styles.bottomBar, children: [_jsxs("span", { children: ["\u00A9 ", new Date().getFullYear(), " ", siteName] }), _jsx("span", { children: t("footer.noCookies") })] })] }) }) }));
|
|
38
44
|
}
|
|
@@ -23,7 +23,13 @@ export default function HeaderClient({ menuLinks, siteName, homeHref, labels, lo
|
|
|
23
23
|
const menuLabel = isMenuOpen ? labels.closeMenu : labels.openMenu;
|
|
24
24
|
const logoData = logo?.src ? logo : null;
|
|
25
25
|
const logoAlt = logoData?.alt || siteName;
|
|
26
|
-
|
|
26
|
+
const logoStyle = logoData
|
|
27
|
+
? {
|
|
28
|
+
...(logoData.height ? { height: logoData.height } : {}),
|
|
29
|
+
...(logoData.width ? { width: logoData.width } : {}),
|
|
30
|
+
}
|
|
31
|
+
: undefined;
|
|
32
|
+
return (_jsxs("div", { className: styles.inner, children: [_jsx(Link, { href: homeHref, className: styles.logo, children: logoData ? (_jsx("img", { src: logoData.src, alt: logoAlt, className: styles.logoImage, width: logoData.width, height: logoData.height, style: logoStyle })) : (siteName) }), menuLinks.length > 0 && (_jsxs("div", { className: styles.navWrapper, children: [_jsxs("button", { type: "button", className: styles.menuButton, "aria-expanded": isMenuOpen, "aria-controls": "primary-navigation", "aria-label": menuLabel, onClick: toggleMenu, children: [_jsxs("span", { className: styles.menuIcon, "aria-hidden": "true", children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }), _jsx("span", { className: styles.menuText, children: menuLabel })] }), _jsx("nav", { id: "primary-navigation", "aria-label": labels.navAria, className: `${styles.nav} ${isMenuOpen ? styles.navOpen : ""}`, "aria-hidden": !isMenuOpen && isMobileView, hidden: !isMenuOpen && isMobileView, children: _jsx("ul", { className: styles.list, children: menuLinks.map((item) => (_jsx("li", { children: _jsx(Link, { href: item.href, className: "header-link", onClick: handleLinkClick, target: item.target || undefined, rel: item.target === "_blank"
|
|
27
33
|
? "noopener noreferrer"
|
|
28
34
|
: undefined, children: item.label }) }, item.id))) }) })] }))] }));
|
|
29
35
|
}
|
|
@@ -6,8 +6,9 @@ type CategoryListViewProps = {
|
|
|
6
6
|
totalPages: number;
|
|
7
7
|
baseUrl?: string;
|
|
8
8
|
homeHref?: string;
|
|
9
|
+
linkBasePath?: string;
|
|
9
10
|
locale?: Locale;
|
|
10
11
|
dateLocale?: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function CategoryListView({ category, posts, totalPages, baseUrl, homeHref, locale, dateLocale, }: CategoryListViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function CategoryListView({ category, posts, totalPages, baseUrl, homeHref, linkBasePath, locale, dateLocale, }: CategoryListViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -5,7 +5,7 @@ import styles from "./index.module.css";
|
|
|
5
5
|
import { getCountLabel, getEmptyLabel, getPaginatorBase } from "./index.utils";
|
|
6
6
|
import { Breadcrumbs } from "../../components";
|
|
7
7
|
import { getTranslator } from "../../utils";
|
|
8
|
-
export function CategoryListView({ category, posts, totalPages, baseUrl, homeHref = "/", locale, dateLocale = "en-US", }) {
|
|
8
|
+
export function CategoryListView({ category, posts, totalPages, baseUrl, homeHref = "/", linkBasePath, locale, dateLocale = "en-US", }) {
|
|
9
9
|
const paginatorBase = getPaginatorBase(category, baseUrl);
|
|
10
10
|
const countLabel = getCountLabel(category, locale);
|
|
11
11
|
const emptyLabel = getEmptyLabel(locale);
|
|
@@ -13,5 +13,5 @@ export function CategoryListView({ category, posts, totalPages, baseUrl, homeHre
|
|
|
13
13
|
return (_jsxs("div", { className: `container ${styles.container}`, children: [_jsxs("header", { className: styles.header, children: [_jsx(Breadcrumbs, { items: [
|
|
14
14
|
{ label: "Home", href: homeHref },
|
|
15
15
|
{ label: category.name },
|
|
16
|
-
] }), _jsx("h1", { className: styles.title, children: category.name }), category.description && (_jsx("div", { className: styles.description, dangerouslySetInnerHTML: { __html: category.description } })), countLabel && _jsx("p", { className: styles.count, children: countLabel })] }), posts.length === 0 ? (_jsx("p", { className: styles.empty, children: emptyLabel })) : (_jsxs("section", { "aria-label": t("home.title"), className: styles.gridSection, children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, categorySlug: category.slug, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: 1, totalPages: totalPages, baseUrl: paginatorBase, locale: locale })] }))] }));
|
|
16
|
+
] }), _jsx("h1", { className: styles.title, children: category.name }), category.description && (_jsx("div", { className: styles.description, dangerouslySetInnerHTML: { __html: category.description } })), countLabel && _jsx("p", { className: styles.count, children: countLabel })] }), posts.length === 0 ? (_jsx("p", { className: styles.empty, children: emptyLabel })) : (_jsxs("section", { "aria-label": t("home.title"), className: styles.gridSection, children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, categorySlug: category.slug, basePath: linkBasePath, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: 1, totalPages: totalPages, baseUrl: paginatorBase, locale: locale })] }))] }));
|
|
17
17
|
}
|
|
@@ -6,8 +6,9 @@ type CategoryPaginationViewProps = {
|
|
|
6
6
|
currentPage: number;
|
|
7
7
|
totalPages: number;
|
|
8
8
|
baseUrl?: string;
|
|
9
|
+
linkBasePath?: string;
|
|
9
10
|
locale?: Locale;
|
|
10
11
|
dateLocale?: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function CategoryPaginationView({ category, posts, currentPage, totalPages, baseUrl, locale, dateLocale, }: CategoryPaginationViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function CategoryPaginationView({ category, posts, currentPage, totalPages, baseUrl, linkBasePath, locale, dateLocale, }: CategoryPaginationViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -5,7 +5,7 @@ import styles from "./index.module.css";
|
|
|
5
5
|
import { getEmptyLabel, getPageLabel, getPaginatorBase } from "./index.utils";
|
|
6
6
|
import { Breadcrumbs } from "../../components";
|
|
7
7
|
import { getTranslator } from "../../utils";
|
|
8
|
-
export function CategoryPaginationView({ category, posts, currentPage, totalPages, baseUrl, locale, dateLocale = "en-US", }) {
|
|
8
|
+
export function CategoryPaginationView({ category, posts, currentPage, totalPages, baseUrl, linkBasePath, locale, dateLocale = "en-US", }) {
|
|
9
9
|
const paginatorBase = getPaginatorBase(category, baseUrl);
|
|
10
10
|
const pageLabel = getPageLabel(locale, currentPage);
|
|
11
11
|
const emptyLabel = getEmptyLabel(locale);
|
|
@@ -14,5 +14,5 @@ export function CategoryPaginationView({ category, posts, currentPage, totalPage
|
|
|
14
14
|
{ label: "Home", href: paginatorBase || "/" },
|
|
15
15
|
{ label: category.name },
|
|
16
16
|
{ label: pageLabel },
|
|
17
|
-
] }), _jsx("h1", { className: styles.title, children: category.name }), _jsx("p", { className: styles.pageLabel, children: pageLabel })] }), posts.length === 0 ? (_jsx("p", { className: styles.empty, children: emptyLabel })) : (_jsxs("section", { "aria-label": t("category.pageLabel", { page: currentPage }), className: styles.gridSection, children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, categorySlug: category.slug, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: currentPage, totalPages: totalPages, baseUrl: paginatorBase, locale: locale })] }))] }));
|
|
17
|
+
] }), _jsx("h1", { className: styles.title, children: category.name }), _jsx("p", { className: styles.pageLabel, children: pageLabel })] }), posts.length === 0 ? (_jsx("p", { className: styles.empty, children: emptyLabel })) : (_jsxs("section", { "aria-label": t("category.pageLabel", { page: currentPage }), className: styles.gridSection, children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, categorySlug: category.slug, basePath: linkBasePath, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: currentPage, totalPages: totalPages, baseUrl: paginatorBase, locale: locale })] }))] }));
|
|
18
18
|
}
|
|
@@ -6,8 +6,9 @@ type HomePaginationViewProps = {
|
|
|
6
6
|
totalPages: number;
|
|
7
7
|
error?: string | null;
|
|
8
8
|
baseUrl?: string;
|
|
9
|
+
linkBasePath?: string;
|
|
9
10
|
locale?: Locale;
|
|
10
11
|
dateLocale?: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function HomePaginationView({ posts, currentPage, totalPages, error, baseUrl, locale, dateLocale, }: HomePaginationViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function HomePaginationView({ posts, currentPage, totalPages, error, baseUrl, linkBasePath, locale, dateLocale, }: HomePaginationViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -3,7 +3,7 @@ import Paginator from "../../components/Paginator";
|
|
|
3
3
|
import PostCard from "../../components/PostCard";
|
|
4
4
|
import styles from "./index.module.css";
|
|
5
5
|
import { buildHomePaginationCopy } from "./index.utils";
|
|
6
|
-
export function HomePaginationView({ posts, currentPage, totalPages, error, baseUrl = "", locale, dateLocale = "en-US", }) {
|
|
6
|
+
export function HomePaginationView({ posts, currentPage, totalPages, error, baseUrl = "", linkBasePath, locale, dateLocale = "en-US", }) {
|
|
7
7
|
const copy = buildHomePaginationCopy(locale, currentPage, error);
|
|
8
|
-
return (_jsxs("div", { className: `container ${styles.container}`, children: [_jsxs("header", { className: styles.header, children: [_jsx("h1", { className: styles.title, children: copy.title }), _jsx("p", { className: styles.subtitle, children: copy.subtitle })] }), error ? (_jsx("div", { className: `card ${styles.errorCard}`, children: copy.errorText && _jsx("p", { children: copy.errorText }) })) : posts.length === 0 ? (_jsx("p", { className: styles.empty, children: copy.empty })) : (_jsxs("section", { "aria-label": copy.title, className: styles.gridSection, role: "region", children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: currentPage, totalPages: totalPages, baseUrl: baseUrl, locale: locale })] }))] }));
|
|
8
|
+
return (_jsxs("div", { className: `container ${styles.container}`, children: [_jsxs("header", { className: styles.header, children: [_jsx("h1", { className: styles.title, children: copy.title }), _jsx("p", { className: styles.subtitle, children: copy.subtitle })] }), error ? (_jsx("div", { className: `card ${styles.errorCard}`, children: copy.errorText && _jsx("p", { children: copy.errorText }) })) : posts.length === 0 ? (_jsx("p", { className: styles.empty, children: copy.empty })) : (_jsxs("section", { "aria-label": copy.title, className: styles.gridSection, role: "region", children: [_jsx("div", { className: styles.grid, children: posts.map((post) => (_jsx(PostCard, { post: post, basePath: linkBasePath, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: currentPage, totalPages: totalPages, baseUrl: baseUrl, locale: locale })] }))] }));
|
|
9
9
|
}
|
|
@@ -6,8 +6,9 @@ type HomeViewProps = {
|
|
|
6
6
|
error?: string | null;
|
|
7
7
|
totalPages: number;
|
|
8
8
|
baseUrl?: string;
|
|
9
|
+
linkBasePath?: string;
|
|
9
10
|
locale?: Locale;
|
|
10
11
|
dateLocale?: string;
|
|
11
12
|
};
|
|
12
|
-
export declare function HomeView({ featuredPost, regularPosts, error, totalPages, baseUrl, locale, dateLocale, }: HomeViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function HomeView({ featuredPost, regularPosts, error, totalPages, baseUrl, linkBasePath, locale, dateLocale, }: HomeViewProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -9,10 +9,10 @@ function truncateLabel(label, max = 20) {
|
|
|
9
9
|
const trimmed = label.trim();
|
|
10
10
|
return trimmed.length > max ? `${trimmed.slice(0, max)}...` : trimmed;
|
|
11
11
|
}
|
|
12
|
-
export function HomeView({ featuredPost, regularPosts, error, totalPages, baseUrl = "", locale, dateLocale = "en-US", }) {
|
|
12
|
+
export function HomeView({ featuredPost, regularPosts, error, totalPages, baseUrl = "", linkBasePath, locale, dateLocale = "en-US", }) {
|
|
13
13
|
const copy = getHomeCopy(locale);
|
|
14
14
|
const featuredModel = featuredPost
|
|
15
|
-
? buildFeaturedViewModel(featuredPost, locale, dateLocale)
|
|
15
|
+
? buildFeaturedViewModel(featuredPost, locale, dateLocale, linkBasePath)
|
|
16
16
|
: null;
|
|
17
17
|
return (_jsx("div", { className: `container ${styles.container}`, children: error ? (_jsxs("div", { className: styles.errorBox, children: [_jsxs("p", { children: [copy.errorTitle, ": ", error] }), _jsx("p", { className: styles.errorHint, children: copy.errorHint })] })) : !featuredModel && regularPosts.length === 0 ? (_jsx("p", { className: styles.empty, children: copy.empty })) : (_jsxs(_Fragment, { children: [featuredModel && (_jsxs("article", { className: `card ${styles.featured} ${featuredModel.image
|
|
18
18
|
? styles.featuredWithImage
|
|
@@ -21,5 +21,5 @@ export function HomeView({ featuredPost, regularPosts, error, totalPages, baseUr
|
|
|
21
21
|
__html: featuredModel.titleHtml,
|
|
22
22
|
}, className: styles.featuredTitle }) }), _jsx("div", { dangerouslySetInnerHTML: {
|
|
23
23
|
__html: featuredModel.excerptHtml,
|
|
24
|
-
}, className: `text-muted ${styles.featuredExcerpt}` }), _jsx("time", { dateTime: featuredModel.dateTime, className: `text-muted ${styles.featuredDate}`, children: featuredModel.dateLabel })] })] })), _jsx("section", { className: styles.postsGrid, "aria-label": copy.title, role: "region", children: regularPosts.map((post) => (_jsx(PostCard, { post: post, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: 1, totalPages: totalPages, baseUrl: baseUrl, locale: locale })] })) }));
|
|
24
|
+
}, className: `text-muted ${styles.featuredExcerpt}` }), _jsx("time", { dateTime: featuredModel.dateTime, className: `text-muted ${styles.featuredDate}`, children: featuredModel.dateLabel })] })] })), _jsx("section", { className: styles.postsGrid, "aria-label": copy.title, role: "region", children: regularPosts.map((post) => (_jsx(PostCard, { post: post, basePath: linkBasePath, locale: locale, dateLocale: dateLocale }, post.id))) }), _jsx(Paginator, { currentPage: 1, totalPages: totalPages, baseUrl: baseUrl, locale: locale })] })) }));
|
|
25
25
|
}
|
|
@@ -20,4 +20,4 @@ export type FeaturedViewModel = {
|
|
|
20
20
|
alt: string;
|
|
21
21
|
} | undefined;
|
|
22
22
|
};
|
|
23
|
-
export declare const buildFeaturedViewModel: (post: WPPost, locale?: Locale, dateLocale?: string) => FeaturedViewModel;
|
|
23
|
+
export declare const buildFeaturedViewModel: (post: WPPost, locale?: Locale, dateLocale?: string, basePath?: string) => FeaturedViewModel;
|
|
@@ -9,7 +9,7 @@ export const getHomeCopy = (locale) => {
|
|
|
9
9
|
errorHint: t("home.errorHint"),
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export const buildFeaturedViewModel = (post, locale, dateLocale = "en-US") => {
|
|
12
|
+
export const buildFeaturedViewModel = (post, locale, dateLocale = "en-US", basePath) => {
|
|
13
13
|
const t = getTranslator(locale);
|
|
14
14
|
const featuredMedia = getFeaturedMedia(post);
|
|
15
15
|
const imageUrl = featuredMedia?.source_url;
|
|
@@ -19,9 +19,10 @@ export const buildFeaturedViewModel = (post, locale, dateLocale = "en-US") => {
|
|
|
19
19
|
post,
|
|
20
20
|
categorySlug: primaryCategory?.slug,
|
|
21
21
|
locale,
|
|
22
|
+
basePath,
|
|
22
23
|
});
|
|
23
24
|
const badgeUrl = primaryCategory
|
|
24
|
-
? buildCategoryUrl(primaryCategory.slug, locale)
|
|
25
|
+
? buildCategoryUrl(primaryCategory.slug, locale, basePath)
|
|
25
26
|
: null;
|
|
26
27
|
return {
|
|
27
28
|
postUrl,
|
|
@@ -6,6 +6,7 @@ type PostViewProps = {
|
|
|
6
6
|
categoryBasePath?: string;
|
|
7
7
|
locale?: Locale;
|
|
8
8
|
authorDescription?: string | null;
|
|
9
|
+
disclaimer?: string;
|
|
9
10
|
};
|
|
10
|
-
export declare function PostView({ post, dateLocale, categoryBasePath, locale, authorDescription, }: PostViewProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function PostView({ post, dateLocale, categoryBasePath, locale, authorDescription, disclaimer, }: PostViewProps): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -9,7 +9,7 @@ function truncateLabel(label, max = 20) {
|
|
|
9
9
|
const trimmed = label.trim();
|
|
10
10
|
return trimmed.length > max ? `${trimmed.slice(0, max)}...` : trimmed;
|
|
11
11
|
}
|
|
12
|
-
export function PostView({ post, dateLocale = "en-US", categoryBasePath = "/", locale, authorDescription, }) {
|
|
12
|
+
export function PostView({ post, dateLocale = "en-US", categoryBasePath = "/", locale, authorDescription, disclaimer, }) {
|
|
13
13
|
const t = getTranslator(locale);
|
|
14
14
|
const author = getAuthor(post);
|
|
15
15
|
const authorBio = authorDescription ?? author?.description;
|
|
@@ -27,5 +27,5 @@ export function PostView({ post, dateLocale = "en-US", categoryBasePath = "/", l
|
|
|
27
27
|
{ label: "Home", href: categoryBasePath },
|
|
28
28
|
{ label: stripTags(post.title.rendered) || post.title.rendered },
|
|
29
29
|
];
|
|
30
|
-
return (_jsx("div", { className: `container ${styles.container}`, children: _jsxs("article", { className: styles.article, children: [_jsx(Breadcrumbs, { items: breadcrumbs }), _jsx("header", { className: styles.postHeader, children: _jsx("h1", { dangerouslySetInnerHTML: { __html: post.title.rendered }, className: styles.title }) }), featuredImage && (_jsxs("figure", { className: styles.figure, children: [primaryCategory && (_jsx("div", { className: styles.badgeOverlay, children: categoryUrl ? (_jsx("a", { href: categoryUrl, className: "badge", title: primaryCategory.name, children: truncateLabel(primaryCategory.name, 20) })) : (_jsx("span", { className: "badge", title: primaryCategory.name, children: truncateLabel(primaryCategory.name, 20) })) })), _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" })] })), _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 })] }), _jsx("div", { dangerouslySetInnerHTML: { __html: post.content.rendered }, className: `post-content ${styles.content}` }), author && (_jsx("aside", { className: `card ${styles.authorCard}`, children: _jsxs("address", { className: styles.authorAddress, children: [_jsx("strong", { className: styles.authorName, children: author.name }), authorBio && (_jsx("p", { className: styles.authorBio, children: authorBio }))] }) }))] }) }));
|
|
30
|
+
return (_jsx("div", { className: `container ${styles.container}`, children: _jsxs("article", { className: styles.article, children: [_jsx(Breadcrumbs, { items: breadcrumbs }), _jsx("header", { className: styles.postHeader, children: _jsx("h1", { dangerouslySetInnerHTML: { __html: post.title.rendered }, className: styles.title }) }), featuredImage && (_jsxs("figure", { className: styles.figure, children: [primaryCategory && (_jsx("div", { className: styles.badgeOverlay, children: categoryUrl ? (_jsx("a", { href: categoryUrl, className: "badge", title: primaryCategory.name, children: truncateLabel(primaryCategory.name, 20) })) : (_jsx("span", { className: "badge", title: primaryCategory.name, children: truncateLabel(primaryCategory.name, 20) })) })), _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" })] })), _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 })] }), _jsx("div", { dangerouslySetInnerHTML: { __html: post.content.rendered }, className: `post-content ${styles.content}` }), disclaimer && (_jsx("div", { className: styles.disclaimer, role: "note", children: disclaimer })), author && (_jsx("aside", { className: `card ${styles.authorCard}`, children: _jsxs("address", { className: styles.authorAddress, children: [_jsx("strong", { className: styles.authorName, children: author.name }), authorBio && (_jsx("p", { className: styles.authorBio, children: authorBio }))] }) }))] }) }));
|
|
31
31
|
}
|
|
@@ -62,6 +62,18 @@
|
|
|
62
62
|
color: var(--foreground);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
.disclaimer {
|
|
66
|
+
margin-top: var(--spacing-md);
|
|
67
|
+
padding: 0.9rem 1.1rem;
|
|
68
|
+
border-radius: 10px;
|
|
69
|
+
border: 1px dashed var(--border);
|
|
70
|
+
background: #f1f5f9;
|
|
71
|
+
color: var(--foreground-light);
|
|
72
|
+
font-size: 0.95rem;
|
|
73
|
+
line-height: 1.6;
|
|
74
|
+
font-style: italic;
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
.authorCard {
|
|
66
78
|
margin-top: var(--spacing-lg);
|
|
67
79
|
margin-left: auto;
|