@astrojs/starlight 0.10.4 → 0.11.1

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 (61) hide show
  1. package/404.astro +9 -4
  2. package/CHANGELOG.md +77 -0
  3. package/components/Badge.astro +1 -0
  4. package/components/Banner.astro +4 -4
  5. package/components/ContentPanel.astro +4 -0
  6. package/components/EditLink.astro +5 -24
  7. package/components/FallbackContentNotice.astro +2 -5
  8. package/components/Footer.astro +5 -32
  9. package/components/{HeadSEO.astro → Head.astro} +10 -14
  10. package/components/Header.astro +26 -16
  11. package/components/Hero.astro +6 -9
  12. package/components/Icons.ts +31 -23
  13. package/components/LanguageSelect.astro +1 -4
  14. package/components/LastUpdated.astro +5 -24
  15. package/components/MarkdownContent.astro +4 -0
  16. package/components/MobileMenuFooter.astro +17 -0
  17. package/components/MobileMenuToggle.astro +2 -4
  18. package/components/{TableOfContents/MobileTableOfContents.astro → MobileTableOfContents.astro} +26 -29
  19. package/components/Page.astro +120 -0
  20. package/{layout → components}/PageFrame.astro +16 -8
  21. package/components/{RightSidebarPanel.astro → PageSidebar.astro} +21 -9
  22. package/components/PageTitle.astro +16 -0
  23. package/components/{PrevNextLinks.astro → Pagination.astro} +3 -9
  24. package/components/Search.astro +5 -5
  25. package/components/Sidebar.astro +7 -36
  26. package/components/SidebarSublist.astro +8 -2
  27. package/components/SiteTitle.astro +1 -20
  28. package/components/SkipLink.astro +3 -5
  29. package/components/SocialIcons.astro +5 -34
  30. package/components/TableOfContents/TableOfContentsList.astro +1 -1
  31. package/components/TableOfContents/starlight-toc.ts +3 -1
  32. package/components/TableOfContents.astro +12 -15
  33. package/components/ThemeProvider.astro +1 -0
  34. package/components/ThemeSelect.astro +1 -4
  35. package/{layout → components}/TwoColumnContent.astro +2 -4
  36. package/constants.ts +4 -0
  37. package/index.astro +4 -2
  38. package/index.ts +10 -15
  39. package/integrations/virtual-user-config.ts +3 -0
  40. package/package.json +133 -4
  41. package/props.ts +1 -0
  42. package/schema.ts +3 -0
  43. package/schemas/components.ts +256 -0
  44. package/schemas/sidebar.ts +89 -0
  45. package/schemas/social.ts +69 -0
  46. package/style/reset.css +1 -1
  47. package/translations/id.json +1 -1
  48. package/translations/index.ts +5 -1
  49. package/translations/ru.json +2 -2
  50. package/translations/uk.json +22 -0
  51. package/translations/vi.json +22 -0
  52. package/{components/TableOfContents → utils}/generateToC.ts +2 -1
  53. package/utils/navigation.ts +22 -5
  54. package/utils/route-data.ts +97 -0
  55. package/utils/routing.ts +10 -0
  56. package/utils/user-config.ts +15 -102
  57. package/utils/validateLogoImports.ts +21 -0
  58. package/virtual.d.ts +37 -0
  59. package/components/RightSidebar.astro +0 -36
  60. package/layout/Page.astro +0 -132
  61. /package/translations/{zh.json → zh-CN.json} +0 -0
package/404.astro CHANGED
@@ -2,7 +2,8 @@
2
2
  import { getEntry } from 'astro:content';
3
3
  import config from 'virtual:starlight/user-config';
4
4
  import EmptyContent from './components/EmptyMarkdown.md';
5
- import Page from './layout/Page.astro';
5
+ import Page from './components/Page.astro';
6
+ import { generateRouteData } from './utils/route-data';
6
7
  import type { StarlightDocsEntry } from './utils/routing';
7
8
  import { useTranslations } from './utils/translations';
8
9
 
@@ -24,6 +25,8 @@ const fallbackEntry: StarlightDocsEntry = {
24
25
  editUrl: false,
25
26
  head: [],
26
27
  hero: { tagline: t('404.text'), actions: [] },
28
+ pagefind: false,
29
+ sidebar: { hidden: false },
27
30
  },
28
31
  render: async () => ({
29
32
  Content: EmptyContent,
@@ -35,8 +38,10 @@ const fallbackEntry: StarlightDocsEntry = {
35
38
  const userEntry = await getEntry('docs', '404');
36
39
  const entry = userEntry || fallbackEntry;
37
40
  const { Content, headings } = await entry.render();
41
+ const route = generateRouteData({
42
+ props: { ...entryMeta, entryMeta, headings, entry, id: entry.id, slug: entry.slug },
43
+ url: Astro.url,
44
+ });
38
45
  ---
39
46
 
40
- <Page {headings} entry={entry} id={entry.id} slug={entry.slug} {...entryMeta} {entryMeta}>
41
- <Content />
42
- </Page>
47
+ <Page {...route}><Content /></Page>
package/CHANGELOG.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#892](https://github.com/withastro/starlight/pull/892) [`2b30321`](https://github.com/withastro/starlight/commit/2b30321bde801bb9945d73dc954e25b40f4324fa) Thanks [@delucis](https://github.com/delucis)! - Add Patreon social link icon
8
+
9
+ - [#854](https://github.com/withastro/starlight/pull/854) [`71a52a1`](https://github.com/withastro/starlight/commit/71a52a16c44e3568128c83070541235133c44436) Thanks [@mehalter](https://github.com/mehalter)! - Add Reddit icon
10
+
11
+ - [#852](https://github.com/withastro/starlight/pull/852) [`344c92e`](https://github.com/withastro/starlight/commit/344c92e1b8bca5f92ec087df6cccf5c611eefdff) Thanks [@Lootjs](https://github.com/Lootjs)! - Improve Russian language support
12
+
13
+ - [#891](https://github.com/withastro/starlight/pull/891) [`395920c`](https://github.com/withastro/starlight/commit/395920c46e7b24cfff31800b3426ab375078e5c1) Thanks [@Frikadellios](https://github.com/Frikadellios)! - Add Ukrainian language support
14
+
15
+ - [#890](https://github.com/withastro/starlight/pull/890) [`63ea8e8`](https://github.com/withastro/starlight/commit/63ea8e86643b050c6be6f9a6167f6642b039c709) Thanks [@delucis](https://github.com/delucis)! - Update `execa` dependency to v8
16
+
17
+ - [#859](https://github.com/withastro/starlight/pull/859) [`eaa7a90`](https://github.com/withastro/starlight/commit/eaa7a902c7b7638b326709fd5203d932b20ed3fa) Thanks [@oggnimodd](https://github.com/oggnimodd)! - Improve Indonesian language support
18
+
19
+ - [#864](https://github.com/withastro/starlight/pull/864) [`b84aff2`](https://github.com/withastro/starlight/commit/b84aff2b9cccbc35c8619763c7f36841abe6344b) Thanks [@mehalter](https://github.com/mehalter)! - Optimize UI icon SVG paths
20
+
21
+ ## 0.11.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [#774](https://github.com/withastro/starlight/pull/774) [`903a579`](https://github.com/withastro/starlight/commit/903a57942ceb99b68672c3fa54622b39cc5d76f8) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Support adding HTML attributes to sidebar links from config and frontmatter
26
+
27
+ - [#796](https://github.com/withastro/starlight/pull/796) [`372ec96`](https://github.com/withastro/starlight/commit/372ec96d31d0c1a9aa8bc1605de2b424bf9bd5af) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Add the `@astrojs/sitemap` and `@astrojs/mdx` integrations only if they are not detected in the Astro configuration.
28
+
29
+ ⚠️ **BREAKING CHANGE** The minimum supported version of Astro is now v3.2.0. Make sure you update Astro at the same time as updating Starlight:
30
+
31
+ ```sh
32
+ npm install astro@latest
33
+ ```
34
+
35
+ - [#447](https://github.com/withastro/starlight/pull/447) [`b45719b`](https://github.com/withastro/starlight/commit/b45719b581353f8d8f0ce0a9b5c89132e902377b) Thanks [@andremralves](https://github.com/andremralves)! - Add `titleDelimiter` configuration option and include site title in page `<title>` tags
36
+
37
+ ⚠️ **BREAKING CHANGE** — Previously, every page’s `<title>` only included its individual frontmatter title.
38
+ Now, `<title>` tags include the page title, a delimiter character (`|` by default), and the site title.
39
+ For example, in the Startlight docs, `<title>Configuration Reference</title>` is now `<title>Configuration Reference | Starlight</title>`.
40
+
41
+ If you have a page where you need to override this new behaviour, set a custom title using the `head` frontmatter property:
42
+
43
+ ```md
44
+ ---
45
+ title: My Page
46
+ head:
47
+ - tag: title
48
+ content: Custom Title
49
+ ---
50
+ ```
51
+
52
+ - [#709](https://github.com/withastro/starlight/pull/709) [`140e729`](https://github.com/withastro/starlight/commit/140e729a8bf12f805ae0b7e2b5ad959cf68d8e22) Thanks [@delucis](https://github.com/delucis)! - Add support for overriding Starlight’s built-in components
53
+
54
+ ⚠️ **BREAKING CHANGE** — The page footer is now included on pages with `template: splash` in their frontmatter. Previously, this was not the case. If you are using `template: splash` and want to continue to hide footer elements, disable them in your frontmatter:
55
+
56
+ ```md
57
+ ---
58
+ title: Landing page
59
+ template: splash
60
+ # Disable unwanted footer elements as needed
61
+ editUrl: false
62
+ lastUpdated: false
63
+ prev: false
64
+ next: false
65
+ ---
66
+ ```
67
+
68
+ ⚠️ **BREAKING CHANGE** — This change involved refactoring the structure of some of Starlight’s built-in components slightly. If you were previously overriding these using other techniques, you may need to adjust your code.
69
+
70
+ ### Patch Changes
71
+
72
+ - [#815](https://github.com/withastro/starlight/pull/815) [`b7b23a2`](https://github.com/withastro/starlight/commit/b7b23a2c90a25fe8ea08338379b83d19c74d9037) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Add Facebook and email icons
73
+
74
+ - [#810](https://github.com/withastro/starlight/pull/810) [`dbe977b`](https://github.com/withastro/starlight/commit/dbe977b6ce3efcffefab850eca08bef316b41e53) Thanks [@hasham-qaiser](https://github.com/hasham-qaiser)! - Use `<span>` instead of `<h2>` in sidebar group headings
75
+
76
+ - [#807](https://github.com/withastro/starlight/pull/807) [`7c73dd1`](https://github.com/withastro/starlight/commit/7c73dd146ee294f9092346a0b0041990cc648a13) Thanks [@torn4dom4n](https://github.com/torn4dom4n)! - Add Vietnamese translations for Starlight UI
77
+
78
+ - [#756](https://github.com/withastro/starlight/pull/756) [`f55a8f0`](https://github.com/withastro/starlight/commit/f55a8f014a7addc46e971dd6b7148f4545acd16c) Thanks [@julien-deramond](https://github.com/julien-deramond)! - Prevent text from overflowing in several cases
79
+
3
80
  ## 0.10.4
4
81
 
5
82
  ### Patch Changes
@@ -22,6 +22,7 @@ const { variant = 'default', text } = Astro.props;
22
22
  line-height: 1;
23
23
  color: #fff;
24
24
  background-color: var(--sl-color-bg-badge);
25
+ overflow-wrap: anywhere;
25
26
  }
26
27
 
27
28
  .outline {
@@ -1,10 +1,10 @@
1
1
  ---
2
- interface Props {
3
- content: string;
4
- }
2
+ import type { Props } from '../props';
3
+
4
+ const { banner } = Astro.props.entry.data;
5
5
  ---
6
6
 
7
- <div class="sl-banner" set:html={Astro.props.content} />
7
+ {banner && <div class="sl-banner" set:html={banner.content} />}
8
8
 
9
9
  <style>
10
10
  .sl-banner {
@@ -1,3 +1,7 @@
1
+ ---
2
+ import type { Props } from '../props';
3
+ ---
4
+
1
5
  <div class="content-panel">
2
6
  <div class="sl-container"><slot /></div>
3
7
  </div>
@@ -1,34 +1,15 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
- import config from 'virtual:starlight/user-config';
4
- import project from 'virtual:starlight/project-context';
5
- import { useTranslations } from '../utils/translations';
6
2
  import Icon from '../user-components/Icon.astro';
7
-
8
- interface Props {
9
- data: CollectionEntry<'docs'>['data'];
10
- id: CollectionEntry<'docs'>['id'];
11
- locale: string | undefined;
12
- }
3
+ import type { Props } from '../props';
4
+ import { useTranslations } from '../utils/translations';
13
5
 
14
6
  const t = useTranslations(Astro.props.locale);
15
- const { editUrl } = Astro.props.data;
16
- const srcPath = project.srcDir.replace(project.root, '');
17
-
18
- let { baseUrl } = config.editLink;
19
- if (baseUrl && baseUrl.at(-1) !== '/') baseUrl += '/';
20
-
21
- const url =
22
- typeof editUrl === 'string'
23
- ? editUrl
24
- : baseUrl
25
- ? baseUrl + srcPath + 'content/docs/' + Astro.props.id
26
- : undefined;
7
+ const { editUrl } = Astro.props;
27
8
  ---
28
9
 
29
10
  {
30
- editUrl !== false && url && (
31
- <a href={url} class="sl-flex">
11
+ editUrl && (
12
+ <a href={editUrl} class="sl-flex">
32
13
  <Icon name="pencil" size="1.2em" />
33
14
  {t('page.editLink')}
34
15
  </a>
@@ -1,10 +1,7 @@
1
1
  ---
2
- import { useTranslations } from '../utils/translations';
3
2
  import Icon from '../user-components/Icon.astro';
4
-
5
- interface Props {
6
- locale: string | undefined;
7
- }
3
+ import type { Props } from '../props';
4
+ import { useTranslations } from '../utils/translations';
8
5
 
9
6
  const t = useTranslations(Astro.props.locale);
10
7
  ---
@@ -1,42 +1,15 @@
1
1
  ---
2
- import config from 'virtual:starlight/user-config';
3
- import { type SidebarEntry, getPrevNextLinks } from '../utils/navigation';
4
- import type { StarlightDocsEntry } from '../utils/routing';
5
- import type { LocaleData } from '../utils/slugs';
2
+ import type { Props } from '../props';
6
3
 
7
- import LastUpdated from '../components/LastUpdated.astro';
8
- import PrevNextLinks from '../components/PrevNextLinks.astro';
9
- import EditLink from './EditLink.astro';
10
-
11
- interface Props extends LocaleData {
12
- entry: StarlightDocsEntry;
13
- sidebar: SidebarEntry[];
14
- }
15
-
16
- const { entry, dir, lang, locale, sidebar } = Astro.props;
17
- const prevNextLinks = getPrevNextLinks(sidebar, config.pagination, {
18
- prev: entry.data.prev,
19
- next: entry.data.next,
20
- });
4
+ import { EditLink, LastUpdated, Pagination } from 'virtual:starlight/components';
21
5
  ---
22
6
 
23
7
  <footer>
24
8
  <div class="meta sl-flex">
25
- {config.editLink.baseUrl && <EditLink data={entry.data} id={entry.id} {locale} />}
26
- {
27
- (entry.data.lastUpdated ?? config.lastUpdated) && (
28
- <LastUpdated
29
- id={entry.id}
30
- {lang}
31
- lastUpdated={
32
- typeof entry.data.lastUpdated !== 'boolean' ? entry.data.lastUpdated : undefined
33
- }
34
- {locale}
35
- />
36
- )
37
- }
9
+ <EditLink {...Astro.props} />
10
+ <LastUpdated {...Astro.props} />
38
11
  </div>
39
- <PrevNextLinks {...prevNextLinks} {dir} {locale} />
12
+ <Pagination {...Astro.props} />
40
13
  </footer>
41
14
 
42
15
  <style>
@@ -1,21 +1,17 @@
1
1
  ---
2
- import type { CollectionEntry, z } from 'astro:content';
2
+ import type { z } from 'astro/zod';
3
3
  import config from 'virtual:starlight/user-config';
4
+ import { version } from '../package.json';
4
5
  import type { HeadConfigSchema } from '../schemas/head';
6
+ import { fileWithBase } from '../utils/base';
5
7
  import { createHead } from '../utils/head';
6
8
  import { localizedUrl } from '../utils/localizedUrl';
7
- import { fileWithBase } from '../utils/base';
8
- import { version } from '../package.json';
9
-
10
- interface Props {
11
- data: CollectionEntry<'docs'>['data'];
12
- lang: string;
13
- }
9
+ import type { Props } from '../props';
14
10
 
15
- const { data, lang } = Astro.props;
11
+ const { entry, lang } = Astro.props;
12
+ const { data } = entry;
16
13
 
17
14
  const canonical = Astro.site ? new URL(Astro.url.pathname, Astro.site) : undefined;
18
- const title = data.title || config.title;
19
15
  const description = data.description || config.description;
20
16
 
21
17
  const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
@@ -24,7 +20,7 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
24
20
  tag: 'meta',
25
21
  attrs: { name: 'viewport', content: 'width=device-width, initial-scale=1' },
26
22
  },
27
- { tag: 'title', content: title },
23
+ { tag: 'title', content: `${data.title} ${config.titleDelimiter} ${config.title}` },
28
24
  { tag: 'link', attrs: { rel: 'canonical', href: canonical?.href } },
29
25
  { tag: 'meta', attrs: { name: 'generator', content: Astro.generator } },
30
26
  {
@@ -41,7 +37,7 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
41
37
  },
42
38
  },
43
39
  // OpenGraph Tags
44
- { tag: 'meta', attrs: { property: 'og:title', content: title } },
40
+ { tag: 'meta', attrs: { property: 'og:title', content: data.title } },
45
41
  { tag: 'meta', attrs: { property: 'og:type', content: 'article' } },
46
42
  { tag: 'meta', attrs: { property: 'og:url', content: canonical?.href } },
47
43
  { tag: 'meta', attrs: { property: 'og:locale', content: lang } },
@@ -52,7 +48,7 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
52
48
  tag: 'meta',
53
49
  attrs: { name: 'twitter:card', content: 'summary_large_image' },
54
50
  },
55
- { tag: 'meta', attrs: { name: 'twitter:title', content: title } },
51
+ { tag: 'meta', attrs: { name: 'twitter:title', content: data.title } },
56
52
  { tag: 'meta', attrs: { name: 'twitter:description', content: description } },
57
53
  ];
58
54
 
@@ -95,7 +91,7 @@ if (config.social?.twitter) {
95
91
  tag: 'meta',
96
92
  attrs: {
97
93
  name: 'twitter:site',
98
- content: new URL(config.social.twitter).pathname,
94
+ content: new URL(config.social.twitter.url).pathname,
99
95
  },
100
96
  });
101
97
  }
@@ -1,24 +1,28 @@
1
1
  ---
2
- import LanguageSelect from './LanguageSelect.astro';
3
- import Search from './Search.astro';
4
- import SiteTitle from './SiteTitle.astro';
5
- import SocialIcons from './SocialIcons.astro';
6
- import ThemeSelect from './ThemeSelect.astro';
2
+ import type { Props } from '../props';
7
3
 
8
- interface Props {
9
- locale: string | undefined;
10
- }
11
-
12
- const { locale } = Astro.props;
4
+ import {
5
+ LanguageSelect,
6
+ Search,
7
+ SiteTitle,
8
+ SocialIcons,
9
+ ThemeSelect,
10
+ } from 'virtual:starlight/components';
13
11
  ---
14
12
 
15
13
  <div class="header sl-flex">
16
- <SiteTitle {locale} />
17
- <Search {locale} />
14
+ <div class="sl-flex">
15
+ <SiteTitle {...Astro.props} />
16
+ </div>
17
+ <div class="sl-flex">
18
+ <Search {...Astro.props} />
19
+ </div>
18
20
  <div class="sl-hidden md:sl-flex right-group">
19
- <SocialIcons />
20
- <ThemeSelect {locale} />
21
- <LanguageSelect {locale} />
21
+ <div class="sl-flex social-icons">
22
+ <SocialIcons {...Astro.props} />
23
+ </div>
24
+ <ThemeSelect {...Astro.props} />
25
+ <LanguageSelect {...Astro.props} />
22
26
  </div>
23
27
  </div>
24
28
 
@@ -30,10 +34,16 @@ const { locale } = Astro.props;
30
34
  height: 100%;
31
35
  }
32
36
 
33
- .right-group {
37
+ .right-group,
38
+ .social-icons {
34
39
  gap: 1rem;
35
40
  align-items: center;
36
41
  }
42
+ .social-icons::after {
43
+ content: '';
44
+ height: 2rem;
45
+ border-inline-end: 1px solid var(--sl-color-gray-5);
46
+ }
37
47
 
38
48
  @media (min-width: 50rem) {
39
49
  :global(:root[data-has-sidebar]) {
@@ -1,21 +1,18 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
2
  import { Image } from 'astro:assets';
3
+ import { PAGE_TITLE_ID } from '../constants';
4
+ import type { Props } from '../props';
4
5
  import CallToAction from './CallToAction.astro';
5
6
 
6
- interface Props {
7
- fallbackTitle: string;
8
- hero: NonNullable<CollectionEntry<'docs'>['data']['hero']>;
9
- }
10
-
11
- const { title = Astro.props.fallbackTitle, tagline, image, actions } = Astro.props.hero;
7
+ const { data } = Astro.props.entry;
8
+ const { title = data.title, tagline, image, actions = [] } = data.hero || {};
12
9
 
13
10
  const imageAttrs = {
14
11
  loading: 'eager' as const,
15
12
  decoding: 'async' as const,
16
13
  width: 400,
17
14
  height: 400,
18
- alt: image?.alt,
15
+ alt: image?.alt || '',
19
16
  };
20
17
  ---
21
18
 
@@ -33,7 +30,7 @@ const imageAttrs = {
33
30
  }
34
31
  <div class="sl-flex stack">
35
32
  <div class="sl-flex copy">
36
- <h1 id="_top" data-page-title set:html={title} />
33
+ <h1 id={PAGE_TITLE_ID} data-page-title set:html={title} />
37
34
  {tagline && <div class="tagline" set:html={tagline} />}
38
35
  </div>
39
36
  {