@astrojs/starlight 0.5.6 → 0.6.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 (76) hide show
  1. package/404.astro +17 -17
  2. package/CHANGELOG.md +40 -2
  3. package/components/CallToAction.astro +32 -35
  4. package/components/ContentPanel.astro +18 -18
  5. package/components/EditLink.astro +23 -23
  6. package/components/FallbackContentNotice.astro +16 -18
  7. package/components/Footer.astro +28 -34
  8. package/components/HeadSEO.astro +69 -75
  9. package/components/Header.astro +47 -51
  10. package/components/Hero.astro +108 -121
  11. package/components/Icons.ts +73 -71
  12. package/components/LanguageSelect.astro +31 -31
  13. package/components/LastUpdated.astro +16 -18
  14. package/components/MarkdownContent.astro +105 -117
  15. package/components/MobileMenuToggle.astro +80 -80
  16. package/components/PrevNextLinks.astro +60 -60
  17. package/components/RightSidebar.astro +17 -17
  18. package/components/RightSidebarPanel.astro +41 -41
  19. package/components/Search.astro +293 -306
  20. package/components/Select.astro +64 -65
  21. package/components/Sidebar.astro +23 -23
  22. package/components/SidebarSublist.astro +96 -95
  23. package/components/SiteTitle.astro +65 -63
  24. package/components/SkipLink.astro +17 -17
  25. package/components/SocialIcons.astro +36 -34
  26. package/components/TableOfContents/MobileTableOfContents.astro +124 -124
  27. package/components/TableOfContents/TableOfContentsList.astro +64 -69
  28. package/components/TableOfContents/generateToC.ts +41 -43
  29. package/components/TableOfContents/starlight-toc.ts +84 -90
  30. package/components/TableOfContents.astro +8 -8
  31. package/components/ThemeProvider.astro +28 -32
  32. package/components/ThemeSelect.astro +66 -71
  33. package/global.d.ts +3 -3
  34. package/index.astro +1 -1
  35. package/index.ts +52 -59
  36. package/integrations/asides.ts +109 -111
  37. package/integrations/sitemap.ts +10 -13
  38. package/integrations/virtual-user-config.ts +37 -37
  39. package/layout/Page.astro +84 -72
  40. package/layout/PageFrame.astro +67 -69
  41. package/layout/TwoColumnContent.astro +40 -42
  42. package/package.json +2 -2
  43. package/schema.ts +126 -113
  44. package/schemas/favicon.ts +40 -0
  45. package/schemas/head.ts +12 -23
  46. package/schemas/i18n.ts +146 -160
  47. package/schemas/logo.ts +22 -22
  48. package/schemas/prevNextLink.ts +14 -14
  49. package/schemas/tableOfContents.ts +14 -18
  50. package/style/asides.css +27 -27
  51. package/style/props.css +168 -172
  52. package/style/reset.css +13 -13
  53. package/style/shiki.css +11 -11
  54. package/style/util.css +30 -30
  55. package/translations/fr.json +21 -21
  56. package/translations/index.ts +4 -4
  57. package/translations/it.json +20 -20
  58. package/translations/tr.json +1 -1
  59. package/translations/zh.json +0 -1
  60. package/user-components/Card.astro +50 -54
  61. package/user-components/CardGrid.astro +21 -21
  62. package/user-components/Icon.astro +19 -21
  63. package/user-components/TabItem.astro +3 -3
  64. package/user-components/Tabs.astro +113 -117
  65. package/user-components/rehype-tabs.ts +72 -72
  66. package/utils/base.ts +6 -6
  67. package/utils/git.ts +55 -55
  68. package/utils/head.ts +56 -54
  69. package/utils/i18n.ts +3 -3
  70. package/utils/localizedUrl.ts +25 -25
  71. package/utils/navigation.ts +225 -203
  72. package/utils/routing.ts +74 -85
  73. package/utils/slugs.ts +41 -51
  74. package/utils/translations.ts +26 -32
  75. package/utils/user-config.ts +278 -278
  76. package/virtual.d.ts +8 -8
@@ -6,67 +6,63 @@ import SocialIcons from './SocialIcons.astro';
6
6
  import ThemeSelect from './ThemeSelect.astro';
7
7
 
8
8
  interface Props {
9
- locale: string | undefined;
9
+ locale: string | undefined;
10
10
  }
11
11
 
12
12
  const { locale } = Astro.props;
13
13
  ---
14
14
 
15
15
  <div class="header flex">
16
- <SiteTitle {locale} />
17
- <Search {locale} />
18
- <div class="hidden md:flex right-group">
19
- <SocialIcons />
20
- <ThemeSelect {locale} />
21
- <LanguageSelect {locale} />
22
- </div>
16
+ <SiteTitle {locale} />
17
+ <Search {locale} />
18
+ <div class="hidden md:flex right-group">
19
+ <SocialIcons />
20
+ <ThemeSelect {locale} />
21
+ <LanguageSelect {locale} />
22
+ </div>
23
23
  </div>
24
24
 
25
25
  <style>
26
- .header {
27
- gap: var(--sl-nav-gap);
28
- justify-content: space-between;
29
- align-items: center;
30
- height: 100%;
31
- }
26
+ .header {
27
+ gap: var(--sl-nav-gap);
28
+ justify-content: space-between;
29
+ align-items: center;
30
+ height: 100%;
31
+ }
32
32
 
33
- .right-group {
34
- gap: 1rem;
35
- align-items: center;
36
- }
33
+ .right-group {
34
+ gap: 1rem;
35
+ align-items: center;
36
+ }
37
37
 
38
- @media (min-width: 50rem) {
39
- :global(:root[data-has-sidebar]) {
40
- --__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
41
- }
42
- :global(:root:not([data-has-toc])) {
43
- --__toc-width: 0rem;
44
- }
45
- .header {
46
- --__sidebar-width: max(
47
- 0rem,
48
- var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x)
49
- );
50
- --__main-column-fr: calc(
51
- (
52
- 100% + var(--__sidebar-pad, 0rem) -
53
- var(--__toc-width, var(--sl-sidebar-width)) -
54
- (2 * var(--__toc-width, var(--sl-nav-pad-x))) -
55
- var(--sl-content-inline-start, 0rem) - var(--sl-content-width)
56
- ) / 2
57
- );
58
- display: grid;
59
- grid-template-columns:
38
+ @media (min-width: 50rem) {
39
+ :global(:root[data-has-sidebar]) {
40
+ --__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
41
+ }
42
+ :global(:root:not([data-has-toc])) {
43
+ --__toc-width: 0rem;
44
+ }
45
+ .header {
46
+ --__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
47
+ --__main-column-fr: calc(
48
+ (
49
+ 100% + var(--__sidebar-pad, 0rem) - var(--__toc-width, var(--sl-sidebar-width)) -
50
+ (2 * var(--__toc-width, var(--sl-nav-pad-x))) - var(--sl-content-inline-start, 0rem) -
51
+ var(--sl-content-width)
52
+ ) / 2
53
+ );
54
+ display: grid;
55
+ grid-template-columns:
60
56
  /* 1 (site title): runs up until the main content column’s left edge or the width of the title, whichever is the largest */
61
- minmax(calc(
62
- var(--__sidebar-width) +
63
- max(0rem, var(--__main-column-fr) - var(--sl-nav-gap))
64
- ), auto)
65
- /* 2 (search box): all free space that is available. */
66
- 1fr
67
- /* 3 (right items): use the space that these need. */
68
- auto;
69
- align-content: center;
70
- }
71
- }
57
+ minmax(
58
+ calc(var(--__sidebar-width) + max(0rem, var(--__main-column-fr) - var(--sl-nav-gap))),
59
+ auto
60
+ )
61
+ /* 2 (search box): all free space that is available. */
62
+ 1fr
63
+ /* 3 (right items): use the space that these need. */
64
+ auto;
65
+ align-content: center;
66
+ }
67
+ }
72
68
  </style>
@@ -4,136 +4,123 @@ import { Image } from 'astro:assets';
4
4
  import CallToAction from './CallToAction.astro';
5
5
 
6
6
  interface Props {
7
- fallbackTitle: string;
8
- hero: NonNullable<CollectionEntry<'docs'>['data']['hero']>;
7
+ fallbackTitle: string;
8
+ hero: NonNullable<CollectionEntry<'docs'>['data']['hero']>;
9
9
  }
10
10
 
11
- const {
12
- title = Astro.props.fallbackTitle,
13
- tagline,
14
- image,
15
- actions,
16
- } = Astro.props.hero;
11
+ const { title = Astro.props.fallbackTitle, tagline, image, actions } = Astro.props.hero;
17
12
 
18
13
  const imageAttrs = {
19
- loading: 'eager' as const,
20
- decoding: 'async' as const,
21
- width: 400,
22
- height: 400,
23
- alt: image?.alt,
14
+ loading: 'eager' as const,
15
+ decoding: 'async' as const,
16
+ width: 400,
17
+ height: 400,
18
+ alt: image?.alt,
24
19
  };
25
20
  ---
26
21
 
27
22
  <div class="hero">
28
- {
29
- image?.file ? (
30
- image.file.format === 'svg' ? (
31
- <img src={image.file.src} {...imageAttrs} />
32
- ) : (
33
- <Image src={image.file} {...imageAttrs} />
34
- )
35
- ) : (
36
- image?.html && <div class="hero-html flex" set:html={image.html} />
37
- )
38
- }
39
- <div class="flex stack">
40
- <div class="flex copy">
41
- <h1 id="_top" data-page-title set:html={title} />
42
- {tagline && <div class="tagline" set:html={tagline} />}
43
- </div>
44
- {
45
- actions.length > 0 && (
46
- <div class="flex actions">
47
- {actions.map(({ text, ...attrs }) => (
48
- <CallToAction {...attrs} set:html={text} />
49
- ))}
50
- </div>
51
- )
52
- }
53
- </div>
23
+ {
24
+ image?.file ? (
25
+ image.file.format === 'svg' ? (
26
+ <img src={image.file.src} {...imageAttrs} />
27
+ ) : (
28
+ <Image src={image.file} {...imageAttrs} />
29
+ )
30
+ ) : (
31
+ image?.html && <div class="hero-html flex" set:html={image.html} />
32
+ )
33
+ }
34
+ <div class="flex stack">
35
+ <div class="flex copy">
36
+ <h1 id="_top" data-page-title set:html={title} />
37
+ {tagline && <div class="tagline" set:html={tagline} />}
38
+ </div>
39
+ {
40
+ actions.length > 0 && (
41
+ <div class="flex actions">
42
+ {actions.map(({ text, ...attrs }) => (
43
+ <CallToAction {...attrs} set:html={text} />
44
+ ))}
45
+ </div>
46
+ )
47
+ }
48
+ </div>
54
49
  </div>
55
50
 
56
51
  <style>
57
- .hero {
58
- display: grid;
59
- align-items: center;
60
- gap: 1rem;
61
- padding-bottom: 1rem;
62
- }
63
-
64
- .hero > img,
65
- .hero > .hero-html {
66
- object-fit: contain;
67
- width: min(70%, 20rem);
68
- height: auto;
69
- margin-inline: auto;
70
- }
71
-
72
- .stack {
73
- flex-direction: column;
74
- gap: clamp(1.5rem, calc(1.5rem + 1vw), 2rem);
75
- text-align: center;
76
- }
77
-
78
- .copy {
79
- flex-direction: column;
80
- gap: 1rem;
81
- align-items: center;
82
- }
83
-
84
- .copy > * {
85
- max-width: 50ch;
86
- }
87
-
88
- h1 {
89
- font-size: clamp(
90
- var(--sl-text-3xl),
91
- calc(0.25rem + 5vw),
92
- var(--sl-text-6xl)
93
- );
94
- line-height: var(--sl-line-height-headings);
95
- font-weight: 600;
96
- color: var(--sl-color-white);
97
- }
98
-
99
- .tagline {
100
- font-size: clamp(
101
- var(--sl-text-base),
102
- calc(0.0625rem + 2vw),
103
- var(--sl-text-xl)
104
- );
105
- color: var(--sl-color-gray-2);
106
- }
107
-
108
- .actions {
109
- gap: 1rem 2rem;
110
- flex-wrap: wrap;
111
- justify-content: center;
112
- }
113
-
114
- @media (min-width: 50rem) {
115
- .hero {
116
- grid-template-columns: 7fr 4fr;
117
- gap: 3%;
118
- padding-block: clamp(2.5rem, calc(1rem + 10vmin), 10rem);
119
- }
120
-
121
- .hero > img,
122
- .hero > .hero-html {
123
- order: 2;
124
- width: min(100%, 25rem);
125
- }
126
-
127
- .stack {
128
- text-align: start;
129
- }
130
-
131
- .copy {
132
- align-items: flex-start;
133
- }
134
-
135
- .actions {
136
- justify-content: flex-start;
137
- }
138
- }
52
+ .hero {
53
+ display: grid;
54
+ align-items: center;
55
+ gap: 1rem;
56
+ padding-bottom: 1rem;
57
+ }
58
+
59
+ .hero > img,
60
+ .hero > .hero-html {
61
+ object-fit: contain;
62
+ width: min(70%, 20rem);
63
+ height: auto;
64
+ margin-inline: auto;
65
+ }
66
+
67
+ .stack {
68
+ flex-direction: column;
69
+ gap: clamp(1.5rem, calc(1.5rem + 1vw), 2rem);
70
+ text-align: center;
71
+ }
72
+
73
+ .copy {
74
+ flex-direction: column;
75
+ gap: 1rem;
76
+ align-items: center;
77
+ }
78
+
79
+ .copy > * {
80
+ max-width: 50ch;
81
+ }
82
+
83
+ h1 {
84
+ font-size: clamp(var(--sl-text-3xl), calc(0.25rem + 5vw), var(--sl-text-6xl));
85
+ line-height: var(--sl-line-height-headings);
86
+ font-weight: 600;
87
+ color: var(--sl-color-white);
88
+ }
89
+
90
+ .tagline {
91
+ font-size: clamp(var(--sl-text-base), calc(0.0625rem + 2vw), var(--sl-text-xl));
92
+ color: var(--sl-color-gray-2);
93
+ }
94
+
95
+ .actions {
96
+ gap: 1rem 2rem;
97
+ flex-wrap: wrap;
98
+ justify-content: center;
99
+ }
100
+
101
+ @media (min-width: 50rem) {
102
+ .hero {
103
+ grid-template-columns: 7fr 4fr;
104
+ gap: 3%;
105
+ padding-block: clamp(2.5rem, calc(1rem + 10vmin), 10rem);
106
+ }
107
+
108
+ .hero > img,
109
+ .hero > .hero-html {
110
+ order: 2;
111
+ width: min(100%, 25rem);
112
+ }
113
+
114
+ .stack {
115
+ text-align: start;
116
+ }
117
+
118
+ .copy {
119
+ align-items: flex-start;
120
+ }
121
+
122
+ .actions {
123
+ justify-content: flex-start;
124
+ }
125
+ }
139
126
  </style>