@webround/core 0.3.7 → 0.3.9
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/seo-react.js +6 -1
- package/dist/seo.d.ts +4 -2
- package/dist/seo.js +8 -7
- package/package.json +1 -1
package/dist/seo-react.js
CHANGED
|
@@ -28,7 +28,12 @@ export function WrSeoHead({ site, config, pathname, lang, langs }) {
|
|
|
28
28
|
const path = langs ? wrBuildLangPath('default', pathname, langs) : pathname;
|
|
29
29
|
const dynamic = useSyncExternalStore(subscribe, () => dynamicSeo, () => undefined);
|
|
30
30
|
const { title, tags, jsonLd } = wrSeoTags({ site, page: { ...wrSeoPageOf(config), ...dynamic }, path, lang, langs });
|
|
31
|
-
|
|
31
|
+
// The `<title>` that `index.html` has (a placeholder, the page app's own) is not the page's: when the page has one of its own, the head must have only that, as the HTML a crawler gets says it
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (title)
|
|
34
|
+
document.head.querySelectorAll('title:not([data-wr-seo])').forEach((other) => other.remove());
|
|
35
|
+
}, [title]);
|
|
36
|
+
return (_jsxs(_Fragment, { children: [title && _jsx("title", { "data-wr-seo": "", children: title }), tags.map(({ tag, attrs }) => {
|
|
32
37
|
const props = Object.fromEntries(Object.entries(attrs).map(([key, value]) => [PROP[key] ?? key, value]));
|
|
33
38
|
const key = `${tag}:${attrs.name ?? attrs.property ?? `${attrs.rel}:${attrs.hreflang ?? ''}`}`;
|
|
34
39
|
return tag === 'meta' ? _jsx("meta", { ...props }, key) : _jsx("link", { ...props }, key);
|
package/dist/seo.d.ts
CHANGED
|
@@ -139,8 +139,10 @@ export interface WrSnapshotTarget {
|
|
|
139
139
|
file: string;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Where the prerendered HTML of an address goes in `dist
|
|
143
|
-
*
|
|
142
|
+
* Where the prerendered HTML of an address goes in `dist/`, as the worker that serves the sites looks for it (the same layout the v1 sites have): a folder for the language and, in it, the home as
|
|
143
|
+
* `index.html` and any other page as `<page>.html`: `/en` → `en/index.html`, `/en/about` → `en/about.html`. The default language has no prefix in the address and its folder is `default`:
|
|
144
|
+
* `/` → `default/index.html`, `/about` → `default/about.html`. The build's own `index.html` (the page app, with no page in it) is never one of these: it is what any other address is served.
|
|
145
|
+
* A page with a longer address keeps it whole (`/en/about/team` → `en/about/team.html`).
|
|
144
146
|
*/
|
|
145
147
|
export declare function wrSnapshotFile(path: string, langs?: WrLangConfig): string;
|
|
146
148
|
/**
|
package/dist/seo.js
CHANGED
|
@@ -159,16 +159,17 @@ export function wrSeoEntries(input) {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* Where the prerendered HTML of an address goes in `dist
|
|
163
|
-
*
|
|
162
|
+
* Where the prerendered HTML of an address goes in `dist/`, as the worker that serves the sites looks for it (the same layout the v1 sites have): a folder for the language and, in it, the home as
|
|
163
|
+
* `index.html` and any other page as `<page>.html`: `/en` → `en/index.html`, `/en/about` → `en/about.html`. The default language has no prefix in the address and its folder is `default`:
|
|
164
|
+
* `/` → `default/index.html`, `/about` → `default/about.html`. The build's own `index.html` (the page app, with no page in it) is never one of these: it is what any other address is served.
|
|
165
|
+
* A page with a longer address keeps it whole (`/en/about/team` → `en/about/team.html`).
|
|
164
166
|
*/
|
|
165
167
|
export function wrSnapshotFile(path, langs) {
|
|
166
168
|
const segments = path.split('/').filter(Boolean);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return `${segments.join('/')}.html`;
|
|
169
|
+
const isLanguage = segments.length > 0 && !!langs?.available.includes(segments[0]);
|
|
170
|
+
const folder = isLanguage && segments[0] !== langs?.default ? segments[0] : 'default';
|
|
171
|
+
const page = isLanguage ? segments.slice(1) : segments;
|
|
172
|
+
return page.length === 0 ? `${folder}/index.html` : `${folder}/${page.join('/')}.html`;
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
174
175
|
* The pages a build prerenders: every page with a fixed address, in every language, but those marked noindex (a crawler is told to leave them
|