@verbaly/compiler 0.47.0 → 0.48.0
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/cli.js +9 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.js +9 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
5
|
-
import { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, createVerbaly, flatten, localeDirection, normalizeLink, parse, parseTags, safeAttribute } from "verbaly";
|
|
5
|
+
import { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, alternateLinks, createVerbaly, flatten, localeDirection, normalizeLink, parse, parseTags, safeAttribute } from "verbaly";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { glob } from "tinyglobby";
|
|
8
8
|
import { parse as parse$1 } from "@babel/parser";
|
|
@@ -2699,24 +2699,18 @@ function formatRenderWarnings(result, sourceLocale) {
|
|
|
2699
2699
|
if (result.untranslatedHead.length > 0) lines.push(` ${counted(result.untranslatedHead.length, "page")} of ${result.files} ship the same <title> in every locale (${result.untranslatedHead[0]}), so search results read in ${sourceLocale}`, ` fix: bind the head too, <title data-verbaly="key"> and a meta through data-verbaly-attr`);
|
|
2700
2700
|
return lines;
|
|
2701
2701
|
}
|
|
2702
|
-
function
|
|
2702
|
+
function pagePath(rel) {
|
|
2703
2703
|
const path = rel.replace(/(^|\/)index\.html$/, "$1");
|
|
2704
|
-
return
|
|
2704
|
+
return path ? `/${path}` : "/";
|
|
2705
2705
|
}
|
|
2706
2706
|
function pageAlternates(baseUrl, rel, locales, sourceLocale) {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
});
|
|
2714
|
-
}
|
|
2715
|
-
alternates.push({
|
|
2716
|
-
hreflang: "x-default",
|
|
2717
|
-
href: pageUrl(baseUrl, "", rel)
|
|
2707
|
+
return alternateLinks({
|
|
2708
|
+
supported: locales,
|
|
2709
|
+
sourceLocale,
|
|
2710
|
+
path: pagePath(rel),
|
|
2711
|
+
routing: "prefix-except-source",
|
|
2712
|
+
baseUrl
|
|
2718
2713
|
});
|
|
2719
|
-
return alternates;
|
|
2720
2714
|
}
|
|
2721
2715
|
function buildSitemap(urls) {
|
|
2722
2716
|
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">${urls.flatMap(({ alternates }) => {
|