@astrojs/starlight 0.35.3 → 0.36.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/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3427](https://github.com/withastro/starlight/pull/3427) [`c3b2d0f`](https://github.com/withastro/starlight/commit/c3b2d0fc37bb9b7b6abc6c11b760a4114690ccd4) Thanks [@delucis](https://github.com/delucis)! - Fixes styling of labels that wrap across multiple lines in `<Tabs>` component
8
+
9
+ ⚠️ **Potentially breaking change:** Tab labels now have a narrower line-height and additional vertical padding. If you have custom CSS targetting the `<Tabs>` component, you may want to double check the visual appearance of your tabs when updating.
10
+
11
+ If you want to preserve the previous styling, you can add the following custom CSS to your site:
12
+
13
+ ```css
14
+ .tab > [role='tab'] {
15
+ line-height: var(--sl-line-height);
16
+ padding-block: 0;
17
+ }
18
+ ```
19
+
20
+ - [#3380](https://github.com/withastro/starlight/pull/3380) [`3364af3`](https://github.com/withastro/starlight/commit/3364af31e535d62ee7b045e6d9cf97c7e58df981) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Makes head entry parsing stricter in Starlight config and content frontmatter.
21
+
22
+ **⚠️ Potentially breaking change:** Previously Starlight would accept a head entry for a `meta` tag defining some `content` which generates invalid HTML as `<meta>` is a void element which cannot have any child nodes. Now, it is an error to define a `meta` tag including some `content`.
23
+
24
+ If you see errors after updating, look for head entries in the Starlight configuration in the `astro.config.mjs` file or in the frontmatter of your content files that include a `content` property for a `meta` tag. To fix the error, move the `content` property to the `attrs` object with at least an additional attribute to identify the kind of metadata it represents:
25
+
26
+ ```diff
27
+ head: {
28
+ tag: 'meta',
29
+ - content: 'foo',
30
+ attrs: {
31
+ name: 'my-meta',
32
+ + content: 'foo',
33
+ },
34
+ },
35
+ ```
36
+
37
+ - [#3340](https://github.com/withastro/starlight/pull/3340) [`2018c31`](https://github.com/withastro/starlight/commit/2018c31b0f559d51478bfbf9f12cfba76b4e74fc) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds missing vertical spacing between Markdown content and UI Framework components using [client directives](https://docs.astro.build/en/reference/directives-reference/#client-directives).
38
+
39
+ **⚠️ Potentially breaking change:** By default, Starlight applies some vertical spacing (`--sl-content-gap-y`) between Markdown content blocks. This change introduces similar spacing between Markdown content blocks and UI Framework components using client directives which was not present before.
40
+
41
+ If you were relying on the previous behavior, you can manually override the spacing by manually specifying the top margin on the component using [custom CSS](https://starlight.astro.build/guides/css-and-tailwind/#custom-css-styles), e.g. by relying on a CSS class to target the component.
42
+
43
+ ```css
44
+ .my-custom-component {
45
+ margin-top: 0;
46
+ }
47
+ ```
48
+
49
+ ### Patch Changes
50
+
51
+ - [#3423](https://github.com/withastro/starlight/pull/3423) [`a0d0670`](https://github.com/withastro/starlight/commit/a0d0670bce5827b90fd0102fa3517814367760e7) Thanks [@andersk](https://github.com/andersk)! - Fixes HTML validity in sidebar groups by ensuring `<summary>` is the first child of `<details>`
52
+
3
53
  ## 0.35.3
4
54
 
5
55
  ### Patch Changes
@@ -37,7 +37,6 @@ const { sublist, nested } = Astro.props;
37
37
  <details
38
38
  open={flattenSidebar(entry.entries).some((i) => i.isCurrent) || !entry.collapsed}
39
39
  >
40
- <SidebarRestorePoint />
41
40
  <summary>
42
41
  <span class="group-label">
43
42
  <span class="large">{entry.label}</span>
@@ -51,6 +50,7 @@ const { sublist, nested } = Astro.props;
51
50
  </span>
52
51
  <Icon name="right-caret" class="caret" size="1.25rem" />
53
52
  </summary>
53
+ <SidebarRestorePoint />
54
54
  <Astro.self sublist={entry.entries} nested />
55
55
  </details>
56
56
  )}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.35.3",
3
+ "version": "0.36.0",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
package/schema.ts CHANGED
@@ -30,7 +30,7 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
30
30
  editUrl: z.union([z.string().url(), z.boolean()]).optional().default(true),
31
31
 
32
32
  /** Set custom `<head>` tags just for this page. */
33
- head: HeadConfigSchema(),
33
+ head: HeadConfigSchema({ source: 'content' }),
34
34
 
35
35
  /** Override global table of contents configuration for this page. */
36
36
  tableOfContents: TableOfContentsSchema().optional(),
package/schemas/head.ts CHANGED
@@ -1,16 +1,47 @@
1
1
  import { z } from 'astro/zod';
2
+ import yaml from 'js-yaml';
2
3
 
3
- export const HeadConfigSchema = () =>
4
+ export const HeadConfigSchema = ({
5
+ source,
6
+ }: {
7
+ /**
8
+ * Depending on the content being validated, either a user's config or a page's frontmatter,
9
+ * different error messages will be shown.
10
+ */
11
+ source: 'config' | 'content';
12
+ }) =>
4
13
  z
5
14
  .array(
6
- z.object({
7
- /** Name of the HTML tag to add to `<head>`, e.g. `'meta'`, `'link'`, or `'script'`. */
8
- tag: z.enum(['title', 'base', 'link', 'style', 'meta', 'script', 'noscript', 'template']),
9
- /** Attributes to set on the tag, e.g. `{ rel: 'stylesheet', href: '/custom.css' }`. */
10
- attrs: z.record(z.union([z.string(), z.boolean(), z.undefined()])).optional(),
11
- /** Content to place inside the tag (optional). */
12
- content: z.string().optional(),
13
- })
15
+ z
16
+ .object({
17
+ /** Name of the HTML tag to add to `<head>`, e.g. `'meta'`, `'link'`, or `'script'`. */
18
+ tag: z.enum(['title', 'base', 'link', 'style', 'meta', 'script', 'noscript', 'template']),
19
+ /** Attributes to set on the tag, e.g. `{ rel: 'stylesheet', href: '/custom.css' }`. */
20
+ attrs: z.record(z.union([z.string(), z.boolean(), z.undefined()])).optional(),
21
+ /** Content to place inside the tag (optional). */
22
+ content: z.string().optional(),
23
+ })
24
+ .superRefine((config, ctx) => {
25
+ if (config.tag !== 'meta' || config.content === undefined) return;
26
+ const { content, ...rest } = config;
27
+ const correctTag = {
28
+ ...rest,
29
+ attrs: { ...(config.attrs ?? { name: 'identifier' }), content: config.content },
30
+ };
31
+ const code =
32
+ source === 'config' ? JSON.stringify(correctTag, null, 2) : yaml.dump([correctTag]);
33
+ ctx.addIssue({
34
+ code: 'custom',
35
+ message:
36
+ `The \`head\` configuration includes a \`meta\` tag with \`content\` which is invalid HTML.\n` +
37
+ `You should instead use a \`content\` attribute ` +
38
+ (Object.keys(rest.attrs ?? {}).length === 0
39
+ ? 'with an additional attribute such as `name`, `property`, or `http-equiv` to identify the kind of metadata it represents '
40
+ : '') +
41
+ `in the \`attrs\` object:\n\n` +
42
+ code,
43
+ });
44
+ })
14
45
  )
15
46
  .default([]);
16
47
 
@@ -2,7 +2,15 @@
2
2
  .sl-markdown-content
3
3
  :not(a, strong, em, del, span, input, code, br)
4
4
  + :not(a, strong, em, del, span, input, code, br, :where(.not-content *)) {
5
- margin-top: 1rem;
5
+ margin-top: var(--sl-content-gap-y);
6
+ }
7
+
8
+ /* Vertical spacing between Markdown content blocks and UI Framework components using client directives. */
9
+ .sl-markdown-content
10
+ :not(a, strong, em, del, span, input, code, br)
11
+ + :is(astro-island, astro-slot)
12
+ > :not(a, strong, em, del, span, input, code, br, :where(.not-content *)):first-child {
13
+ margin-top: var(--sl-content-gap-y);
6
14
  }
7
15
 
8
16
  /* Headings after non-headings have more spacing. */
package/style/props.css CHANGED
@@ -101,6 +101,7 @@
101
101
  --sl-sidebar-pad-x: 1rem;
102
102
  --sl-content-width: 45rem;
103
103
  --sl-content-pad-x: 1rem;
104
+ --sl-content-gap-y: 1rem;
104
105
  --sl-main-pad: 0 0 3vh 0;
105
106
  --sl-menu-button-size: 2rem;
106
107
  --sl-nav-gap: var(--sl-content-pad-x);
@@ -115,13 +115,15 @@ if (isSynced) {
115
115
  }
116
116
 
117
117
  .tab {
118
+ display: flex;
118
119
  margin-bottom: -2px;
119
120
  }
120
121
  .tab > [role='tab'] {
121
122
  display: flex;
122
123
  align-items: center;
123
124
  gap: 0.5rem;
124
- padding: 0 1.25rem;
125
+ line-height: var(--sl-line-height-headings);
126
+ padding: 0.275rem 1.25rem;
125
127
  text-decoration: none;
126
128
  border-bottom: 2px solid var(--sl-color-gray-5);
127
129
  color: var(--sl-color-gray-3);
package/utils/head.ts CHANGED
@@ -7,7 +7,7 @@ import { fileWithBase } from './base';
7
7
  import { formatCanonical } from './canonical';
8
8
  import { localizedUrl } from './localizedUrl';
9
9
 
10
- const HeadSchema = HeadConfigSchema();
10
+ const HeadSchema = HeadConfigSchema({ source: 'content' });
11
11
 
12
12
  /** Get the head for the current page. */
13
13
  export function getHead(
@@ -149,7 +149,7 @@ const UserConfigSchema = z.object({
149
149
  * ],
150
150
  * })
151
151
  */
152
- head: HeadConfigSchema(),
152
+ head: HeadConfigSchema({ source: 'config' }),
153
153
 
154
154
  /**
155
155
  * Provide CSS files to customize the look and feel of your Starlight site.