@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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as targetLocales, i as resolveConfig, r as loadConfig, t as findConfigFile } from "./config-iLrfRYDB.js";
2
2
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, relative } from "node:path";
4
- import { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, createVerbaly, flatten, localeDirection, normalizeLink, parse, parseTags, safeAttribute } from "verbaly";
4
+ import { LOCALE_STORAGE_KEY, RICH_TAGS, VOID_TAGS, alternateLinks, createVerbaly, flatten, localeDirection, normalizeLink, parse, parseTags, safeAttribute } from "verbaly";
5
5
  import { glob } from "tinyglobby";
6
6
  import { parse as parse$1 } from "@babel/parser";
7
7
  import { createHash } from "node:crypto";
@@ -2334,24 +2334,18 @@ function formatRenderWarnings(result, sourceLocale) {
2334
2334
  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`);
2335
2335
  return lines;
2336
2336
  }
2337
- function pageUrl(baseUrl, prefix, rel) {
2337
+ function pagePath(rel) {
2338
2338
  const path = rel.replace(/(^|\/)index\.html$/, "$1");
2339
- return `${baseUrl}${prefix}${path ? `/${path}` : "/"}`;
2339
+ return path ? `/${path}` : "/";
2340
2340
  }
2341
2341
  function pageAlternates(baseUrl, rel, locales, sourceLocale) {
2342
- const alternates = [];
2343
- for (const locale of locales) {
2344
- const prefix = locale === sourceLocale ? "" : `/${locale}`;
2345
- alternates.push({
2346
- hreflang: locale,
2347
- href: pageUrl(baseUrl, prefix, rel)
2348
- });
2349
- }
2350
- alternates.push({
2351
- hreflang: "x-default",
2352
- href: pageUrl(baseUrl, "", rel)
2342
+ return alternateLinks({
2343
+ supported: locales,
2344
+ sourceLocale,
2345
+ path: pagePath(rel),
2346
+ routing: "prefix-except-source",
2347
+ baseUrl
2353
2348
  });
2354
- return alternates;
2355
2349
  }
2356
2350
  function buildSitemap(urls) {
2357
2351
  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 }) => {