@astrojs/starlight 0.41.11 → 0.42.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.
Files changed (402) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +13 -0
  2. package/dist/components/MobileMenuToggle.astro +65 -0
  3. package/{components → dist/components}/PageFrame.astro +32 -8
  4. package/dist/components-internals/Icons.d.ts +415 -0
  5. package/dist/components-internals/Icons.js +140 -0
  6. package/dist/components-internals/SidebarPersistState.d.ts +1 -0
  7. package/dist/components-internals/SidebarPersistState.js +53 -0
  8. package/dist/components-internals/TableOfContents/starlight-toc.d.ts +18 -0
  9. package/dist/components-internals/TableOfContents/starlight-toc.js +88 -0
  10. package/dist/constants.d.ts +4 -0
  11. package/dist/constants.js +4 -0
  12. package/{expressive-code.d.ts → dist/expressive-code.d.ts} +6 -13
  13. package/dist/expressive-code.js +31 -0
  14. package/dist/global.d.ts +62 -0
  15. package/dist/global.js +2 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +109 -0
  18. package/dist/integrations/aside-utils.d.ts +9 -0
  19. package/dist/integrations/aside-utils.js +35 -0
  20. package/dist/integrations/expressive-code/hast.d.ts +1 -0
  21. package/dist/integrations/expressive-code/hast.js +2 -0
  22. package/dist/integrations/expressive-code/index.d.ts +60 -0
  23. package/dist/integrations/expressive-code/index.js +48 -0
  24. package/dist/integrations/expressive-code/preprocessor.d.ts +17 -0
  25. package/dist/integrations/expressive-code/preprocessor.js +76 -0
  26. package/dist/integrations/expressive-code/themes/night-owl-dark.js +4 -0
  27. package/dist/integrations/expressive-code/themes/night-owl-light.js +4 -0
  28. package/dist/integrations/expressive-code/theming.d.ts +16 -0
  29. package/dist/integrations/expressive-code/theming.js +71 -0
  30. package/dist/integrations/expressive-code/translations.d.ts +8 -0
  31. package/dist/integrations/expressive-code/translations.js +26 -0
  32. package/dist/integrations/markdown-icon.d.ts +8 -0
  33. package/dist/integrations/markdown-icon.js +14 -0
  34. package/dist/integrations/markdown-plugins.d.ts +18 -0
  35. package/dist/integrations/markdown-plugins.js +36 -0
  36. package/dist/integrations/markdown-processor.d.ts +29 -0
  37. package/dist/integrations/markdown-processor.js +44 -0
  38. package/dist/integrations/pagefind.d.ts +7 -0
  39. package/dist/integrations/pagefind.js +34 -0
  40. package/dist/integrations/rehype-code-rtl-support.d.ts +21 -0
  41. package/dist/integrations/rehype-code-rtl-support.js +36 -0
  42. package/dist/integrations/rehype-heading-links.d.ts +10 -0
  43. package/dist/integrations/rehype-heading-links.js +57 -0
  44. package/dist/integrations/remark-asides.d.ts +32 -0
  45. package/dist/integrations/remark-asides.js +166 -0
  46. package/dist/integrations/remark-rehype.d.ts +17 -0
  47. package/dist/integrations/remark-rehype.js +51 -0
  48. package/dist/integrations/satteri.d.ts +13 -0
  49. package/dist/integrations/satteri.js +209 -0
  50. package/dist/integrations/shared/absolutePathToLang.d.ts +10 -0
  51. package/dist/integrations/shared/absolutePathToLang.js +13 -0
  52. package/dist/integrations/shared/localeToLang.d.ts +10 -0
  53. package/dist/integrations/shared/localeToLang.js +13 -0
  54. package/dist/integrations/shared/slugToLocale.d.ts +12 -0
  55. package/dist/integrations/shared/slugToLocale.js +15 -0
  56. package/dist/integrations/sitemap.d.ts +12 -0
  57. package/dist/integrations/sitemap.js +19 -0
  58. package/dist/integrations/vite-layer-order.d.ts +15 -0
  59. package/dist/integrations/vite-layer-order.js +56 -0
  60. package/dist/integrations/vite-lazy-barrel-optimization.d.ts +12 -0
  61. package/dist/integrations/vite-lazy-barrel-optimization.js +33 -0
  62. package/dist/integrations/vite-virtual-modules.d.ts +14 -0
  63. package/dist/integrations/vite-virtual-modules.js +108 -0
  64. package/dist/internal.d.ts +3 -0
  65. package/dist/internal.js +3 -0
  66. package/dist/loaders.d.ts +20 -0
  67. package/dist/loaders.js +49 -0
  68. package/dist/locals.d.ts +15 -0
  69. package/dist/locals.js +33 -0
  70. package/dist/package.js +4 -0
  71. package/{props.ts → dist/props.d.ts} +6 -4
  72. package/dist/props.js +1 -0
  73. package/dist/route-data.d.ts +7 -0
  74. package/dist/route-data.js +6 -0
  75. package/dist/schema.d.ts +426 -0
  76. package/dist/schema.js +103 -0
  77. package/dist/schemas/badge.d.ts +86 -0
  78. package/dist/schemas/badge.js +39 -0
  79. package/dist/schemas/components.d.ts +236 -0
  80. package/dist/schemas/components.js +36 -0
  81. package/dist/schemas/expressiveCode.d.ts +7 -0
  82. package/dist/schemas/expressiveCode.js +5 -0
  83. package/dist/schemas/favicon.d.ts +9 -0
  84. package/dist/schemas/favicon.js +32 -0
  85. package/dist/schemas/head.d.ts +33 -0
  86. package/dist/schemas/head.js +41 -0
  87. package/dist/schemas/hero.d.ts +319 -0
  88. package/dist/schemas/hero.js +73 -0
  89. package/dist/schemas/i18n.d.ts +125 -0
  90. package/dist/schemas/i18n.js +76 -0
  91. package/dist/schemas/icon.d.ts +284 -0
  92. package/dist/schemas/icon.js +7 -0
  93. package/dist/schemas/locale.d.ts +20 -0
  94. package/dist/schemas/locale.js +11 -0
  95. package/dist/schemas/logo.d.ts +32 -0
  96. package/dist/schemas/logo.js +14 -0
  97. package/dist/schemas/pagefind.d.ts +166 -0
  98. package/dist/schemas/pagefind.js +31 -0
  99. package/dist/schemas/prevNextLink.d.ts +10 -0
  100. package/dist/schemas/prevNextLink.js +14 -0
  101. package/dist/schemas/sidebar.d.ts +205 -0
  102. package/dist/schemas/sidebar.js +71 -0
  103. package/dist/schemas/site-title.d.ts +7 -0
  104. package/dist/schemas/site-title.js +17 -0
  105. package/dist/schemas/social.d.ts +292 -0
  106. package/dist/schemas/social.js +18 -0
  107. package/dist/schemas/tableOfContents.d.ts +24 -0
  108. package/dist/schemas/tableOfContents.js +16 -0
  109. package/dist/translations/ar.js +36 -0
  110. package/dist/translations/ca.js +46 -0
  111. package/dist/translations/cs.js +46 -0
  112. package/dist/translations/da.js +33 -0
  113. package/dist/translations/de.js +33 -0
  114. package/dist/translations/el.js +33 -0
  115. package/dist/translations/en.js +33 -0
  116. package/dist/translations/es.js +46 -0
  117. package/dist/translations/fa.js +33 -0
  118. package/dist/translations/fi.js +33 -0
  119. package/dist/translations/fr.js +36 -0
  120. package/dist/translations/gl.js +46 -0
  121. package/dist/translations/he.js +33 -0
  122. package/dist/translations/hi.js +36 -0
  123. package/dist/translations/hu.js +46 -0
  124. package/dist/translations/id.js +33 -0
  125. package/dist/translations/index.d.ts +48 -0
  126. package/dist/translations/index.js +75 -0
  127. package/dist/translations/it.js +36 -0
  128. package/dist/translations/ja.js +36 -0
  129. package/dist/translations/ko.js +36 -0
  130. package/dist/translations/lv.js +33 -0
  131. package/dist/translations/nb.js +33 -0
  132. package/dist/translations/nl.js +33 -0
  133. package/dist/translations/pl.js +36 -0
  134. package/dist/translations/pt.js +36 -0
  135. package/dist/translations/ro.js +33 -0
  136. package/dist/translations/ru.js +36 -0
  137. package/dist/translations/sk.js +33 -0
  138. package/dist/translations/sv.js +33 -0
  139. package/dist/translations/th.js +33 -0
  140. package/dist/translations/tr.js +33 -0
  141. package/dist/translations/uk.js +33 -0
  142. package/dist/translations/vi.js +33 -0
  143. package/dist/translations/zh-CN.js +36 -0
  144. package/dist/translations/zh-TW.js +36 -0
  145. package/dist/types.d.ts +4 -0
  146. package/dist/types.js +1 -0
  147. package/{user-components → dist/user-components}/FileTree.astro +1 -1
  148. package/{user-components → dist/user-components}/Steps.astro +1 -1
  149. package/{user-components → dist/user-components}/TabItem.astro +1 -1
  150. package/{user-components → dist/user-components}/Tabs.astro +1 -1
  151. package/dist/user-components/file-tree-icons.d.ts +178 -0
  152. package/dist/user-components/file-tree-icons.js +632 -0
  153. package/dist/user-components/file-tree-processor.d.ts +16 -0
  154. package/dist/user-components/file-tree-processor.js +132 -0
  155. package/dist/user-components/steps-processor.d.ts +10 -0
  156. package/dist/user-components/steps-processor.js +39 -0
  157. package/dist/user-components/tabs-processor.d.ts +23 -0
  158. package/dist/user-components/tabs-processor.js +70 -0
  159. package/dist/utils/base.d.ts +7 -0
  160. package/dist/utils/base.js +15 -0
  161. package/dist/utils/canonical.d.ts +10 -0
  162. package/dist/utils/canonical.js +14 -0
  163. package/dist/utils/collection-fs.d.ts +13 -0
  164. package/dist/utils/collection-fs.js +19 -0
  165. package/{utils/collection.ts → dist/utils/collection.d.ts} +9 -20
  166. package/dist/utils/collection.js +26 -0
  167. package/dist/utils/createPathFormatter.d.ts +9 -0
  168. package/dist/utils/createPathFormatter.js +35 -0
  169. package/dist/utils/createTranslationSystem.d.ts +23 -0
  170. package/dist/utils/createTranslationSystem.js +84 -0
  171. package/dist/utils/error-map.d.ts +23 -0
  172. package/dist/utils/error-map.js +125 -0
  173. package/dist/utils/format-path.d.ts +4 -0
  174. package/dist/utils/format-path.js +9 -0
  175. package/dist/utils/generateToC.d.ts +14 -0
  176. package/dist/utils/generateToC.js +25 -0
  177. package/dist/utils/git.d.ts +12 -0
  178. package/dist/utils/git.js +71 -0
  179. package/dist/utils/gitInlined.d.ts +6 -0
  180. package/dist/utils/gitInlined.js +11 -0
  181. package/dist/utils/head.d.ts +7 -0
  182. package/dist/utils/head.js +233 -0
  183. package/dist/utils/i18n.d.ts +50 -0
  184. package/dist/utils/i18n.js +141 -0
  185. package/dist/utils/localizedUrl.d.ts +8 -0
  186. package/dist/utils/localizedUrl.js +28 -0
  187. package/dist/utils/navigation.d.ts +19 -0
  188. package/dist/utils/navigation.js +353 -0
  189. package/dist/utils/path.d.ts +21 -0
  190. package/dist/utils/path.js +51 -0
  191. package/dist/utils/plugins.d.ts +721 -0
  192. package/dist/utils/plugins.js +174 -0
  193. package/dist/utils/routing/data.d.ts +20 -0
  194. package/dist/utils/routing/data.js +127 -0
  195. package/dist/utils/routing/index.d.ts +21 -0
  196. package/dist/utils/routing/index.js +106 -0
  197. package/dist/utils/routing/middleware.d.ts +11 -0
  198. package/dist/utils/routing/middleware.js +65 -0
  199. package/dist/utils/routing/types.d.ts +93 -0
  200. package/dist/utils/routing/types.js +1 -0
  201. package/dist/utils/slugs.d.ts +45 -0
  202. package/dist/utils/slugs.js +104 -0
  203. package/dist/utils/starlight-page.d.ts +36 -0
  204. package/dist/utils/starlight-page.js +120 -0
  205. package/dist/utils/translations-fs.d.ts +15 -0
  206. package/dist/utils/translations-fs.js +39 -0
  207. package/dist/utils/translations.d.ts +20 -0
  208. package/dist/utils/translations.js +29 -0
  209. package/dist/utils/types.d.ts +5 -0
  210. package/dist/utils/types.js +1 -0
  211. package/dist/utils/url.d.ts +7 -0
  212. package/{utils/url.ts → dist/utils/url.js} +5 -4
  213. package/dist/utils/user-config.d.ts +2055 -0
  214. package/dist/utils/user-config.js +136 -0
  215. package/dist/utils/validateLogoImports.d.ts +5 -0
  216. package/dist/utils/validateLogoImports.js +16 -0
  217. package/dist/utils/zodDeepMerge.d.ts +16 -0
  218. package/dist/utils/zodDeepMerge.js +53 -0
  219. package/package.json +60 -34
  220. package/CHANGELOG.md +0 -3051
  221. package/components/MobileMenuToggle.astro +0 -114
  222. package/components-internals/Icons.ts +0 -248
  223. package/components-internals/SidebarPersistState.ts +0 -71
  224. package/components-internals/TableOfContents/starlight-toc.ts +0 -127
  225. package/constants.ts +0 -4
  226. package/expressive-code.mjs +0 -23
  227. package/global.d.ts +0 -11
  228. package/i18n.d.ts +0 -18
  229. package/index.ts +0 -200
  230. package/integrations/aside-utils.ts +0 -41
  231. package/integrations/expressive-code/hast.d.ts +0 -5
  232. package/integrations/expressive-code/hast.mjs +0 -9
  233. package/integrations/expressive-code/index.ts +0 -125
  234. package/integrations/expressive-code/preprocessor.ts +0 -126
  235. package/integrations/expressive-code/themes/night-owl-dark.jsonc +0 -1796
  236. package/integrations/expressive-code/themes/night-owl-light.jsonc +0 -1695
  237. package/integrations/expressive-code/theming.ts +0 -105
  238. package/integrations/expressive-code/translations.ts +0 -36
  239. package/integrations/markdown-icon.ts +0 -13
  240. package/integrations/markdown-plugins.ts +0 -71
  241. package/integrations/markdown-processor.ts +0 -64
  242. package/integrations/pagefind.ts +0 -60
  243. package/integrations/rehype-code-rtl-support.ts +0 -37
  244. package/integrations/rehype-heading-links.ts +0 -79
  245. package/integrations/remark-asides.ts +0 -219
  246. package/integrations/remark-rehype.ts +0 -87
  247. package/integrations/satteri.ts +0 -265
  248. package/integrations/shared/absolutePathToLang.ts +0 -26
  249. package/integrations/shared/localeToLang.ts +0 -15
  250. package/integrations/shared/slugToLocale.ts +0 -18
  251. package/integrations/sitemap.ts +0 -23
  252. package/integrations/vite-layer-order.ts +0 -69
  253. package/integrations/vite-lazy-barrel-optimization.ts +0 -40
  254. package/integrations/vite-virtual-modules.ts +0 -175
  255. package/internal.ts +0 -6
  256. package/loaders.ts +0 -63
  257. package/locals.d.ts +0 -43
  258. package/locals.ts +0 -43
  259. package/route-data.ts +0 -11
  260. package/schema.ts +0 -167
  261. package/schemas/badge.ts +0 -40
  262. package/schemas/components.ts +0 -265
  263. package/schemas/expressiveCode.ts +0 -12
  264. package/schemas/favicon.ts +0 -40
  265. package/schemas/head.ts +0 -50
  266. package/schemas/hero.ts +0 -69
  267. package/schemas/i18n.ts +0 -244
  268. package/schemas/icon.ts +0 -7
  269. package/schemas/logo.ts +0 -28
  270. package/schemas/pagefind.ts +0 -128
  271. package/schemas/prevNextLink.ts +0 -18
  272. package/schemas/sidebar.ts +0 -163
  273. package/schemas/site-title.ts +0 -20
  274. package/schemas/social.ts +0 -23
  275. package/schemas/tableOfContents.ts +0 -21
  276. package/translations/README.md +0 -14
  277. package/translations/ar.json +0 -33
  278. package/translations/ca.json +0 -43
  279. package/translations/cs.json +0 -43
  280. package/translations/da.json +0 -30
  281. package/translations/de.json +0 -30
  282. package/translations/el.json +0 -30
  283. package/translations/en.json +0 -30
  284. package/translations/es.json +0 -43
  285. package/translations/fa.json +0 -30
  286. package/translations/fi.json +0 -30
  287. package/translations/fr.json +0 -33
  288. package/translations/gl.json +0 -43
  289. package/translations/he.json +0 -30
  290. package/translations/hi.json +0 -33
  291. package/translations/hu.json +0 -43
  292. package/translations/id.json +0 -30
  293. package/translations/index.ts +0 -76
  294. package/translations/it.json +0 -33
  295. package/translations/ja.json +0 -33
  296. package/translations/ko.json +0 -33
  297. package/translations/lv.json +0 -30
  298. package/translations/nb.json +0 -30
  299. package/translations/nl.json +0 -30
  300. package/translations/pl.json +0 -33
  301. package/translations/pt.json +0 -33
  302. package/translations/ro.json +0 -30
  303. package/translations/ru.json +0 -33
  304. package/translations/sk.json +0 -30
  305. package/translations/sv.json +0 -30
  306. package/translations/th.json +0 -30
  307. package/translations/tr.json +0 -30
  308. package/translations/uk.json +0 -30
  309. package/translations/vi.json +0 -30
  310. package/translations/zh-CN.json +0 -33
  311. package/translations/zh-TW.json +0 -33
  312. package/types.ts +0 -7
  313. package/user-components/file-tree-icons.ts +0 -782
  314. package/user-components/rehype-file-tree.ts +0 -251
  315. package/user-components/rehype-steps.ts +0 -85
  316. package/user-components/rehype-tabs.ts +0 -121
  317. package/utils/base.ts +0 -15
  318. package/utils/canonical.ts +0 -19
  319. package/utils/collection-fs.ts +0 -20
  320. package/utils/createPathFormatter.ts +0 -60
  321. package/utils/createTranslationSystem.ts +0 -137
  322. package/utils/error-map.ts +0 -222
  323. package/utils/format-path.ts +0 -7
  324. package/utils/generateToC.ts +0 -33
  325. package/utils/git.ts +0 -121
  326. package/utils/gitInlined.ts +0 -20
  327. package/utils/head.ts +0 -235
  328. package/utils/i18n.ts +0 -221
  329. package/utils/localizedUrl.ts +0 -51
  330. package/utils/navigation.ts +0 -574
  331. package/utils/path.ts +0 -58
  332. package/utils/plugins.ts +0 -498
  333. package/utils/routing/data.ts +0 -154
  334. package/utils/routing/index.ts +0 -139
  335. package/utils/routing/middleware.ts +0 -81
  336. package/utils/routing/types.ts +0 -101
  337. package/utils/slugs.ts +0 -119
  338. package/utils/starlight-page.ts +0 -205
  339. package/utils/translations-fs.ts +0 -54
  340. package/utils/translations.ts +0 -57
  341. package/utils/types.ts +0 -15
  342. package/utils/user-config.ts +0 -348
  343. package/utils/validateLogoImports.ts +0 -21
  344. package/utils/zodDeepMerge.ts +0 -144
  345. package/virtual-internal.d.ts +0 -149
  346. package/virtual.d.ts +0 -27
  347. /package/{components → dist/components}/AnchorHeading.astro +0 -0
  348. /package/{components → dist/components}/Banner.astro +0 -0
  349. /package/{components → dist/components}/ContentNotice.astro +0 -0
  350. /package/{components → dist/components}/ContentPanel.astro +0 -0
  351. /package/{components → dist/components}/DraftContentNotice.astro +0 -0
  352. /package/{components → dist/components}/EditLink.astro +0 -0
  353. /package/{components → dist/components}/FallbackContentNotice.astro +0 -0
  354. /package/{components → dist/components}/Footer.astro +0 -0
  355. /package/{components → dist/components}/Head.astro +0 -0
  356. /package/{components → dist/components}/Header.astro +0 -0
  357. /package/{components → dist/components}/Hero.astro +0 -0
  358. /package/{components → dist/components}/LanguageSelect.astro +0 -0
  359. /package/{components → dist/components}/LastUpdated.astro +0 -0
  360. /package/{components → dist/components}/MarkdownContent.astro +0 -0
  361. /package/{components → dist/components}/MobileMenuFooter.astro +0 -0
  362. /package/{components → dist/components}/MobileTableOfContents.astro +0 -0
  363. /package/{components → dist/components}/Page.astro +0 -0
  364. /package/{components → dist/components}/PageSidebar.astro +0 -0
  365. /package/{components → dist/components}/PageTitle.astro +0 -0
  366. /package/{components → dist/components}/Pagination.astro +0 -0
  367. /package/{components → dist/components}/Search.astro +0 -0
  368. /package/{components → dist/components}/Select.astro +0 -0
  369. /package/{components → dist/components}/Sidebar.astro +0 -0
  370. /package/{components → dist/components}/SidebarPersister.astro +0 -0
  371. /package/{components → dist/components}/SidebarRestorePoint.astro +0 -0
  372. /package/{components → dist/components}/SidebarSublist.astro +0 -0
  373. /package/{components → dist/components}/SiteTitle.astro +0 -0
  374. /package/{components → dist/components}/SkipLink.astro +0 -0
  375. /package/{components → dist/components}/SocialIcons.astro +0 -0
  376. /package/{components → dist/components}/StarlightPage.astro +0 -0
  377. /package/{components → dist/components}/TableOfContents.astro +0 -0
  378. /package/{components → dist/components}/ThemeProvider.astro +0 -0
  379. /package/{components → dist/components}/ThemeSelect.astro +0 -0
  380. /package/{components → dist/components}/TwoColumnContent.astro +0 -0
  381. /package/{components-internals → dist/components-internals}/TableOfContents/TableOfContentsList.astro +0 -0
  382. /package/{components.ts → dist/components.ts} +0 -0
  383. /package/{routes → dist/routes}/common.astro +0 -0
  384. /package/{routes → dist/routes}/ssr/404.astro +0 -0
  385. /package/{routes → dist/routes}/ssr/index.astro +0 -0
  386. /package/{routes → dist/routes}/static/404.astro +0 -0
  387. /package/{routes → dist/routes}/static/index.astro +0 -0
  388. /package/{style → dist/style}/anchor-links.css +0 -0
  389. /package/{style → dist/style}/asides.css +0 -0
  390. /package/{style → dist/style}/layers.css +0 -0
  391. /package/{style → dist/style}/markdown.css +0 -0
  392. /package/{style → dist/style}/print.css +0 -0
  393. /package/{style → dist/style}/props.css +0 -0
  394. /package/{style → dist/style}/reset.css +0 -0
  395. /package/{style → dist/style}/util.css +0 -0
  396. /package/{user-components → dist/user-components}/Aside.astro +0 -0
  397. /package/{user-components → dist/user-components}/Badge.astro +0 -0
  398. /package/{user-components → dist/user-components}/Card.astro +0 -0
  399. /package/{user-components → dist/user-components}/CardGrid.astro +0 -0
  400. /package/{user-components → dist/user-components}/Icon.astro +0 -0
  401. /package/{user-components → dist/user-components}/LinkButton.astro +0 -0
  402. /package/{user-components → dist/user-components}/LinkCard.astro +0 -0
@@ -1,219 +0,0 @@
1
- /// <reference types="mdast-util-directive" />
2
-
3
- import { h as _h, s as _s, type Properties } from 'hastscript';
4
- import type { Node, Paragraph as P, Parent, PhrasingContent, Root } from 'mdast';
5
- import {
6
- type Directives,
7
- directiveToMarkdown,
8
- type TextDirective,
9
- type LeafDirective,
10
- } from 'mdast-util-directive';
11
- import { toMarkdown } from 'mdast-util-to-markdown';
12
- import { toString } from 'mdast-util-to-string';
13
- import type { Plugin, Transformer } from 'unified';
14
- import { visit } from 'unist-util-visit';
15
- import type { MarkdownProcessorPluginOptions } from './markdown-processor';
16
- import { parseIconChildren } from './markdown-icon';
17
- import type { ElementContent } from 'hast';
18
- import { getAsideIcon, isAsideVariant, type AsideVariant } from './aside-utils';
19
-
20
- /** Hacky function that generates an mdast HTML tree ready for conversion to HTML by rehype. */
21
- function h(el: string, attrs: Properties = {}, children: unknown[] = []): P {
22
- const { tagName, properties } = _h(el, attrs);
23
- return {
24
- type: 'paragraph',
25
- data: { hName: tagName, hProperties: properties },
26
- children: children as P['children'],
27
- };
28
- }
29
-
30
- /** Hacky function that generates an mdast SVG tree ready for conversion to HTML by rehype. */
31
- function s(el: string, attrs: Properties = {}, children: unknown[] = []): P {
32
- const { tagName, properties } = _s(el, attrs);
33
- return {
34
- type: 'paragraph',
35
- data: { hName: tagName, hProperties: properties },
36
- children: children as P['children'],
37
- };
38
- }
39
-
40
- /** Checks if a node is a directive. */
41
- function isNodeDirective(node: Node): node is Directives {
42
- return (
43
- node.type === 'textDirective' ||
44
- node.type === 'leafDirective' ||
45
- node.type === 'containerDirective'
46
- );
47
- }
48
-
49
- /**
50
- * Transforms back directives not handled by Starlight to avoid breaking user content.
51
- * For example, a user might write `x:y` in the middle of a sentence, where `:y` would be
52
- * identified as a text directive, which are not used by Starlight, and we definitely want that
53
- * text to be rendered verbatim in the output.
54
- */
55
- function transformUnhandledDirective(
56
- node: TextDirective | LeafDirective,
57
- index: number,
58
- parent: Parent
59
- ) {
60
- let markdown = toMarkdown(node, { extensions: [directiveToMarkdown()] });
61
- /**
62
- * `mdast-util-to-markdown` assumes that the tree represents a complete document (as it's an AST
63
- * and not a CST) and to follow the POSIX definition of a line (a sequence of zero or more
64
- * non- <newline> characters plus a terminating <newline> character), a newline is automatically
65
- * added at the end of the output so that the output is a valid file.
66
- * In this specific case, we can safely remove the newline character at the end of the output
67
- * before replacing the directive with its value.
68
- *
69
- * @see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
70
- * @see https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508cc619b862f75b762dcf876c6b8315d330/lib/index.js#L79-L85
71
- */
72
- if (markdown.at(-1) === '\n') markdown = markdown.slice(0, -1);
73
- const textNode = { type: 'text', value: markdown } as const;
74
- if (node.type === 'textDirective') {
75
- parent.children[index] = textNode;
76
- } else {
77
- parent.children[index] = {
78
- type: 'paragraph',
79
- children: [textNode],
80
- };
81
- }
82
- }
83
-
84
- /** Hacky function that generates the children of an mdast SVG tree. */
85
- function makeSvgChildNodes(children: ElementContent[]): P[] {
86
- const nodes: P[] = [];
87
- for (const child of children) {
88
- if (child.type !== 'element') continue;
89
- nodes.push({
90
- type: 'paragraph',
91
- data: { hName: child.tagName, hProperties: child.properties },
92
- // We are explicitly casting to the expected type here due to the hacky nature of this
93
- // function which only works with SVG elements.
94
- children: makeSvgChildNodes(child.children) as unknown as P['children'],
95
- });
96
- }
97
- return nodes;
98
- }
99
-
100
- /**
101
- * remark plugin that converts blocks delimited with `:::` into styled
102
- * asides (a.k.a. “callouts”, “admonitions”, etc.). Depends on the
103
- * `remark-directive` module for the core parsing logic.
104
- *
105
- * For example, this Markdown
106
- *
107
- * ```md
108
- * :::tip[Did you know?]
109
- * Astro helps you build faster websites with “Islands Architecture”.
110
- * :::
111
- * ```
112
- *
113
- * will produce this output
114
- *
115
- * ```astro
116
- * <aside class="starlight-aside starlight-aside--tip" aria-label="Did you know?">
117
- * <p class="starlight-aside__title" aria-hidden="true">Did you know?</p>
118
- * <div class="starlight-aside__content">
119
- * <p>Astro helps you build faster websites with “Islands Architecture”.</p>
120
- * </div>
121
- * </aside>
122
- * ```
123
- */
124
- export function remarkAsides(options: MarkdownProcessorPluginOptions): Plugin<[], Root> {
125
- const iconPaths: Record<AsideVariant, ReturnType<typeof parseIconChildren>> = {
126
- note: parseIconChildren(getAsideIcon('note')),
127
- tip: parseIconChildren(getAsideIcon('tip')),
128
- caution: parseIconChildren(getAsideIcon('caution')),
129
- danger: parseIconChildren(getAsideIcon('danger')),
130
- };
131
-
132
- const transformer: Transformer<Root> = (tree, file) => {
133
- const lang = options.absolutePathToLang(file.path);
134
- const t = options.useTranslations(lang);
135
- visit(tree, (node, index, parent) => {
136
- if (!parent || index === undefined || !isNodeDirective(node)) {
137
- return;
138
- }
139
- if (node.type === 'textDirective' || node.type === 'leafDirective') {
140
- return;
141
- }
142
- const variant = node.name;
143
- const attributes = node.attributes;
144
- if (!isAsideVariant(variant)) return;
145
-
146
- // remark-directive converts a container’s “label” to a paragraph added as the head of its
147
- // children with the `directiveLabel` property set to true. We want to pass it as the title
148
- // prop to <Aside>, so when we find a directive label, we store it for the title prop and
149
- // remove the paragraph from the container’s children.
150
- let title: string = t(`aside.${variant}`);
151
- let titleNode: PhrasingContent[] = [{ type: 'text', value: title }];
152
- const firstChild = node.children[0];
153
- if (
154
- firstChild?.type === 'paragraph' &&
155
- firstChild.data &&
156
- 'directiveLabel' in firstChild.data &&
157
- firstChild.children.length > 0
158
- ) {
159
- titleNode = firstChild.children;
160
- title = toString(firstChild.children);
161
- // The first paragraph contains a directive label, we can safely remove it.
162
- node.children.splice(0, 1);
163
- }
164
-
165
- const iconPath = makeSvgChildNodes(
166
- attributes?.['icon']
167
- ? parseIconChildren(getAsideIcon(variant, attributes?.['icon']))
168
- : iconPaths[variant]
169
- );
170
-
171
- const aside = h(
172
- 'aside',
173
- {
174
- 'aria-label': title,
175
- class: `starlight-aside starlight-aside--${variant}`,
176
- },
177
- [
178
- h('p', { class: 'starlight-aside__title', 'aria-hidden': 'true' }, [
179
- s(
180
- 'svg',
181
- {
182
- viewBox: '0 0 24 24',
183
- width: 16,
184
- height: 16,
185
- fill: 'currentColor',
186
- class: 'starlight-aside__icon',
187
- },
188
- iconPath
189
- ),
190
- ...titleNode,
191
- ]),
192
- h('div', { class: 'starlight-aside__content' }, node.children),
193
- ]
194
- );
195
-
196
- parent.children[index] = aside;
197
- });
198
- };
199
-
200
- return function attacher() {
201
- return transformer;
202
- };
203
- }
204
-
205
- export function remarkDirectivesRestoration() {
206
- return function transformer(tree: Root) {
207
- visit(tree, (node, index, parent) => {
208
- if (
209
- index !== undefined &&
210
- parent &&
211
- (node.type === 'textDirective' || node.type === 'leafDirective') &&
212
- node.data === undefined
213
- ) {
214
- transformUnhandledDirective(node, index, parent);
215
- return;
216
- }
217
- });
218
- };
219
- }
@@ -1,87 +0,0 @@
1
- import { isUnifiedProcessor, rehypeHeadingIds } from '@astrojs/markdown-remark';
2
- import type { Root as RehypeRoot } from 'hast';
3
- import type { Root as RemarkRoot } from 'mdast';
4
- import remarkDirective from 'remark-directive';
5
- import type { Plugin } from 'unified';
6
- import type { VFile } from 'vfile';
7
- import { remarkAsides, remarkDirectivesRestoration } from './remark-asides';
8
- import { rehypeRtlCodeSupport } from './rehype-code-rtl-support';
9
- import rehypeAutolinkHeadings from './rehype-heading-links';
10
- import {
11
- getMarkdownProcessorPaths,
12
- shouldTransformPath,
13
- type MarkdownProcessorPluginOptions,
14
- } from './markdown-processor';
15
-
16
- // Re-exported so callers can narrow `markdown.processor` to the Unified processor and use the
17
- // remark directive-restoration plugin through the same lazy import that loads the optional
18
- // `@astrojs/markdown-remark` peer dependency.
19
- export { isUnifiedProcessor, remarkDirectivesRestoration };
20
-
21
- /** List of remark plugins to apply. */
22
- export function starlightRemarkPlugins(options: MarkdownProcessorPluginOptions): RemarkPlugin[] {
23
- return [remarkDirective, remarkPlugins(options)];
24
- }
25
-
26
- /** List of rehype plugins to apply. */
27
- export function starlightRehypePlugins(options: MarkdownProcessorPluginOptions): RehypePlugin[] {
28
- return [
29
- ...(options.starlightConfig.markdown.headingLinks ? [[rehypeHeadingIds]] : []),
30
- rehypePlugins(options),
31
- ] as RehypePlugin[];
32
- }
33
-
34
- /** Remark plugin applying other Starlight remark plugins if necessary. */
35
- function remarkPlugins(options: MarkdownProcessorPluginOptions): RemarkPlugin {
36
- const allowedPaths = getMarkdownProcessorPaths(options);
37
-
38
- return function attacher(this) {
39
- const remarkAsidesTransformer = remarkAsides(options).call(this)!;
40
-
41
- return async function transformer(...args) {
42
- const [, file] = args;
43
-
44
- if (!shouldTransformFile(file, allowedPaths)) return;
45
-
46
- await remarkAsidesTransformer(...args);
47
- };
48
- };
49
- }
50
-
51
- /** Rehype plugin applying other Starlight rehype plugins if necessary. */
52
- function rehypePlugins(options: MarkdownProcessorPluginOptions): RehypePlugin {
53
- const allowedPaths = getMarkdownProcessorPaths(options);
54
-
55
- return function attacher(this) {
56
- const rehypeRtlCodeSupportTransformer = rehypeRtlCodeSupport(options).call(this);
57
- const rehypeAutolinkHeadingsTransformer = rehypeAutolinkHeadings(options).call(this);
58
-
59
- return async function transformer(...args) {
60
- const [, file] = args;
61
-
62
- if (!shouldTransformFile(file, allowedPaths)) return;
63
-
64
- await rehypeRtlCodeSupportTransformer(...args);
65
-
66
- if (options.starlightConfig.markdown.headingLinks) {
67
- await rehypeAutolinkHeadingsTransformer(...args);
68
- }
69
- };
70
- };
71
- }
72
-
73
- /**
74
- * Determines if a file should be transformed by a remark/rehype plugin, e.g. files without a known
75
- * path or files that are not part of the allowed paths are skipped.
76
- */
77
- function shouldTransformFile(file: VFile, allowedPaths: string[]) {
78
- // If the content is rendered using the content loader `renderMarkdown()` API, a file path
79
- // is not provided.
80
- // In that case, we skip the file.
81
- if (!file?.path) return false;
82
-
83
- return shouldTransformPath(file.path, allowedPaths);
84
- }
85
-
86
- type RemarkPlugin = Plugin<[], RemarkRoot>;
87
- type RehypePlugin = Plugin<[], RehypeRoot>;
@@ -1,265 +0,0 @@
1
- import { fileURLToPath } from 'node:url';
2
- import { satteriHeadingIdsPlugin } from '@astrojs/markdown-satteri';
3
- import type { Parents, Properties } from 'hast';
4
- import type { Paragraph } from 'mdast';
5
- import { directiveToMarkdown } from 'mdast-util-directive';
6
- import { toMarkdown } from 'mdast-util-to-markdown';
7
- import type {
8
- HastPluginDefinition,
9
- HastPluginInput,
10
- HastVisitorContext,
11
- MdastPluginInput,
12
- MdastPluginDefinition,
13
- } from 'satteri';
14
- import { headingLinkIconChildren } from './markdown-icon';
15
- import { getAsideIcon, isAsideVariant } from './aside-utils';
16
- import {
17
- getMarkdownProcessorPaths,
18
- shouldTransformPath,
19
- type MarkdownProcessorPluginOptions,
20
- } from './markdown-processor';
21
-
22
- export function starlightSatteriPlugins(options: MarkdownProcessorPluginOptions): {
23
- mdastPlugins: MdastPluginInput[];
24
- hastPlugins: HastPluginInput[];
25
- } {
26
- const allowedPaths = getMarkdownProcessorPaths(options);
27
- return {
28
- mdastPlugins: [satteriAsidesPlugin(options, allowedPaths)],
29
- hastPlugins: [
30
- satteriRtlCodeSupportPlugin(allowedPaths),
31
- ...(options.starlightConfig.markdown.headingLinks
32
- ? [() => satteriHeadingIdsPlugin(), satteriAutolinkHeadingsPlugin(options, allowedPaths)]
33
- : []),
34
- ],
35
- };
36
- }
37
-
38
- /**
39
- * Recover directives Starlight didn't claim so user content isn't dropped
40
- */
41
- export function satteriDirectivesRestoration(): MdastPluginDefinition {
42
- return {
43
- name: 'starlight-directives-restoration',
44
- textDirective(node) {
45
- // Leave directives another plugin already handled (i.e. set `data` on) untouched.
46
- if (node.data !== undefined) return;
47
- return { type: 'text', value: serializeDirective(node) };
48
- },
49
- leafDirective(node) {
50
- if (node.data !== undefined) return;
51
- return {
52
- type: 'paragraph',
53
- children: [{ type: 'text', value: serializeDirective(node) }],
54
- };
55
- },
56
- containerDirective(node) {
57
- if (node.data !== undefined) return;
58
- return paragraphElement('div', {}, [...node.children]);
59
- },
60
- };
61
- }
62
-
63
- function paragraphElement(
64
- tagName: string,
65
- properties: Properties,
66
- children: unknown[] = []
67
- ): Paragraph {
68
- return {
69
- type: 'paragraph',
70
- data: { hName: tagName, hProperties: properties },
71
- children: children as Paragraph['children'],
72
- };
73
- }
74
-
75
- /** Convert `:::variant` directive blocks into styled asides. */
76
- function satteriAsidesPlugin(
77
- options: MarkdownProcessorPluginOptions,
78
- allowedPaths: string[]
79
- ): MdastPluginDefinition {
80
- return {
81
- name: 'starlight-asides',
82
- containerDirective(node, ctx) {
83
- if (!shouldTransformPath(ctx.fileURL, allowedPaths)) return;
84
- if (!isAsideVariant(node.name)) return;
85
-
86
- const variant = node.name;
87
- // `shouldTransformPath` above already returned for a missing `fileURL`.
88
- const filename = fileURLToPath(ctx.fileURL!);
89
- const t = options.useTranslations(options.absolutePathToLang(filename));
90
-
91
- let title = t(`aside.${variant}`);
92
- let titleNode: unknown[] = [{ type: 'text', value: title }];
93
- const children = [...node.children];
94
- const firstChild = children[0];
95
- if (
96
- firstChild?.type === 'paragraph' &&
97
- firstChild.data?.directiveLabel &&
98
- firstChild.children.length > 0
99
- ) {
100
- titleNode = firstChild.children;
101
- title = ctx.textContent(firstChild);
102
- children.shift();
103
- }
104
-
105
- const icon = getAsideIcon(variant, node.attributes?.['icon']);
106
- const iconSvg = `<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" class="starlight-aside__icon">${icon}</svg>`;
107
- // Markdown and MDX require different AST shapes for raw HTML content.
108
- // TODO: replace endsWith check with an official Sätteri API once available.
109
- const iconNode = ctx.fileURL?.pathname.endsWith('.mdx')
110
- ? {
111
- type: 'mdxJsxTextElement',
112
- name: 'Fragment',
113
- attributes: [{ type: 'mdxJsxAttribute', name: 'set:html', value: iconSvg }],
114
- }
115
- : { type: 'html', value: iconSvg };
116
-
117
- return paragraphElement(
118
- 'aside',
119
- {
120
- 'aria-label': title,
121
- class: `starlight-aside starlight-aside--${variant}`,
122
- },
123
- [
124
- paragraphElement('p', { class: 'starlight-aside__title', 'aria-hidden': 'true' }, [
125
- iconNode,
126
- ...titleNode,
127
- ]),
128
- paragraphElement('div', { class: 'starlight-aside__content' }, children),
129
- ]
130
- );
131
- },
132
- };
133
- }
134
-
135
- function serializeDirective(node: Parameters<typeof toMarkdown>[0]): string {
136
- const md = toMarkdown(node, { extensions: [directiveToMarkdown()] });
137
- return md.at(-1) === '\n' ? md.slice(0, -1) : md;
138
- }
139
-
140
- function satteriRtlCodeSupportPlugin(allowedPaths: string[]): HastPluginDefinition {
141
- return {
142
- name: 'starlight-rtl-code-support',
143
- element: [
144
- {
145
- filter: ['pre'],
146
- visit(node, ctx) {
147
- if (!shouldTransformPath(ctx.fileURL, allowedPaths)) return;
148
- if (node.properties && 'dir' in node.properties) return;
149
- ctx.setProperty(node, 'dir', 'ltr');
150
- },
151
- },
152
- {
153
- filter: ['code'],
154
- visit(node, ctx) {
155
- if (
156
- shouldTransformPath(ctx.fileURL, allowedPaths) &&
157
- !(node.properties && 'dir' in node.properties) &&
158
- !hasPreParent(node, ctx)
159
- ) {
160
- ctx.setProperty(node, 'dir', 'auto');
161
- }
162
- },
163
- },
164
- ],
165
- // Shiki runs ahead of us and replaces the highlighted `<pre>` element with a raw HTML
166
- // node, so the `pre` element visitor above never sees it. Patch the raw markup instead.
167
- raw(node, ctx) {
168
- if (!shouldTransformPath(ctx.fileURL, allowedPaths)) return undefined;
169
- const value = ltrRawPre(node.value);
170
- if (value === null) return undefined;
171
- return { type: 'raw', value };
172
- },
173
- };
174
- }
175
-
176
- /**
177
- * Check if any parent of `child` is a `<pre>` element by walking up the tree.
178
- */
179
- function hasPreParent(child: Readonly<Parents> | undefined, ctx: HastVisitorContext): boolean {
180
- while (child) {
181
- const parent: Readonly<Parents> | undefined = ctx.parent(child);
182
- if (parent?.type === 'element' && parent.tagName === 'pre') return true;
183
- child = parent;
184
- }
185
- return false;
186
- }
187
-
188
- const rawPreOpenTag = /<pre(?=[\s>])[^>]*>/;
189
-
190
- /**
191
- * Add `dir="ltr"` to the opening tag of a raw `<pre>` HTML string, unless it already declares a
192
- * `dir`. Returns `null` when the value isn’t a `<pre>`, leaving unrelated raw HTML untouched.
193
- */
194
- function ltrRawPre(value: string): string | null {
195
- const openTag = value.match(rawPreOpenTag)?.[0];
196
- if (!openTag || /\sdir\s*=/.test(openTag)) return null;
197
- return value.replace(openTag, () => `<pre dir="ltr"${openTag.slice(4)}`);
198
- }
199
-
200
- function satteriAutolinkHeadingsPlugin(
201
- options: MarkdownProcessorPluginOptions,
202
- allowedPaths: string[]
203
- ): HastPluginDefinition {
204
- return {
205
- name: 'starlight-autolink-headings',
206
- element: {
207
- filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
208
- visit(node, ctx) {
209
- if (!shouldTransformPath(ctx.fileURL, allowedPaths)) return;
210
-
211
- const id = node.properties?.['id'];
212
- if (typeof id !== 'string' || !id) return;
213
-
214
- const title = ctx.textContent(node);
215
- // `shouldTransformPath` above already returned for a missing `fileURL`.
216
- const filename = fileURLToPath(ctx.fileURL!);
217
- const t = options.useTranslations(options.absolutePathToLang(filename));
218
- const accessibleLabel = t('heading.anchorLabel', {
219
- title,
220
- interpolation: { escapeValue: false },
221
- });
222
-
223
- return {
224
- type: 'element',
225
- tagName: 'div',
226
- properties: { class: `sl-heading-wrapper level-${node.tagName}` },
227
- children: [
228
- node,
229
- {
230
- type: 'element',
231
- tagName: 'a',
232
- properties: { class: 'sl-anchor-link', href: '#' + id },
233
- children: [
234
- {
235
- type: 'element',
236
- tagName: 'span',
237
- properties: { 'aria-hidden': 'true', class: 'sl-anchor-icon' },
238
- children: [
239
- {
240
- type: 'element',
241
- tagName: 'svg',
242
- properties: {
243
- width: '16',
244
- height: '16',
245
- viewBox: '0 0 24 24',
246
- fill: 'currentColor',
247
- },
248
- children: headingLinkIconChildren,
249
- },
250
- ],
251
- },
252
- {
253
- type: 'element',
254
- tagName: 'span',
255
- properties: { class: 'sr-only', 'data-pagefind-ignore': true },
256
- children: [{ type: 'text', value: accessibleLabel }],
257
- },
258
- ],
259
- },
260
- ],
261
- };
262
- },
263
- },
264
- };
265
- }
@@ -1,26 +0,0 @@
1
- import type { StarlightConfig } from '../../types';
2
- import { localeToLang } from './localeToLang';
3
- import { slugToLocale } from './slugToLocale';
4
-
5
- /** Get current language from an absolute file path. */
6
- export function absolutePathToLang(
7
- path: string,
8
- {
9
- docsPath,
10
- starlightConfig,
11
- }: {
12
- docsPath: string;
13
- starlightConfig: Pick<StarlightConfig, 'defaultLocale' | 'locales'>;
14
- }
15
- ): string {
16
- // Format path to unix style path.
17
- path = path?.replace(/\\/g, '/');
18
- // Ensure that the page path starts with a slash if the docs directory also does,
19
- // which makes stripping the docs path in the next step work on Windows, too.
20
- if (path && !path.startsWith('/') && docsPath.startsWith('/')) path = '/' + path;
21
- // Strip docs path leaving only content collection file ID.
22
- // Example: /Users/houston/repo/src/content/docs/en/guide.md => en/guide.md
23
- const slug = path?.replace(docsPath, '');
24
- const locale = slugToLocale(slug, starlightConfig);
25
- return localeToLang(starlightConfig, locale);
26
- }
@@ -1,15 +0,0 @@
1
- import type { StarlightConfig } from '../../types';
2
- import { BuiltInDefaultLocale } from '../../utils/i18n';
3
-
4
- /**
5
- * Get the BCP-47 language tag for the given locale.
6
- * @param locale Locale string or `undefined` for the root locale.
7
- */
8
- export function localeToLang(
9
- config: Pick<StarlightConfig, 'defaultLocale' | 'locales'>,
10
- locale: string | undefined
11
- ): string {
12
- const lang = locale ? config.locales?.[locale]?.lang : config.locales?.root?.lang;
13
- const defaultLang = config.defaultLocale?.lang || config.defaultLocale?.locale;
14
- return lang || defaultLang || BuiltInDefaultLocale.lang;
15
- }
@@ -1,18 +0,0 @@
1
- import type { StarlightConfig } from '../../types';
2
-
3
- /**
4
- * Get the “locale” of a slug. This is the base path at which a language is served.
5
- * For example, if French docs are in `src/content/docs/french/`, the locale is `french`.
6
- * Root locale slugs will return `undefined`.
7
- * @param slug A collection entry slug
8
- */
9
- export function slugToLocale(
10
- slug: string | undefined,
11
- config: Pick<StarlightConfig, 'defaultLocale' | 'locales'>
12
- ): string | undefined {
13
- const localesConfig = config.locales ?? {};
14
- const baseSegment = slug?.split('/')[0];
15
- if (baseSegment && localesConfig[baseSegment]) return baseSegment;
16
- if (!localesConfig.root) return config.defaultLocale.locale;
17
- return undefined;
18
- }
@@ -1,23 +0,0 @@
1
- import sitemap, { type SitemapOptions } from '@astrojs/sitemap';
2
- import type { StarlightConfig } from '../types';
3
-
4
- export function getSitemapConfig(opts: StarlightConfig): SitemapOptions {
5
- const sitemapConfig: SitemapOptions = {};
6
- if (opts.isMultilingual) {
7
- sitemapConfig.i18n = {
8
- defaultLocale: opts.defaultLocale.locale || 'root',
9
- locales: Object.fromEntries(
10
- Object.entries(opts.locales).map(([locale, config]) => [locale, config!.lang!])
11
- ),
12
- };
13
- }
14
- return sitemapConfig;
15
- }
16
-
17
- /**
18
- * A wrapped version of the `@astrojs/sitemap` integration configured based
19
- * on Starlight i18n config.
20
- */
21
- export function starlightSitemap(opts: StarlightConfig) {
22
- return sitemap(getSitemapConfig(opts));
23
- }