dh-remixer-sdk 0.0.42-e97c4fc → 0.0.42
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/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - Fills missing fields from available data (og/title/twitter propagation, canonical, og:url, etc.)
|
|
7
7
|
* - Preserves existing application/ld+json scripts; if none exist AND indexable, emits fallback WebPage JSON-LD
|
|
8
8
|
* - Forces robots to "noindex, follow" when isIndexable=false
|
|
9
|
-
* -
|
|
9
|
+
* - Ensures <html lang="en">
|
|
10
10
|
* - Canonical is DOMAIN + route (3rd param), not window.location
|
|
11
11
|
* - Avoids double-escaping (&amp;) by decoding extracted text before output
|
|
12
12
|
* - Ensures JSON-LD contains real characters (e.g. "&" not "&")
|
|
@@ -128,8 +128,7 @@ export async function injectMetadata(
|
|
|
128
128
|
// --- helpers --------------------------------------------------------------
|
|
129
129
|
|
|
130
130
|
// --- extract head ---------------------------------------------------------
|
|
131
|
-
|
|
132
|
-
const lang = pick(/<html\b[^>]*\blang=["']([^"']+)["']/i, prerenderedHtml) || "en";
|
|
131
|
+
const lang = "en";
|
|
133
132
|
|
|
134
133
|
const headInner = pick(/<head\b[^>]*>([\s\S]*?)<\/head>/i, prerenderedHtml);
|
|
135
134
|
|
|
@@ -83,7 +83,10 @@ test("JSON-LD description follows the page-level description (AI-7092)", async (
|
|
|
83
83
|
|
|
84
84
|
test("a head with only the static description still keeps it", async () => {
|
|
85
85
|
const out = await injectMetadata(SAMPLE, "/", true);
|
|
86
|
-
assert.match(
|
|
86
|
+
assert.match(
|
|
87
|
+
out,
|
|
88
|
+
/<meta\s+name="description"\s+content="A sample description"/,
|
|
89
|
+
);
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
// og:locale is derived from http-equiv="content-language", which follows the
|
|
@@ -175,27 +178,3 @@ test("markStaticHead is idempotent and survives a '>' inside content", () => {
|
|
|
175
178
|
/<meta data-ssg-static name="description" content="a > b" \/>/,
|
|
176
179
|
);
|
|
177
180
|
});
|
|
178
|
-
|
|
179
|
-
/*
|
|
180
|
-
* AI-7669: a non-English site declares its language in .env, the LanguageProvider applies it on
|
|
181
|
-
* mount, and the prerenderer captures the resulting <html lang>. This step used to re-emit a
|
|
182
|
-
* constant "en", so every published non-English page served the wrong language to crawlers and to
|
|
183
|
-
* anyone without JS.
|
|
184
|
-
*/
|
|
185
|
-
test("carries the prerendered <html lang> through to the output (AI-7669)", async () => {
|
|
186
|
-
const polish = `<html lang="pl">
|
|
187
|
-
<head><title>Introligatornia</title></head>
|
|
188
|
-
<body></body>
|
|
189
|
-
</html>`;
|
|
190
|
-
|
|
191
|
-
const out = await injectMetadata(polish, "/", true);
|
|
192
|
-
|
|
193
|
-
assert.match(out, /<html lang="pl">/);
|
|
194
|
-
assert.ok(!out.includes('<html lang="en">'));
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
test("defaults <html lang> to en when the prerendered document has none", async () => {
|
|
198
|
-
const out = await injectMetadata("<html><head><title>T</title></head><body></body></html>", "/", true);
|
|
199
|
-
|
|
200
|
-
assert.match(out, /<html lang="en">/);
|
|
201
|
-
});
|
|
@@ -47,30 +47,6 @@ const buildLocales = (): Record<string, LocaleDict> => {
|
|
|
47
47
|
|
|
48
48
|
const locales = buildLocales();
|
|
49
49
|
|
|
50
|
-
// The default is declared in .env as VITE_DEFAULT_LANG because this file is platform-owned. It is
|
|
51
|
-
// honoured only when that language has a dictionary — a provider opened on a language with no locale
|
|
52
|
-
// tree renders every t() key as raw text. A site with no dictionaries at all (inline text) keeps it.
|
|
53
|
-
// A declaration may be looser than the folder name (pl-PL, PL, pt-br) — match the dictionary, then its base subtag.
|
|
54
|
-
const dictionaryFor = (code: string): string | undefined => {
|
|
55
|
-
const keys = Object.keys(locales);
|
|
56
|
-
const lower = code.toLowerCase();
|
|
57
|
-
const base = lower.split("-")[0];
|
|
58
|
-
|
|
59
|
-
return keys.find((k) => k.toLowerCase() === lower) ?? keys.find((k) => k.toLowerCase() === base);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const resolveInitialLanguage = (): string => {
|
|
63
|
-
const declared = import.meta.env.VITE_DEFAULT_LANG as string | undefined;
|
|
64
|
-
const present = Object.keys(locales);
|
|
65
|
-
const declaredDictionary = declared ? dictionaryFor(declared) : undefined;
|
|
66
|
-
|
|
67
|
-
if (declaredDictionary) return declaredDictionary;
|
|
68
|
-
if (locales["en"]) return "en";
|
|
69
|
-
if (present.length) return present[0];
|
|
70
|
-
|
|
71
|
-
return declared || "en";
|
|
72
|
-
};
|
|
73
|
-
|
|
74
50
|
interface LanguageContextType {
|
|
75
51
|
language: string;
|
|
76
52
|
setLanguage: (lang: string) => void;
|
|
@@ -84,7 +60,7 @@ interface LanguageProviderProps {
|
|
|
84
60
|
}
|
|
85
61
|
|
|
86
62
|
export const LanguageProvider = ({ children }: LanguageProviderProps) => {
|
|
87
|
-
const [language, setLanguage] = useState<string>(
|
|
63
|
+
const [language, setLanguage] = useState<string>("en");
|
|
88
64
|
|
|
89
65
|
// Reflect the active language on <html lang> (a11y/SEO, and so tools can read it).
|
|
90
66
|
useEffect(() => {
|
|
@@ -29,6 +29,7 @@ export type RemixerCheckoutParams = {
|
|
|
29
29
|
shippingCost?: number;
|
|
30
30
|
shippingLabel?: string;
|
|
31
31
|
shippingAddress?: RemixerShippingAddress;
|
|
32
|
+
collectShipping?: boolean;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export type RemixerCheckoutSession = {
|
|
@@ -192,6 +193,7 @@ export const ecommerce = {
|
|
|
192
193
|
shipping_cost: params.shippingCost,
|
|
193
194
|
shipping_label: params.shippingLabel,
|
|
194
195
|
shipping_address: params.shippingAddress,
|
|
196
|
+
collect_shipping: params.collectShipping,
|
|
195
197
|
});
|
|
196
198
|
},
|
|
197
199
|
|