wpheadless-lib 1.1.11 → 1.1.12

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.
@@ -8,9 +8,8 @@
8
8
  --spacing-xl: 3rem;
9
9
 
10
10
  /* Typography */
11
- --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto",
12
- "Helvetica Neue", Arial, sans-serif;
13
- --font-display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
11
+ --font-sans: Arial, sans-serif;
12
+ --font-display: Arial, sans-serif;
14
13
 
15
14
  /* Transitions */
16
15
  --transition: color 0.2s ease, background-color 0.2s ease,
@@ -20,5 +20,5 @@ type RootLayoutBaseProps = {
20
20
  headerLogo?: LogoProps;
21
21
  footerLogo?: LogoProps;
22
22
  };
23
- export declare function RootLayoutBase({ children, menuHeaderId, menuFooterId, siteName, wpApiUrl, wpUsername, wpAppPassword, homeHref, locale, headerLogo, footerLogo, }: RootLayoutBaseProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function RootLayoutBase({ children, menuHeaderId, menuFooterId, siteName, wpApiUrl, wpUsername, wpAppPassword, homeHref, locale, headerLogo, footerLogo, }: RootLayoutBaseProps): import("react").JSX.Element;
24
24
  export {};
@@ -5,5 +5,5 @@ export type BreadcrumbItem = {
5
5
  type BreadcrumbsProps = {
6
6
  items: BreadcrumbItem[];
7
7
  };
8
- export declare function Breadcrumbs({ items }: BreadcrumbsProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Breadcrumbs({ items }: BreadcrumbsProps): import("react").JSX.Element;
9
9
  export {};
@@ -1,5 +1,5 @@
1
1
  type JsonLdProps = {
2
2
  data?: unknown;
3
3
  };
4
- export declare function JsonLd({ data }: JsonLdProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function JsonLd({ data }: JsonLdProps): import("react").JSX.Element;
5
5
  export {};
@@ -6,5 +6,5 @@ interface PaginatorProps {
6
6
  maxVisiblePages?: number;
7
7
  locale?: Locale;
8
8
  }
9
- export default function Paginator({ currentPage, totalPages, baseUrl, maxVisiblePages, locale, }: PaginatorProps): import("react/jsx-runtime").JSX.Element;
9
+ export default function Paginator({ currentPage, totalPages, baseUrl, maxVisiblePages, locale, }: PaginatorProps): import("react").JSX.Element;
10
10
  export {};
@@ -8,5 +8,5 @@ interface PostCardProps {
8
8
  dateLocale?: string;
9
9
  basePath?: string;
10
10
  }
11
- export default function PostCard({ post, categorySlug, locale, defaultLocale, dateLocale, basePath, }: PostCardProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function PostCard({ post, categorySlug, locale, defaultLocale, dateLocale, basePath, }: PostCardProps): import("react").JSX.Element;
12
12
  export {};
@@ -10,5 +10,5 @@ type FooterProps = {
10
10
  locale?: string;
11
11
  logo?: LogoProps;
12
12
  };
13
- export default function Footer({ menuId, wpApiUrl, wpUsername, wpAppPassword, siteName, locale, logo, }: FooterProps): Promise<import("react/jsx-runtime").JSX.Element>;
13
+ export default function Footer({ menuId, wpApiUrl, wpUsername, wpAppPassword, siteName, locale, logo, }: FooterProps): Promise<import("react").JSX.Element>;
14
14
  export {};
@@ -17,5 +17,5 @@ type HeaderClientProps = {
17
17
  labels: HeaderLabels;
18
18
  logo?: LogoProps;
19
19
  };
20
- export default function HeaderClient({ menuLinks, siteName, homeHref, labels, logo, }: HeaderClientProps): import("react/jsx-runtime").JSX.Element;
20
+ export default function HeaderClient({ menuLinks, siteName, homeHref, labels, logo, }: HeaderClientProps): import("react").JSX.Element;
21
21
  export {};
@@ -11,5 +11,5 @@ type HeaderProps = {
11
11
  locale?: string;
12
12
  logo?: LogoProps;
13
13
  };
14
- export default function Header({ menuId, wpApiUrl, wpUsername, wpAppPassword, siteName, homeHref, locale, logo, }: HeaderProps): Promise<import("react/jsx-runtime").JSX.Element>;
14
+ export default function Header({ menuId, wpApiUrl, wpUsername, wpAppPassword, siteName, homeHref, locale, logo, }: HeaderProps): Promise<import("react").JSX.Element>;
15
15
  export {};
@@ -2,7 +2,7 @@ import type { ComponentPropsWithoutRef } from "react";
2
2
  type AlertProps = ComponentPropsWithoutRef<"div"> & {
3
3
  variant?: "default" | "destructive";
4
4
  };
5
- export declare function Alert({ className, variant, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element;
6
- export declare function AlertTitle({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
7
- export declare function AlertDescription({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
5
+ export declare function Alert({ className, variant, ...props }: AlertProps): import("react").JSX.Element;
6
+ export declare function AlertTitle({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react").JSX.Element;
7
+ export declare function AlertDescription({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react").JSX.Element;
8
8
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { ComponentPropsWithoutRef } from "react";
2
2
  export declare function badgeClassName(className?: string): string;
3
- export declare function Badge({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Badge({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import Link from "next/link";
2
2
  import type { ComponentPropsWithoutRef } from "react";
3
- export declare function Breadcrumb({ className, ...props }: ComponentPropsWithoutRef<"nav">): import("react/jsx-runtime").JSX.Element;
4
- export declare function BreadcrumbList({ className, ...props }: ComponentPropsWithoutRef<"ol">): import("react/jsx-runtime").JSX.Element;
5
- export declare function BreadcrumbItem({ className, ...props }: ComponentPropsWithoutRef<"li">): import("react/jsx-runtime").JSX.Element;
6
- export declare function BreadcrumbLink({ className, ...props }: ComponentPropsWithoutRef<typeof Link>): import("react/jsx-runtime").JSX.Element;
7
- export declare function BreadcrumbPage({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react/jsx-runtime").JSX.Element;
8
- export declare function BreadcrumbSeparator({ className, children, ...props }: ComponentPropsWithoutRef<"span">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Breadcrumb({ className, ...props }: ComponentPropsWithoutRef<"nav">): import("react").JSX.Element;
4
+ export declare function BreadcrumbList({ className, ...props }: ComponentPropsWithoutRef<"ol">): import("react").JSX.Element;
5
+ export declare function BreadcrumbItem({ className, ...props }: ComponentPropsWithoutRef<"li">): import("react").JSX.Element;
6
+ export declare function BreadcrumbLink({ className, ...props }: ComponentPropsWithoutRef<typeof Link>): import("react").JSX.Element;
7
+ export declare function BreadcrumbPage({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react").JSX.Element;
8
+ export declare function BreadcrumbSeparator({ className, children, ...props }: ComponentPropsWithoutRef<"span">): import("react").JSX.Element;
@@ -3,5 +3,5 @@ type ButtonProps = ComponentPropsWithRef<"button"> & {
3
3
  variant?: "default" | "outline" | "ghost";
4
4
  size?: "default" | "sm" | "icon";
5
5
  };
6
- export declare function Button({ className, variant, size, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function Button({ className, variant, size, ...props }: ButtonProps): import("react").JSX.Element;
7
7
  export {};
@@ -4,8 +4,8 @@ type CardProps<T extends ElementType> = {
4
4
  size?: "default" | "sm";
5
5
  className?: string;
6
6
  } & Omit<ComponentPropsWithoutRef<T>, "as" | "className">;
7
- export declare function Card<T extends ElementType = "div">({ as, size, className, ...props }: CardProps<T>): import("react/jsx-runtime").JSX.Element;
8
- export declare function CardHeader({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
9
- export declare function CardContent({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
10
- export declare function CardFooter({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Card<T extends ElementType = "div">({ as, size, className, ...props }: CardProps<T>): import("react").JSX.Element;
8
+ export declare function CardHeader({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react").JSX.Element;
9
+ export declare function CardContent({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react").JSX.Element;
10
+ export declare function CardFooter({ className, ...props }: ComponentPropsWithoutRef<"div">): import("react").JSX.Element;
11
11
  export {};
@@ -1,14 +1,14 @@
1
1
  import Link from "next/link";
2
2
  import type { ComponentPropsWithoutRef } from "react";
3
- export declare function Pagination({ className, ...props }: ComponentPropsWithoutRef<"nav">): import("react/jsx-runtime").JSX.Element;
4
- export declare function PaginationContent({ className, ...props }: ComponentPropsWithoutRef<"ul">): import("react/jsx-runtime").JSX.Element;
5
- export declare function PaginationItem(props: ComponentPropsWithoutRef<"li">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Pagination({ className, ...props }: ComponentPropsWithoutRef<"nav">): import("react").JSX.Element;
4
+ export declare function PaginationContent({ className, ...props }: ComponentPropsWithoutRef<"ul">): import("react").JSX.Element;
5
+ export declare function PaginationItem(props: ComponentPropsWithoutRef<"li">): import("react").JSX.Element;
6
6
  type PaginationLinkProps = ComponentPropsWithoutRef<typeof Link> & {
7
7
  isActive?: boolean;
8
8
  size?: "default" | "icon";
9
9
  };
10
- export declare function PaginationLink({ className, isActive, size, ...props }: PaginationLinkProps): import("react/jsx-runtime").JSX.Element;
11
- export declare function PaginationPrevious({ children, className, ...props }: Omit<PaginationLinkProps, "size">): import("react/jsx-runtime").JSX.Element;
12
- export declare function PaginationNext({ children, className, ...props }: Omit<PaginationLinkProps, "size">): import("react/jsx-runtime").JSX.Element;
13
- export declare function PaginationEllipsis({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react/jsx-runtime").JSX.Element;
10
+ export declare function PaginationLink({ className, isActive, size, ...props }: PaginationLinkProps): import("react").JSX.Element;
11
+ export declare function PaginationPrevious({ children, className, ...props }: Omit<PaginationLinkProps, "size">): import("react").JSX.Element;
12
+ export declare function PaginationNext({ children, className, ...props }: Omit<PaginationLinkProps, "size">): import("react").JSX.Element;
13
+ export declare function PaginationEllipsis({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react").JSX.Element;
14
14
  export {};
@@ -1,5 +1,6 @@
1
1
  import { type SiteLanguage, type SiteLanguageInput } from "./language.js";
2
2
  export type LanguageConfig = SiteLanguageInput;
3
+ export declare function getHreflangCode(language: Pick<SiteLanguageInput, "code">): string;
3
4
  export declare function getTranslationKey(entity: unknown): string | undefined;
4
5
  export declare function getEntityLanguageId(entity: unknown): string | undefined;
5
6
  type BuildUrlParams<T> = {
@@ -1,6 +1,12 @@
1
1
  import { getAbsoluteUrl } from "./routing.js";
2
2
  import { normalizeLanguages, shouldRenderLanguageAlternates, } from "./language.js";
3
3
  const normalizeBasePath = (basePath) => basePath.endsWith("/") ? basePath : `${basePath}/`;
4
+ export function getHreflangCode(language) {
5
+ const [languageCode, regionCode] = language.code.split("-");
6
+ if (!regionCode)
7
+ return languageCode.toLowerCase();
8
+ return `${languageCode.toLowerCase()}-${regionCode.toUpperCase()}`;
9
+ }
4
10
  export function getTranslationKey(entity) {
5
11
  const meta = entity?.meta;
6
12
  const value = meta?.translation_key_v2;
@@ -33,7 +39,7 @@ export async function buildLanguageAlternatesFromTranslations({ translations, la
33
39
  const url = buildUrl({ entity: match, langCfg });
34
40
  if (!url)
35
41
  continue;
36
- alternates[langCfg.code] = url;
42
+ alternates[getHreflangCode(langCfg)] = url;
37
43
  }
38
44
  return Object.keys(alternates).length > 1 ? alternates : undefined;
39
45
  }
@@ -68,7 +74,7 @@ export async function buildLanguageAlternatesPerLanguage({ languages, fetcher, b
68
74
  const url = buildUrl({ entity, langCfg });
69
75
  if (!url)
70
76
  continue;
71
- alternates[langCfg.code] = url;
77
+ alternates[getHreflangCode(langCfg)] = url;
72
78
  }
73
79
  catch (error) {
74
80
  console.error("Error building hreflang for lang", langCfg.code, error);
@@ -1,21 +1,42 @@
1
1
  import { createPageEndpoints, createPostsEndpoints } from "wpjsapi-lib";
2
2
  import { createWpClient, isValidWpApiUrl } from "../api/wpClient.js";
3
3
  import { listPostsWithEmbeds } from "../api/posts.js";
4
- import { getCategoryPaginationStaticParams } from "../base/index.js";
5
- import { getHomePaginationStaticParams } from "../base/home/pagination.js";
4
+ import { getCategoryPaginationStaticParams, getCategoryTotalPages, } from "../base/index.js";
5
+ import { getHomePaginationStaticParams, getHomeTotalPages, } from "../base/home/pagination.js";
6
6
  import { getAbsoluteUrl, ensureTrailingSlash } from "./routing.js";
7
7
  import { isYoastNoindex } from "./seo.js";
8
- import { getTranslationKey, getEntityLanguageId, withXDefault, } from "./hreflang.js";
8
+ import { getHreflangCode, getTranslationKey, getEntityLanguageId, withXDefault, } from "./hreflang.js";
9
9
  import { normalizeLanguages, shouldRenderLanguageAlternates, } from "./language.js";
10
10
  const resolveWpApiUrl = (cfg) => cfg.wpApiUrl ?? process.env.WP_API_URL ?? "";
11
11
  const resolveSiteUrl = (cfg) => cfg.siteUrl ?? process.env.NEXT_PUBLIC_SITE_URL;
12
12
  const buildHomeAlternates = (cfg) => shouldRenderLanguageAlternates(cfg.languages)
13
13
  ? withXDefault(normalizeLanguages(cfg.languages).reduce((acc, langCfg) => {
14
14
  const basePath = ensureTrailingSlash(langCfg.basePath || "/");
15
- acc[langCfg.code] = getAbsoluteUrl(basePath, resolveSiteUrl(cfg));
15
+ acc[getHreflangCode(langCfg)] = getAbsoluteUrl(basePath, resolveSiteUrl(cfg));
16
16
  return acc;
17
17
  }, {}))
18
18
  : undefined;
19
+ async function buildHomePaginationAlternates(cfg, currentPage) {
20
+ if (!shouldRenderLanguageAlternates(cfg.languages))
21
+ return undefined;
22
+ const wpApiUrl = resolveWpApiUrl(cfg);
23
+ if (!isValidWpApiUrl(wpApiUrl))
24
+ return undefined;
25
+ const siteUrl = resolveSiteUrl(cfg);
26
+ const alternates = {};
27
+ for (const langCfg of normalizeLanguages(cfg.languages)) {
28
+ const totalPages = await getHomeTotalPages({
29
+ baseApiUrl: wpApiUrl,
30
+ perPage: cfg.runtimeConfig.postsPerPagePagination,
31
+ langId: langCfg.langId,
32
+ });
33
+ if (totalPages < currentPage)
34
+ continue;
35
+ const basePath = ensureTrailingSlash(langCfg.basePath || "/");
36
+ alternates[getHreflangCode(langCfg)] = getAbsoluteUrl(`${basePath}page/${currentPage}/`, siteUrl);
37
+ }
38
+ return withXDefault(alternates);
39
+ }
19
40
  const escapeXml = (value) => value
20
41
  .replace(/&/g, "&amp;")
21
42
  .replace(/</g, "&lt;")
@@ -130,6 +151,7 @@ export async function getHomePaginationEntries(cfg) {
130
151
  return {
131
152
  url,
132
153
  lastmod: lastmod ? new Date(lastmod).toISOString() : undefined,
154
+ alternates: await buildHomePaginationAlternates(cfg, Number(p.page)),
133
155
  };
134
156
  });
135
157
  entries.push(...pageEntries);
@@ -144,6 +166,7 @@ export async function getCategoryEntries(cfg) {
144
166
  const siteUrl = resolveSiteUrl(cfg);
145
167
  if (!isValidWpApiUrl(wpApiUrl))
146
168
  return entries;
169
+ const renderAlternatesForLanguages = shouldRenderLanguageAlternates(cfg.languages);
147
170
  const categoriesPerLang = {};
148
171
  const categoryAlternates = {};
149
172
  for (const langCfg of languages) {
@@ -156,6 +179,8 @@ export async function getCategoryEntries(cfg) {
156
179
  categoriesPerLang[langCfg.code] = indexableCategories;
157
180
  const basePath = ensureTrailingSlash(langCfg.basePath || "/");
158
181
  for (const cat of indexableCategories) {
182
+ if (!renderAlternatesForLanguages)
183
+ continue;
159
184
  const translationKey = getTranslationKey(cat);
160
185
  if (!translationKey)
161
186
  continue;
@@ -163,7 +188,7 @@ export async function getCategoryEntries(cfg) {
163
188
  if (!categoryAlternates[translationKey]) {
164
189
  categoryAlternates[translationKey] = {};
165
190
  }
166
- categoryAlternates[translationKey][langCfg.code] = url;
191
+ categoryAlternates[translationKey][getHreflangCode(langCfg)] = url;
167
192
  }
168
193
  }
169
194
  for (const langCfg of languages) {
@@ -184,6 +209,8 @@ export async function getCategoryEntries(cfg) {
184
209
  const lastmod = latest?.modified ||
185
210
  latest?.date;
186
211
  const alt = (() => {
212
+ if (!renderAlternatesForLanguages)
213
+ return undefined;
187
214
  const key = getTranslationKey(cat);
188
215
  if (!key)
189
216
  return undefined;
@@ -208,15 +235,43 @@ export async function getCategoryPaginationEntries(cfg) {
208
235
  const siteUrl = resolveSiteUrl(cfg);
209
236
  if (!isValidWpApiUrl(wpApiUrl))
210
237
  return entries;
238
+ const renderAlternatesForLanguages = shouldRenderLanguageAlternates(cfg.languages);
211
239
  const catIdsBySlugByLang = {};
240
+ const catsBySlugByLang = {};
241
+ const alternatesByTranslationPage = {};
212
242
  for (const langCfg of languages) {
213
243
  const { categoriesApi } = createWpClient({ baseUrl: wpApiUrl });
214
244
  const categories = await categoriesApi.listAll({
215
245
  ...getWpLangParam(langCfg),
216
- _fields: ["id", "slug", "yoast_head_json"],
246
+ _fields: ["id", "slug", "meta", "yoast_head_json"],
217
247
  });
218
248
  const indexableCategories = categories.filter((cat) => !isNoindexEntity(cat));
219
249
  catIdsBySlugByLang[langCfg.code] = Object.fromEntries(indexableCategories.map((c) => [c.slug, c.id]));
250
+ catsBySlugByLang[langCfg.code] = Object.fromEntries(indexableCategories.map((c) => [c.slug, c]));
251
+ const basePath = ensureTrailingSlash(langCfg.basePath || "/");
252
+ for (const category of indexableCategories) {
253
+ if (!renderAlternatesForLanguages)
254
+ continue;
255
+ const translationKey = getTranslationKey(category);
256
+ if (!translationKey)
257
+ continue;
258
+ const totalPages = await getCategoryTotalPages({
259
+ baseApiUrl: wpApiUrl,
260
+ categoryId: category.id,
261
+ perPage: runtimeConfig.postsPerPagePagination,
262
+ langId: langCfg.langId,
263
+ });
264
+ for (let page = 2; page <= totalPages; page++) {
265
+ const pageKey = String(page);
266
+ if (!alternatesByTranslationPage[translationKey]) {
267
+ alternatesByTranslationPage[translationKey] = {};
268
+ }
269
+ if (!alternatesByTranslationPage[translationKey][pageKey]) {
270
+ alternatesByTranslationPage[translationKey][pageKey] = {};
271
+ }
272
+ alternatesByTranslationPage[translationKey][pageKey][getHreflangCode(langCfg)] = getAbsoluteUrl(`${basePath}${category.slug}/page/${page}/`, siteUrl);
273
+ }
274
+ }
220
275
  }
221
276
  for (const langCfg of languages) {
222
277
  const catPages = await getCategoryPaginationStaticParams({
@@ -231,6 +286,7 @@ export async function getCategoryPaginationEntries(cfg) {
231
286
  const catId = catIdsBySlugByLang[langCfg.code]?.[page.category];
232
287
  if (!catId)
233
288
  return null;
289
+ const category = catsBySlugByLang[langCfg.code]?.[page.category];
234
290
  let lastmod;
235
291
  const pagePosts = await listPostsWithEmbeds({
236
292
  baseApiUrl: wpApiUrl,
@@ -248,6 +304,9 @@ export async function getCategoryPaginationEntries(cfg) {
248
304
  return {
249
305
  url,
250
306
  lastmod: lastmod ? new Date(lastmod).toISOString() : undefined,
307
+ alternates: renderAlternatesForLanguages && category
308
+ ? withXDefault(alternatesByTranslationPage[getTranslationKey(category) || ""]?.[page.page])
309
+ : undefined,
251
310
  };
252
311
  });
253
312
  entries.push(...pageEntries.filter(Boolean));
@@ -264,6 +323,7 @@ export async function getPostEntriesForLang(langCode, cfg) {
264
323
  return [];
265
324
  const siteUrl = resolveSiteUrl(cfg);
266
325
  const postsApi = createPostsEndpoints({ baseUrl: wpApiUrl });
326
+ const renderAlternatesForLanguages = shouldRenderLanguageAlternates(cfg.languages);
267
327
  const languageFilter = langCfg.langId
268
328
  ? { taxonomies: { language: [langCfg.langId] } }
269
329
  : {};
@@ -290,6 +350,8 @@ export async function getPostEntriesForLang(langCode, cfg) {
290
350
  });
291
351
  for (const { language: l, base, posts: filteredLangPosts } of postsByLanguage) {
292
352
  for (const p of filteredLangPosts) {
353
+ if (!renderAlternatesForLanguages)
354
+ continue;
293
355
  const translationKey = getTranslationKey(p);
294
356
  if (!translationKey)
295
357
  continue;
@@ -300,7 +362,7 @@ export async function getPostEntriesForLang(langCode, cfg) {
300
362
  const url = getAbsoluteUrl(`${base}${categorySlug}/${p.slug}/`, siteUrl);
301
363
  if (!postAlternates[translationKey])
302
364
  postAlternates[translationKey] = {};
303
- postAlternates[translationKey][l.code] = url;
365
+ postAlternates[translationKey][getHreflangCode(l)] = url;
304
366
  }
305
367
  }
306
368
  const basePath = ensureTrailingSlash(langCfg.basePath || "/");
@@ -314,7 +376,7 @@ export async function getPostEntriesForLang(langCode, cfg) {
314
376
  const lastmod = p.modified ||
315
377
  p.date;
316
378
  const translationKey = getTranslationKey(p);
317
- const alts = translationKey
379
+ const alts = renderAlternatesForLanguages && translationKey
318
380
  ? withXDefault(postAlternates[translationKey])
319
381
  : undefined;
320
382
  return {
@@ -332,6 +394,7 @@ export async function getLegalEntries(cfg) {
332
394
  const wpApiUrl = resolveWpApiUrl(cfg);
333
395
  if (!isValidWpApiUrl(wpApiUrl))
334
396
  return entries;
397
+ const renderAlternatesForLanguages = shouldRenderLanguageAlternates(cfg.languages);
335
398
  const pagesApi = createPageEndpoints({ baseUrl: wpApiUrl });
336
399
  const pagesPerLang = {};
337
400
  const alternatesByKey = {};
@@ -357,18 +420,22 @@ export async function getLegalEntries(cfg) {
357
420
  "yoast_head_json",
358
421
  ],
359
422
  });
360
- const filtered = pages.filter((p) => getEntityLanguageId(p)?.toString() === langCfg.langId?.toString());
423
+ const filtered = langCfg.langId
424
+ ? pages.filter((p) => getEntityLanguageId(p)?.toString() === langCfg.langId?.toString())
425
+ : pages;
361
426
  const indexablePages = filtered.filter((page) => !isNoindexEntity(page));
362
427
  pagesPerLang[langCfg.code] = indexablePages;
363
428
  const basePath = ensureTrailingSlash(langCfg.basePath || "/");
364
429
  for (const p of indexablePages) {
430
+ if (!renderAlternatesForLanguages)
431
+ continue;
365
432
  const translationKey = getTranslationKey(p);
366
433
  if (!translationKey)
367
434
  continue;
368
435
  const url = getAbsoluteUrl(`${basePath}legal/${p.slug}/`, siteUrl);
369
436
  if (!alternatesByKey[translationKey])
370
437
  alternatesByKey[translationKey] = {};
371
- alternatesByKey[translationKey][langCfg.code] = url;
438
+ alternatesByKey[translationKey][getHreflangCode(langCfg)] = url;
372
439
  }
373
440
  }
374
441
  for (const langCfg of languages) {
@@ -378,7 +445,7 @@ export async function getLegalEntries(cfg) {
378
445
  const url = getAbsoluteUrl(`${basePath}legal/${p.slug}/`, siteUrl);
379
446
  const lastmod = p.modified || p.date;
380
447
  const translationKey = getTranslationKey(p);
381
- const alts = translationKey
448
+ const alts = renderAlternatesForLanguages && translationKey
382
449
  ? withXDefault(alternatesByKey[translationKey])
383
450
  : undefined;
384
451
  entries.push({
@@ -10,5 +10,5 @@ type CategoryListViewProps = {
10
10
  locale?: Locale;
11
11
  dateLocale?: string;
12
12
  };
13
- export declare function CategoryListView({ category, posts, totalPages, baseUrl, homeHref, linkBasePath, 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.Element;
14
14
  export {};
@@ -10,5 +10,5 @@ type CategoryPaginationViewProps = {
10
10
  locale?: Locale;
11
11
  dateLocale?: string;
12
12
  };
13
- export declare function CategoryPaginationView({ category, posts, currentPage, totalPages, baseUrl, linkBasePath, 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.Element;
14
14
  export {};
@@ -10,5 +10,5 @@ type HomePaginationViewProps = {
10
10
  locale?: Locale;
11
11
  dateLocale?: string;
12
12
  };
13
- export declare function HomePaginationView({ posts, currentPage, totalPages, error, baseUrl, linkBasePath, 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.Element;
14
14
  export {};
@@ -10,5 +10,5 @@ type HomeViewProps = {
10
10
  locale?: Locale;
11
11
  dateLocale?: string;
12
12
  };
13
- export declare function HomeView({ featuredPost, regularPosts, error, totalPages, baseUrl, linkBasePath, 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.Element;
14
14
  export {};
@@ -5,5 +5,5 @@ type LegalPageViewProps = {
5
5
  homeHref: string;
6
6
  priorityImage?: boolean;
7
7
  };
8
- export declare function LegalPageView({ page, homeHref, priorityImage, }: LegalPageViewProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function LegalPageView({ page, homeHref, priorityImage, }: LegalPageViewProps): import("react").JSX.Element;
9
9
  export {};
@@ -9,5 +9,5 @@ type PostViewProps = {
9
9
  disclaimer?: string;
10
10
  priorityImage?: boolean;
11
11
  };
12
- export declare function PostView({ post, dateLocale, categoryBasePath, locale, authorDescription, disclaimer, priorityImage, }: PostViewProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function PostView({ post, dateLocale, categoryBasePath, locale, authorDescription, disclaimer, priorityImage, }: PostViewProps): import("react").JSX.Element;
13
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wpheadless-lib",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",