jamdesk 1.1.122 → 1.1.123

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jamdesk",
3
- "version": "1.1.122",
3
+ "version": "1.1.123",
4
4
  "description": "CLI for Jamdesk — build, preview, and deploy documentation sites from MDX. Dev server with hot reload, 50+ components, OpenAPI support, AI search, and Mintlify migration",
5
5
  "keywords": [
6
6
  "jamdesk",
@@ -11,7 +11,7 @@
11
11
  import type { Metadata } from 'next';
12
12
  import type { DocsConfig, Logo, LogoConfig, Favicon, LanguageConfig, LanguageCode } from './docs-types';
13
13
  import { normalizeLogo } from './docs-types';
14
- import { findHreflangAliasCollisions, transformLanguagePath, toHreflang } from './language-utils';
14
+ import { findHreflangAliasCollisions, transformLanguagePath, toHreflang, resolveLocaleFromPath } from './language-utils';
15
15
  import { logger } from '../shared/logger';
16
16
 
17
17
  // Dedupe per-process: same docs.json shape produces the same collision
@@ -228,6 +228,7 @@ function numericMeta(metatags: Record<string, string>, key: string): number | un
228
228
 
229
229
  type FallbackOg = {
230
230
  title?: string; description?: string; url: string; siteName: string; ogImageUrl: string;
231
+ locale?: string;
231
232
  };
232
233
 
233
234
  /**
@@ -261,7 +262,10 @@ export function buildOpenGraphMetadata(
261
262
  og.description = metatags['og:description'] || fb.description;
262
263
  og.url = metatags['og:url'] || fb.url;
263
264
  og.siteName = metatags['og:site_name'] || fb.siteName;
264
- if (metatags['og:locale']) og.locale = metatags['og:locale'];
265
+ // Explicit og:locale wins; otherwise fall back to the locale derived from the
266
+ // page's resolved language (multi-language sites only — see derivePageLocale).
267
+ const ogLocale = metatags['og:locale'] || fb.locale;
268
+ if (ogLocale) og.locale = ogLocale;
265
269
  // og:determiner is a narrow Next union ('a'|'an'|'the'|'auto'|''); ignore invalid.
266
270
  if (['a', 'an', 'the', 'auto', ''].includes(metatags['og:determiner'])) {
267
271
  og.determiner = metatags['og:determiner'];
@@ -563,6 +567,31 @@ export function buildHreflangAlternates(
563
567
  return alternates;
564
568
  }
565
569
 
570
+ /**
571
+ * Derive an `og:locale` value from the page's resolved language.
572
+ *
573
+ * Open Graph wants `language_TERRITORY` (underscore). We reuse the hreflang
574
+ * BCP-47 mapping and swap the hyphen for an underscore, so region-bearing codes
575
+ * map exactly (`pt-BR` → `pt_BR`, `fr-CA` → `fr_CA`, `cn` → `zh_Hans`) and bare
576
+ * codes emit the language alone (`fr` → `fr`). We deliberately do NOT invent a
577
+ * territory for bare codes — guessing `es_ES` for a Latin-American site would be
578
+ * worse than emitting `es`.
579
+ *
580
+ * Gated to multi-language sites: with one (or zero) declared languages we can't
581
+ * know the site's locale, so we emit nothing rather than guess `en`. The default
582
+ * (unprefixed) page resolves to the configured default language.
583
+ */
584
+ function derivePageLocale(pagePath: string, languages?: LanguageConfig[]): string | undefined {
585
+ if (!languages || languages.length <= 1) return undefined;
586
+ const declared = languages.map((l) => l.language);
587
+ const fromPath = resolveLocaleFromPath(pagePath, declared);
588
+ const code = (fromPath
589
+ || languages.find((l) => l.default)?.language
590
+ || languages[0]?.language) as LanguageCode | undefined;
591
+ if (!code) return undefined;
592
+ return toHreflang(code).replace(/-/g, '_');
593
+ }
594
+
566
595
  /**
567
596
  * Build SEO metadata for a documentation page.
568
597
  *
@@ -683,6 +712,7 @@ export function buildSeoMetadata(
683
712
  url: pageUrl,
684
713
  siteName: config.name,
685
714
  ogImageUrl,
715
+ locale: derivePageLocale(pagePath, languages),
686
716
  });
687
717
  }
688
718