wpheadless-lib 1.1.10 → 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.
- package/dist/api/categories.d.ts +1 -1
- package/dist/api/categories.js +18 -2
- package/dist/api/index.d.ts +7 -6
- package/dist/api/index.js +7 -6
- package/dist/api/mappers.d.ts +1 -1
- package/dist/api/mappers.js +1 -1
- package/dist/api/menus.d.ts +18 -0
- package/dist/api/menus.js +39 -0
- package/dist/api/posts.js +30 -2
- package/dist/api/translations.js +7 -1
- package/dist/api/wpClient.d.ts +5 -8
- package/dist/api/wpClient.js +14 -0
- package/dist/app/config.d.ts +2 -1
- package/dist/app/config.js +4 -0
- package/dist/app/globals.css +35 -124
- package/dist/base/category/index.d.ts +3 -3
- package/dist/base/category/index.js +9 -8
- package/dist/base/category/pagination.d.ts +2 -2
- package/dist/base/category/pagination.js +12 -10
- package/dist/base/home/index.js +1 -1
- package/dist/base/home/pagination.js +3 -3
- package/dist/base/index.d.ts +7 -7
- package/dist/base/index.js +7 -7
- package/dist/base/layout/RootLayoutBase.d.ts +7 -8
- package/dist/base/layout/RootLayoutBase.js +4 -4
- package/dist/base/layout/RootLayoutBase.module.css +10 -0
- package/dist/base/legal/index.d.ts +4 -4
- package/dist/base/legal/index.js +36 -24
- package/dist/base/post/index.d.ts +1 -1
- package/dist/base/post/index.js +15 -12
- package/dist/components/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/Breadcrumbs/index.js +4 -4
- package/dist/components/JsonLd.d.ts +5 -0
- package/dist/components/JsonLd.js +9 -0
- package/dist/components/Paginator/index.d.ts +2 -2
- package/dist/components/Paginator/index.js +5 -5
- package/dist/components/PostCard/index.d.ts +3 -2
- package/dist/components/PostCard/index.js +8 -6
- package/dist/components/PostCard/index.module.css +7 -7
- package/dist/components/PostCard/index.types.d.ts +2 -1
- package/dist/components/PostCard/index.utils.d.ts +5 -5
- package/dist/components/PostCard/index.utils.js +8 -6
- package/dist/components/index.d.ts +6 -5
- package/dist/components/index.js +6 -5
- package/dist/components/layout/Footer/index.d.ts +6 -6
- package/dist/components/layout/Footer/index.js +11 -22
- package/dist/components/layout/Footer/index.module.css +59 -9
- package/dist/components/layout/Header/HeaderClient.d.ts +2 -2
- package/dist/components/layout/Header/HeaderClient.js +22 -2
- package/dist/components/layout/Header/index.d.ts +6 -6
- package/dist/components/layout/Header/index.js +10 -29
- package/dist/components/layout/Header/index.module.css +77 -16
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/alert.js +12 -0
- package/dist/components/ui/alert.module.css +26 -0
- package/dist/components/ui/badge.d.ts +3 -0
- package/dist/components/ui/badge.js +9 -0
- package/dist/components/ui/badge.module.css +23 -0
- package/dist/components/ui/breadcrumb.d.ts +8 -0
- package/dist/components/ui/breadcrumb.js +22 -0
- package/dist/components/ui/breadcrumb.module.css +37 -0
- package/dist/components/ui/button.d.ts +7 -0
- package/dist/components/ui/button.js +16 -0
- package/dist/components/ui/button.module.css +72 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +16 -0
- package/dist/components/ui/card.module.css +37 -0
- package/dist/components/ui/cn.d.ts +1 -0
- package/dist/components/ui/cn.js +3 -0
- package/dist/components/ui/index.d.ts +6 -0
- package/dist/components/ui/index.js +6 -0
- package/dist/components/ui/pagination.d.ts +14 -0
- package/dist/components/ui/pagination.js +25 -0
- package/dist/components/ui/pagination.module.css +62 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/yoast/index.js +10 -7
- package/dist/utils/hreflang.d.ts +5 -7
- package/dist/utils/hreflang.js +19 -8
- package/dist/utils/html.d.ts +2 -0
- package/dist/utils/html.js +25 -0
- package/dist/utils/index.d.ts +7 -6
- package/dist/utils/index.js +7 -6
- package/dist/utils/language.d.ts +37 -0
- package/dist/utils/language.js +75 -0
- package/dist/utils/seo.d.ts +1 -6
- package/dist/utils/seo.js +9 -5
- package/dist/utils/sitemap.d.ts +1 -1
- package/dist/utils/sitemap.js +181 -63
- package/dist/views/CategoryListView/index.d.ts +2 -2
- package/dist/views/CategoryListView/index.js +6 -6
- package/dist/views/CategoryListView/index.utils.d.ts +1 -1
- package/dist/views/CategoryListView/index.utils.js +1 -1
- package/dist/views/CategoryPaginationView/index.d.ts +2 -2
- package/dist/views/CategoryPaginationView/index.js +6 -6
- package/dist/views/CategoryPaginationView/index.utils.d.ts +1 -1
- package/dist/views/CategoryPaginationView/index.utils.js +1 -1
- package/dist/views/HomePaginationView/index.d.ts +2 -2
- package/dist/views/HomePaginationView/index.js +5 -4
- package/dist/views/HomePaginationView/index.utils.d.ts +1 -1
- package/dist/views/HomePaginationView/index.utils.js +1 -1
- package/dist/views/HomeView/index.d.ts +2 -2
- package/dist/views/HomeView/index.js +13 -12
- package/dist/views/HomeView/index.module.css +51 -8
- package/dist/views/HomeView/index.utils.d.ts +1 -1
- package/dist/views/HomeView/index.utils.js +2 -2
- package/dist/views/LegalPageView/index.d.ts +2 -1
- package/dist/views/LegalPageView/index.js +5 -5
- package/dist/views/LegalPageView/index.module.css +3 -3
- package/dist/views/LegalPageView/index.utils.js +1 -1
- package/dist/views/PostView/index.d.ts +3 -2
- package/dist/views/PostView/index.js +9 -7
- package/dist/views/PostView/index.module.css +46 -13
- package/dist/views/PostView/index.utils.d.ts +3 -3
- package/dist/views/PostView/index.utils.js +2 -2
- package/dist/views/index.d.ts +6 -6
- package/dist/views/index.js +6 -6
- package/package.json +47 -10
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.list {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 0.375rem;
|
|
6
|
+
color: var(--foreground-light);
|
|
7
|
+
font-size: 0.875rem;
|
|
8
|
+
list-style: none;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.item {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 0.375rem;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.link {
|
|
21
|
+
color: var(--foreground-light);
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
transition: color 0.2s ease;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.link:hover {
|
|
27
|
+
color: var(--foreground);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.page {
|
|
31
|
+
color: var(--foreground);
|
|
32
|
+
font-weight: 400;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.separator {
|
|
36
|
+
color: var(--foreground-light);
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
type ButtonProps = ComponentPropsWithRef<"button"> & {
|
|
3
|
+
variant?: "default" | "outline" | "ghost";
|
|
4
|
+
size?: "default" | "sm" | "icon";
|
|
5
|
+
};
|
|
6
|
+
export declare function Button({ className, variant, size, ...props }: ButtonProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "./cn.js";
|
|
3
|
+
import styles from "./button.module.css";
|
|
4
|
+
const variants = {
|
|
5
|
+
default: styles.default,
|
|
6
|
+
outline: styles.outline,
|
|
7
|
+
ghost: styles.ghost,
|
|
8
|
+
};
|
|
9
|
+
const sizes = {
|
|
10
|
+
default: styles.defaultSize,
|
|
11
|
+
sm: styles.small,
|
|
12
|
+
icon: styles.icon,
|
|
13
|
+
};
|
|
14
|
+
export function Button({ className, variant = "default", size = "default", ...props }) {
|
|
15
|
+
return (_jsx("button", { "data-slot": "button", className: cn(styles.button, variants[variant], sizes[size], className), ...props }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
gap: 0.5rem;
|
|
7
|
+
border: 0;
|
|
8
|
+
border-radius: 0.5rem;
|
|
9
|
+
font-size: 0.875rem;
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
line-height: 1;
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
transition:
|
|
15
|
+
color 0.2s ease,
|
|
16
|
+
background-color 0.2s ease,
|
|
17
|
+
border-color 0.2s ease,
|
|
18
|
+
box-shadow 0.2s ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button:disabled {
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
opacity: 0.5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.default {
|
|
27
|
+
background: var(--primary);
|
|
28
|
+
color: var(--primary-foreground);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.default:hover {
|
|
32
|
+
background: var(--primary-hover);
|
|
33
|
+
color: var(--primary-foreground);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.outline {
|
|
37
|
+
border: 1px solid var(--border);
|
|
38
|
+
background: var(--background);
|
|
39
|
+
color: var(--foreground);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.outline:hover {
|
|
43
|
+
background: var(--background-alt);
|
|
44
|
+
color: var(--foreground);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ghost {
|
|
48
|
+
background: transparent;
|
|
49
|
+
color: var(--foreground);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ghost:hover {
|
|
53
|
+
background: var(--background-alt);
|
|
54
|
+
color: var(--foreground);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.defaultSize {
|
|
58
|
+
min-height: 2.25rem;
|
|
59
|
+
padding-inline: 0.75rem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.small {
|
|
63
|
+
min-height: 2rem;
|
|
64
|
+
padding-inline: 0.625rem;
|
|
65
|
+
font-size: 0.75rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.icon {
|
|
69
|
+
width: 2.25rem;
|
|
70
|
+
height: 2.25rem;
|
|
71
|
+
padding: 0;
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType } from "react";
|
|
2
|
+
type CardProps<T extends ElementType> = {
|
|
3
|
+
as?: T;
|
|
4
|
+
size?: "default" | "sm";
|
|
5
|
+
className?: string;
|
|
6
|
+
} & Omit<ComponentPropsWithoutRef<T>, "as" | "className">;
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "./cn.js";
|
|
3
|
+
import styles from "./card.module.css";
|
|
4
|
+
export function Card({ as, size = "default", className, ...props }) {
|
|
5
|
+
const Comp = as || "div";
|
|
6
|
+
return (_jsx(Comp, { "data-slot": "card", "data-size": size, className: cn(styles.card, size === "sm" && styles.small, className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
export function CardHeader({ className, ...props }) {
|
|
9
|
+
return (_jsx("div", { "data-slot": "card-header", className: cn(styles.header, className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
export function CardContent({ className, ...props }) {
|
|
12
|
+
return (_jsx("div", { "data-slot": "card-content", className: cn(styles.content, className), ...props }));
|
|
13
|
+
}
|
|
14
|
+
export function CardFooter({ className, ...props }) {
|
|
15
|
+
return (_jsx("div", { "data-slot": "card-footer", className: cn(styles.footer, className), ...props }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.card {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 1rem;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
border-radius: 0.75rem;
|
|
7
|
+
background: var(--card-bg);
|
|
8
|
+
color: var(--foreground);
|
|
9
|
+
box-shadow: 0 1px 3px var(--shadow);
|
|
10
|
+
transition: box-shadow 0.2s ease;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.card:hover {
|
|
14
|
+
box-shadow: 0 10px 25px var(--shadow-hover);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.small {
|
|
18
|
+
gap: 0.75rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.header {
|
|
22
|
+
display: grid;
|
|
23
|
+
gap: 0.25rem;
|
|
24
|
+
padding-inline: 1rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.content {
|
|
28
|
+
padding-inline: 1rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.footer {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
border-top: 1px solid var(--border);
|
|
35
|
+
background: var(--background-alt);
|
|
36
|
+
padding: 1rem;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cn(...classes: Array<string | false | null | undefined>): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
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
|
+
type PaginationLinkProps = ComponentPropsWithoutRef<typeof Link> & {
|
|
7
|
+
isActive?: boolean;
|
|
8
|
+
size?: "default" | "icon";
|
|
9
|
+
};
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
import { cn } from "./cn.js";
|
|
4
|
+
import styles from "./pagination.module.css";
|
|
5
|
+
export function Pagination({ className, ...props }) {
|
|
6
|
+
return (_jsx("nav", { "data-slot": "pagination", className: cn(styles.pagination, className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
export function PaginationContent({ className, ...props }) {
|
|
9
|
+
return (_jsx("ul", { "data-slot": "pagination-content", className: cn(styles.content, className), ...props }));
|
|
10
|
+
}
|
|
11
|
+
export function PaginationItem(props) {
|
|
12
|
+
return _jsx("li", { "data-slot": "pagination-item", ...props });
|
|
13
|
+
}
|
|
14
|
+
export function PaginationLink({ className, isActive, size = "icon", ...props }) {
|
|
15
|
+
return (_jsx(Link, { "data-slot": "pagination-link", "data-active": isActive, "aria-current": isActive ? "page" : undefined, className: cn(styles.link, size === "icon" ? styles.icon : styles.defaultSize, isActive && styles.active, className), ...props }));
|
|
16
|
+
}
|
|
17
|
+
export function PaginationPrevious({ children, className, ...props }) {
|
|
18
|
+
return (_jsxs(PaginationLink, { size: "default", className: className, ...props, children: [_jsx("span", { "aria-hidden": "true", children: "\u2190" }), _jsx("span", { children: children })] }));
|
|
19
|
+
}
|
|
20
|
+
export function PaginationNext({ children, className, ...props }) {
|
|
21
|
+
return (_jsxs(PaginationLink, { size: "default", className: className, ...props, children: [_jsx("span", { children: children }), _jsx("span", { "aria-hidden": "true", children: "\u2192" })] }));
|
|
22
|
+
}
|
|
23
|
+
export function PaginationEllipsis({ className, ...props }) {
|
|
24
|
+
return (_jsx("span", { "data-slot": "pagination-ellipsis", "aria-hidden": "true", className: cn(styles.ellipsis, className), ...props, children: "\u2026" }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.pagination {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
margin-inline: auto;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.content {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
gap: 0.25rem;
|
|
14
|
+
list-style: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.link {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
border-radius: 0.5rem;
|
|
24
|
+
color: var(--foreground);
|
|
25
|
+
font-size: 0.875rem;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
transition:
|
|
29
|
+
color 0.2s ease,
|
|
30
|
+
background-color 0.2s ease,
|
|
31
|
+
border-color 0.2s ease;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.link:hover {
|
|
35
|
+
background: var(--background-alt);
|
|
36
|
+
color: var(--foreground);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.icon {
|
|
40
|
+
width: 2.25rem;
|
|
41
|
+
height: 2.25rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.defaultSize {
|
|
45
|
+
min-height: 2.25rem;
|
|
46
|
+
gap: 0.5rem;
|
|
47
|
+
padding-inline: 0.75rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.active {
|
|
51
|
+
border: 1px solid var(--border);
|
|
52
|
+
background: var(--background);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ellipsis {
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 2.25rem;
|
|
58
|
+
height: 2.25rem;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
color: var(--foreground-light);
|
|
62
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./base";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./plugins";
|
|
4
|
-
export * from "./views";
|
|
5
|
-
export * from "./components";
|
|
6
|
-
export * from "./api";
|
|
1
|
+
export * from "./base/index.js";
|
|
2
|
+
export * from "./utils/index.js";
|
|
3
|
+
export * from "./plugins/index.js";
|
|
4
|
+
export * from "./views/index.js";
|
|
5
|
+
export * from "./components/index.js";
|
|
6
|
+
export * from "./api/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./base";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./plugins";
|
|
4
|
-
export * from "./views";
|
|
5
|
-
export * from "./components";
|
|
6
|
-
export * from "./api";
|
|
1
|
+
export * from "./base/index.js";
|
|
2
|
+
export * from "./utils/index.js";
|
|
3
|
+
export * from "./plugins/index.js";
|
|
4
|
+
export * from "./views/index.js";
|
|
5
|
+
export * from "./components/index.js";
|
|
6
|
+
export * from "./api/index.js";
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./yoast";
|
|
1
|
+
export * from "./yoast/index.js";
|
package/dist/plugins/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./yoast";
|
|
1
|
+
export * from "./yoast/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { buildYoastRobotsMeta, rewriteYoastUrls } from "../../utils/seo";
|
|
1
|
+
import { buildYoastRobotsMeta, rewriteYoastUrls } from "../../utils/seo.js";
|
|
2
|
+
import { toPlainText } from "../../utils/html.js";
|
|
2
3
|
const hasYoast = (entity) => {
|
|
3
4
|
if (!entity || typeof entity !== "object")
|
|
4
5
|
return false;
|
|
@@ -18,8 +19,8 @@ export const extractYoastMetadata = (entity, fallback = {}, opts = {}) => {
|
|
|
18
19
|
return null;
|
|
19
20
|
const robots = buildYoastRobotsMeta(yoast.robots);
|
|
20
21
|
const imageUrl = yoast.og_image?.[0]?.url || fallback.image;
|
|
21
|
-
const title = yoast.title || fallback.title;
|
|
22
|
-
const description = yoast.description || fallback.description;
|
|
22
|
+
const title = toPlainText(yoast.title) || fallback.title;
|
|
23
|
+
const description = toPlainText(yoast.description) || fallback.description;
|
|
23
24
|
const canonical = fallback.url;
|
|
24
25
|
return {
|
|
25
26
|
title,
|
|
@@ -29,8 +30,9 @@ export const extractYoastMetadata = (entity, fallback = {}, opts = {}) => {
|
|
|
29
30
|
canonical,
|
|
30
31
|
},
|
|
31
32
|
openGraph: {
|
|
32
|
-
title: yoast.title || fallback.title,
|
|
33
|
-
description: yoast.og_description || yoast.description ||
|
|
33
|
+
title: toPlainText(yoast.title) || fallback.title,
|
|
34
|
+
description: toPlainText(yoast.og_description || yoast.description) ||
|
|
35
|
+
fallback.description,
|
|
34
36
|
url: fallback.url,
|
|
35
37
|
type: yoast.og_type || "website",
|
|
36
38
|
siteName: yoast.og_site_name || fallback.siteName,
|
|
@@ -38,8 +40,9 @@ export const extractYoastMetadata = (entity, fallback = {}, opts = {}) => {
|
|
|
38
40
|
},
|
|
39
41
|
twitter: {
|
|
40
42
|
card: yoast.twitter_card || "summary_large_image",
|
|
41
|
-
title: yoast.twitter_title || yoast.title || fallback.title,
|
|
42
|
-
description: yoast.twitter_description || yoast.description ||
|
|
43
|
+
title: toPlainText(yoast.twitter_title || yoast.title) || fallback.title,
|
|
44
|
+
description: toPlainText(yoast.twitter_description || yoast.description) ||
|
|
45
|
+
fallback.description,
|
|
43
46
|
images: imageUrl ? [imageUrl] : undefined,
|
|
44
47
|
},
|
|
45
48
|
};
|
package/dist/utils/hreflang.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
langId?: string;
|
|
5
|
-
};
|
|
1
|
+
import { type SiteLanguage, type SiteLanguageInput } from "./language.js";
|
|
2
|
+
export type LanguageConfig = SiteLanguageInput;
|
|
3
|
+
export declare function getHreflangCode(language: Pick<SiteLanguageInput, "code">): string;
|
|
6
4
|
export declare function getTranslationKey(entity: unknown): string | undefined;
|
|
7
5
|
export declare function getEntityLanguageId(entity: unknown): string | undefined;
|
|
8
6
|
type BuildUrlParams<T> = {
|
|
9
7
|
entity: T;
|
|
10
|
-
langCfg:
|
|
8
|
+
langCfg: SiteLanguage;
|
|
11
9
|
};
|
|
12
10
|
export declare function buildLanguageAlternatesFromTranslations<T>({ translations, languages, buildUrl, ensurePageExists, }: {
|
|
13
11
|
translations: T[];
|
|
@@ -29,7 +27,7 @@ export declare function buildLanguageAlternatesPerLanguage<T>({ languages, fetch
|
|
|
29
27
|
ensurePageExists?: (params: BuildUrlParams<T>) => Promise<boolean>;
|
|
30
28
|
}): Promise<Record<string, string> | undefined>;
|
|
31
29
|
export declare function buildAbsoluteLangUrl({ basePath, path, siteUrl, }: {
|
|
32
|
-
basePath
|
|
30
|
+
basePath?: string;
|
|
33
31
|
path: string;
|
|
34
32
|
siteUrl?: string;
|
|
35
33
|
}): string;
|
package/dist/utils/hreflang.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { getAbsoluteUrl } from "./routing";
|
|
1
|
+
import { getAbsoluteUrl } from "./routing.js";
|
|
2
|
+
import { normalizeLanguages, shouldRenderLanguageAlternates, } from "./language.js";
|
|
2
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
|
+
}
|
|
3
10
|
export function getTranslationKey(entity) {
|
|
4
11
|
const meta = entity?.meta;
|
|
5
12
|
const value = meta?.translation_key_v2;
|
|
@@ -13,10 +20,11 @@ export function getEntityLanguageId(entity) {
|
|
|
13
20
|
return typeof lang === "number" ? lang.toString() : lang;
|
|
14
21
|
}
|
|
15
22
|
export async function buildLanguageAlternatesFromTranslations({ translations, languages, buildUrl, ensurePageExists, }) {
|
|
16
|
-
if (!translations?.length)
|
|
23
|
+
if (!translations?.length || !shouldRenderLanguageAlternates(languages)) {
|
|
17
24
|
return undefined;
|
|
25
|
+
}
|
|
18
26
|
const alternates = {};
|
|
19
|
-
for (const langCfg of languages) {
|
|
27
|
+
for (const langCfg of normalizeLanguages(languages)) {
|
|
20
28
|
if (!langCfg.langId)
|
|
21
29
|
continue;
|
|
22
30
|
const match = translations.find((translation) => getEntityLanguageId(translation)?.toString() ===
|
|
@@ -31,13 +39,14 @@ export async function buildLanguageAlternatesFromTranslations({ translations, la
|
|
|
31
39
|
const url = buildUrl({ entity: match, langCfg });
|
|
32
40
|
if (!url)
|
|
33
41
|
continue;
|
|
34
|
-
alternates[langCfg
|
|
42
|
+
alternates[getHreflangCode(langCfg)] = url;
|
|
35
43
|
}
|
|
36
44
|
return Object.keys(alternates).length > 1 ? alternates : undefined;
|
|
37
45
|
}
|
|
38
46
|
export async function resolveLanguageAlternates({ translationKey, languages, fetchTranslations, buildUrl, ensurePageExists, }) {
|
|
39
|
-
if (!translationKey)
|
|
47
|
+
if (!translationKey || !shouldRenderLanguageAlternates(languages)) {
|
|
40
48
|
return undefined;
|
|
49
|
+
}
|
|
41
50
|
const translations = await fetchTranslations(translationKey);
|
|
42
51
|
return buildLanguageAlternatesFromTranslations({
|
|
43
52
|
translations,
|
|
@@ -47,8 +56,10 @@ export async function resolveLanguageAlternates({ translationKey, languages, fet
|
|
|
47
56
|
});
|
|
48
57
|
}
|
|
49
58
|
export async function buildLanguageAlternatesPerLanguage({ languages, fetcher, buildUrl, ensurePageExists, }) {
|
|
59
|
+
if (!shouldRenderLanguageAlternates(languages))
|
|
60
|
+
return undefined;
|
|
50
61
|
const alternates = {};
|
|
51
|
-
for (const langCfg of languages) {
|
|
62
|
+
for (const langCfg of normalizeLanguages(languages)) {
|
|
52
63
|
if (!langCfg.langId)
|
|
53
64
|
continue;
|
|
54
65
|
try {
|
|
@@ -63,7 +74,7 @@ export async function buildLanguageAlternatesPerLanguage({ languages, fetcher, b
|
|
|
63
74
|
const url = buildUrl({ entity, langCfg });
|
|
64
75
|
if (!url)
|
|
65
76
|
continue;
|
|
66
|
-
alternates[langCfg
|
|
77
|
+
alternates[getHreflangCode(langCfg)] = url;
|
|
67
78
|
}
|
|
68
79
|
catch (error) {
|
|
69
80
|
console.error("Error building hreflang for lang", langCfg.code, error);
|
|
@@ -72,7 +83,7 @@ export async function buildLanguageAlternatesPerLanguage({ languages, fetcher, b
|
|
|
72
83
|
return Object.keys(alternates).length > 1 ? alternates : undefined;
|
|
73
84
|
}
|
|
74
85
|
export function buildAbsoluteLangUrl({ basePath, path, siteUrl, }) {
|
|
75
|
-
const normalizedBase = normalizeBasePath(basePath);
|
|
86
|
+
const normalizedBase = normalizeBasePath(basePath || "/");
|
|
76
87
|
const normalizedPath = path.startsWith("/")
|
|
77
88
|
? path.slice(1)
|
|
78
89
|
: path.replace(/^\/+/, "");
|
package/dist/utils/html.d.ts
CHANGED
package/dist/utils/html.js
CHANGED
|
@@ -6,3 +6,28 @@ export function stripTags(html) {
|
|
|
6
6
|
return undefined;
|
|
7
7
|
return html.replace(/<[^>]*>/g, "");
|
|
8
8
|
}
|
|
9
|
+
const namedEntities = {
|
|
10
|
+
amp: "&",
|
|
11
|
+
apos: "'",
|
|
12
|
+
gt: ">",
|
|
13
|
+
lt: "<",
|
|
14
|
+
nbsp: " ",
|
|
15
|
+
quot: '"',
|
|
16
|
+
};
|
|
17
|
+
export function decodeHtmlEntities(value) {
|
|
18
|
+
if (!value)
|
|
19
|
+
return value;
|
|
20
|
+
return value.replace(/&(#(?:x[0-9a-fA-F]+|\d+)|[a-zA-Z]+);/g, (match, entity) => {
|
|
21
|
+
if (entity[0] === "#") {
|
|
22
|
+
const isHex = entity[1]?.toLowerCase() === "x";
|
|
23
|
+
const codePoint = Number.parseInt(entity.slice(isHex ? 2 : 1), isHex ? 16 : 10);
|
|
24
|
+
return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
|
|
25
|
+
}
|
|
26
|
+
return namedEntities[entity] ?? match;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function toPlainText(html) {
|
|
30
|
+
const stripped = stripTags(html);
|
|
31
|
+
const decoded = decodeHtmlEntities(stripped);
|
|
32
|
+
return decoded?.replace(/\s+/g, " ").trim() || undefined;
|
|
33
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from "./i18n";
|
|
2
|
-
export * from "./routing";
|
|
3
|
-
export * from "./seo";
|
|
4
|
-
export * from "./html";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
1
|
+
export * from "./i18n.js";
|
|
2
|
+
export * from "./routing.js";
|
|
3
|
+
export * from "./seo.js";
|
|
4
|
+
export * from "./html.js";
|
|
5
|
+
export * from "./language.js";
|
|
6
|
+
export * from "./hreflang.js";
|
|
7
|
+
export * from "./sitemap.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from "./i18n";
|
|
2
|
-
export * from "./routing";
|
|
3
|
-
export * from "./seo";
|
|
4
|
-
export * from "./html";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
1
|
+
export * from "./i18n.js";
|
|
2
|
+
export * from "./routing.js";
|
|
3
|
+
export * from "./seo.js";
|
|
4
|
+
export * from "./html.js";
|
|
5
|
+
export * from "./language.js";
|
|
6
|
+
export * from "./hreflang.js";
|
|
7
|
+
export * from "./sitemap.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type SiteLanguageInput = {
|
|
2
|
+
code: string;
|
|
3
|
+
basePath?: string;
|
|
4
|
+
langId?: string;
|
|
5
|
+
wpLang?: string;
|
|
6
|
+
locale?: string;
|
|
7
|
+
dateLocale?: string;
|
|
8
|
+
isDefault?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type SiteLanguage = Required<Pick<SiteLanguageInput, "code" | "basePath" | "locale" | "isDefault">> & Omit<SiteLanguageInput, "basePath" | "locale" | "isDefault"> & {
|
|
11
|
+
prefixed: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type LanguageMode = "single" | "multi";
|
|
14
|
+
export type LanguageConfigOptions = {
|
|
15
|
+
defaultCode?: string;
|
|
16
|
+
defaultLocale?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function normalizeLanguages(languages?: SiteLanguageInput[], options?: LanguageConfigOptions): SiteLanguage[];
|
|
19
|
+
export declare function getLanguageMode(languages?: SiteLanguageInput[]): LanguageMode;
|
|
20
|
+
export declare function getDefaultLanguage(languages?: SiteLanguageInput[]): SiteLanguage;
|
|
21
|
+
export declare function getLanguageByCode(languages: SiteLanguageInput[] | undefined, code?: string): SiteLanguage | undefined;
|
|
22
|
+
export declare function getLanguageBasePath(language: SiteLanguageInput, allLanguages?: SiteLanguageInput[]): string;
|
|
23
|
+
export declare function shouldRenderLanguageAlternates(languages?: SiteLanguageInput[]): boolean;
|
|
24
|
+
export declare function buildLanguagePath(language: SiteLanguageInput, path?: string, allLanguages?: SiteLanguageInput[]): string;
|
|
25
|
+
export declare function getWpLanguageCode(language?: SiteLanguageInput): string | undefined;
|
|
26
|
+
export declare function getWpLanguageFilter(language?: SiteLanguageInput): {
|
|
27
|
+
taxonomies?: undefined;
|
|
28
|
+
lang?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
taxonomies: {
|
|
31
|
+
language: string[];
|
|
32
|
+
};
|
|
33
|
+
lang?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
lang: string;
|
|
36
|
+
taxonomies?: undefined;
|
|
37
|
+
};
|