@astrojs/starlight 0.25.1 → 0.25.3

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,25 @@
1
1
  # @astrojs/starlight
2
2
 
3
+ ## 0.25.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2154](https://github.com/withastro/starlight/pull/2154) [`0b381d5`](https://github.com/withastro/starlight/commit/0b381d53f23c31492cf415057d960f9a5eaa2f3d) Thanks [@mktbsh](https://github.com/mktbsh)! - Updates `<head>` logic to deduplicate `<link rel="canonical">` tags. This means that custom canonicals set via frontmatter now override the default canonical generated by Starlight.
8
+
9
+ - [#2157](https://github.com/withastro/starlight/pull/2157) [`6757d97`](https://github.com/withastro/starlight/commit/6757d97b0ae789e0c61a776ad9af742858c663b0) Thanks [@astrobot-houston](https://github.com/astrobot-houston)! - Updates file tree icon mapping to correctly map `.cjs` and `.mjs` extensions in several contexts
10
+
11
+ - [#2156](https://github.com/withastro/starlight/pull/2156) [`904ad47`](https://github.com/withastro/starlight/commit/904ad47ea9588c0b1d8c583f3f04e4ae199474d9) Thanks [@delucis](https://github.com/delucis)! - Fixes builds for projects with a space in their pathname
12
+
13
+ - [#2137](https://github.com/withastro/starlight/pull/2137) [`703903b`](https://github.com/withastro/starlight/commit/703903bb782c3fabd3fe914e40494c00f12ec945) Thanks [@cevdetardaharan](https://github.com/cevdetardaharan)! - Removes `twitter:title` and `twitter:description` meta tags from `<head>`
14
+
15
+ ## 0.25.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#2126](https://github.com/withastro/starlight/pull/2126) [`ada51ee`](https://github.com/withastro/starlight/commit/ada51ee1500d07c1819059f57e97dc6e97b4d2ba) Thanks [@essential-randomness](https://github.com/essential-randomness)! - Adds support for markdown formatting in aside titles
20
+
21
+ - [#2135](https://github.com/withastro/starlight/pull/2135) [`9bbb969`](https://github.com/withastro/starlight/commit/9bbb9690616f79a80f3d286082b2500457bbcae9) Thanks [@oluwatobiss](https://github.com/oluwatobiss)! - Adds Pinterest social icon
22
+
3
23
  ## 0.25.1
4
24
 
5
25
  ### Patch Changes
@@ -1,6 +1,8 @@
1
1
  import { expect, testFactory } from './test-utils';
2
2
 
3
- const test = await testFactory('./fixtures/custom-src-dir/');
3
+ // This fixture contains a space in the directory so that we have a smoke test for building
4
+ // Starlight projects with pathnames like this, which are a common source of bugs.
5
+ const test = await testFactory('./fixtures/custom src-dir/');
4
6
 
5
7
  test('builds a custom page using the `<StarlightPage>` component and a custom `srcDir`', async ({
6
8
  page,
@@ -48,8 +48,6 @@ const headDefaults: z.input<ReturnType<typeof HeadConfigSchema>> = [
48
48
  tag: 'meta',
49
49
  attrs: { name: 'twitter:card', content: 'summary_large_image' },
50
50
  },
51
- { tag: 'meta', attrs: { name: 'twitter:title', content: data.title } },
52
- { tag: 'meta', attrs: { name: 'twitter:description', content: description } },
53
51
  ];
54
52
 
55
53
  if (description)
@@ -125,6 +125,8 @@ export const BuiltInIcons = {
125
125
  '<path d="M12.102 0h-.081C5.462 0 .13 5.252.001 11.779v.012L.007 24l12.097-.01c6.582-.055 11.897-5.404 11.897-11.995S18.686.056 12.109 0h-.005zM12 18.857h-.015a6.778 6.778 0 0 1-2.94-.666l.041.018-4.345 1.077 1.227-4.018a6.78 6.78 0 0 1-.83-3.27A6.86 6.86 0 1 1 12 18.857z"/>',
126
126
  zulip:
127
127
  '<path d="M21 19c0 1.7-1.2 3-2.7 3H5.7C4.2 22 3 20.7 3 19a3 3 0 0 1 1.2-2.4l6.7-6c0-.1.3 0 .2.2l-2.5 5s0 .2.2.2h9.5c1.5 0 2.7 1.4 2.7 3Zm0-14a3 3 0 0 1-1.2 2.4l-6.7 6c0 .1-.2 0-.2-.2l2.5-5s0-.2-.2-.2H5.7C4.2 8 3 6.6 3 5c0-1.7 1.2-3 2.7-3h12.6C19.8 2 21 3.3 21 5Z"/>',
128
+ pinterest:
129
+ '<path d="M12 0a12 12 0 0 0-4.4 23.1c0-.9-.2-2.4 0-3.4l1.5-6s-.4-.7-.4-1.7c0-1.7 1-3 2.2-3 1 0 1.5.8 1.5 1.7 0 1-.6 2.6-1 4-.3 1.2.6 2.2 1.8 2.2 2.1 0 3.8-2.2 3.8-5.5 0-2.8-2-4.9-5-4.9a5.2 5.2 0 0 0-5.4 5.2c0 1 .3 2.2.8 2.8.1.1.2.2.1.3l-.3 1.4c0 .2-.2.3-.4.2-1.5-.7-2.4-3-2.4-4.7C4.4 8 7 4.5 12.3 4.5c4.1 0 7.4 3 7.4 6.9 0 4.1-2.6 7.4-6.3 7.4-1.2 0-2.3-.6-2.7-1.3l-.8 2.8c-.2 1-1 2.4-1.5 3.2A12 12 0 1 0 12 0z"/>',
128
130
  astro:
129
131
  '<path d="M7.233 15.856c-.456 1.5-.132 3.586.948 4.57v-.036l.036-.096c.132-.636.648-1.032 1.309-1.008.612.012.96.336 1.044 1.044.036.264.036.528.048.803v.084c0 .6.168 1.176.504 1.68.3.48.72.851 1.284 1.103l-.024-.048-.024-.096c-.42-1.26-.12-2.135.984-2.879l.336-.227.745-.492a3.647 3.647 0 0 0 1.536-2.603c.06-.456 0-.9-.132-1.331l-.18.12c-1.668.887-3.577 1.2-5.425.84-1.117-.169-2.197-.48-3-1.416l.011-.012ZM2 15.592s3.205-1.559 6.421-1.559l2.437-7.508c.084-.36.348-.6.648-.6.3 0 .552.24.648.612l2.425 7.496c3.816 0 6.421 1.56 6.421 1.56L15.539.72c-.144-.444-.42-.72-.768-.72H8.24c-.348 0-.6.276-.768.72L2 15.592Z"/>',
130
132
  alpine: '<path d="m18.7 6 5.3 5.3-5.3 5.3-5.4-5.3L18.7 6zM5.3 6l11 11H5.8L0 11.2 5.3 6z"/>',
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { AstroConfig, AstroIntegration, AstroUserConfig } from 'astro';
4
4
  import { h as _h, s as _s, type Properties } from 'hastscript';
5
- import type { Node, Paragraph as P, Parent, Root } from 'mdast';
5
+ import type { Node, Paragraph as P, Parent, PhrasingContent, Root } from 'mdast';
6
6
  import {
7
7
  type Directives,
8
8
  directiveToMarkdown,
@@ -10,6 +10,7 @@ import {
10
10
  type LeafDirective,
11
11
  } from 'mdast-util-directive';
12
12
  import { toMarkdown } from 'mdast-util-to-markdown';
13
+ import { toString } from 'mdast-util-to-string';
13
14
  import remarkDirective from 'remark-directive';
14
15
  import type { Plugin, Transformer } from 'unified';
15
16
  import { visit } from 'unist-util-visit';
@@ -156,16 +157,16 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> {
156
157
  // prop to <Aside>, so when we find a directive label, we store it for the title prop and
157
158
  // remove the paragraph from the container’s children.
158
159
  let title = t(`aside.${variant}`);
160
+ let titleNode: PhrasingContent[] = [{ type: 'text', value: title }];
159
161
  const firstChild = node.children[0];
160
162
  if (
161
163
  firstChild?.type === 'paragraph' &&
162
164
  firstChild.data &&
163
- 'directiveLabel' in firstChild.data
165
+ 'directiveLabel' in firstChild.data &&
166
+ firstChild.children.length > 0
164
167
  ) {
165
- const firstGrandChild = firstChild.children[0];
166
- if (firstGrandChild?.type === 'text') {
167
- title = firstGrandChild.value;
168
- }
168
+ titleNode = firstChild.children;
169
+ title = toString(firstChild.children);
169
170
  // The first paragraph contains a directive label, we can safely remove it.
170
171
  node.children.splice(0, 1);
171
172
  }
@@ -189,7 +190,7 @@ function remarkAsides(options: AsidesOptions): Plugin<[], Root> {
189
190
  },
190
191
  iconPaths[variant]
191
192
  ),
192
- { type: 'text', value: title },
193
+ ...titleNode,
193
194
  ]),
194
195
  h('section', { class: 'starlight-aside__content' }, node.children),
195
196
  ]
@@ -19,8 +19,15 @@ export function vitePluginStarlightUserConfig(
19
19
  build: Pick<AstroConfig['build'], 'format'>;
20
20
  }
21
21
  ): NonNullable<ViteUserConfig['plugins']>[number] {
22
- const resolveId = (id: string) =>
23
- JSON.stringify(id.startsWith('.') ? resolve(fileURLToPath(root), id) : id);
22
+ /**
23
+ * Resolves module IDs to a usable format:
24
+ * - Relative paths (e.g. `'./module.js'`) are resolved against `base` and formatted as an absolute path.
25
+ * - Package identifiers (e.g. `'module'`) are returned unchanged.
26
+ *
27
+ * By default, `base` is the project root directory.
28
+ */
29
+ const resolveId = (id: string, base = root) =>
30
+ JSON.stringify(id.startsWith('.') ? resolve(fileURLToPath(base), id) : id);
24
31
 
25
32
  const virtualComponentModules = Object.fromEntries(
26
33
  Object.entries(opts.components).map(([name, path]) => [
@@ -50,7 +57,7 @@ export function vitePluginStarlightUserConfig(
50
57
  : 'export const logos = {};',
51
58
  'virtual:starlight/collection-config': `let userCollections;
52
59
  try {
53
- userCollections = (await import('${new URL('./content/config.ts', srcDir).pathname}')).collections;
60
+ userCollections = (await import(${resolveId('./content/config.ts', srcDir)})).collections;
54
61
  } catch {}
55
62
  export const collections = userCollections;`,
56
63
  ...virtualComponentModules,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/starlight",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
4
4
  "description": "Build beautiful, high-performance documentation websites with Astro",
5
5
  "keywords": [
6
6
  "docs",
@@ -195,6 +195,7 @@
195
195
  "hastscript": "^9.0.0",
196
196
  "mdast-util-directive": "^3.0.0",
197
197
  "mdast-util-to-markdown": "^2.1.0",
198
+ "mdast-util-to-string": "^4.0.0",
198
199
  "pagefind": "^1.0.3",
199
200
  "rehype": "^13.0.1",
200
201
  "rehype-format": "^5.0.0",
package/schemas/social.ts CHANGED
@@ -32,6 +32,7 @@ export const socialLinks = [
32
32
  'blueSky',
33
33
  'discourse',
34
34
  'zulip',
35
+ 'pinterest',
35
36
  ] as const;
36
37
 
37
38
  export const SocialLinksSchema = () =>
@@ -79,6 +80,7 @@ export const SocialLinksSchema = () =>
79
80
  blueSky: 'BlueSky',
80
81
  discourse: 'Discourse',
81
82
  zulip: 'Zulip',
83
+ pinterest: 'Pinterest',
82
84
  }[key];
83
85
  labelledLinks[key] = { label, url };
84
86
  }
@@ -44,6 +44,8 @@ export const definitions: Definitions = {
44
44
  COMMIT_EDITMSG: 'seti:git',
45
45
  MERGE_MSG: 'seti:git',
46
46
  'karma.conf.js': 'seti:karma',
47
+ 'karma.conf.cjs': 'seti:karma',
48
+ 'karma.conf.mjs': 'seti:karma',
47
49
  'karma.conf.coffee': 'seti:karma',
48
50
  'README.md': 'seti:info',
49
51
  'README.txt': 'seti:info',
@@ -74,6 +76,7 @@ export const definitions: Definitions = {
74
76
  'WORKSPACE.bazel': 'seti:bazel',
75
77
  'bower.json': 'seti:bower',
76
78
  'Bower.json': 'seti:bower',
79
+ 'eslint.config.js': 'seti:eslint',
77
80
  'firebase.json': 'seti:firebase',
78
81
  geckodriver: 'seti:firefox',
79
82
  'Gruntfile.js': 'seti:grunt',
@@ -91,22 +94,28 @@ export const definitions: Definitions = {
91
94
  'sass-lint.yml': 'seti:sass',
92
95
  'stylelint.config.js': 'seti:stylelint',
93
96
  'stylelint.config.cjs': 'seti:stylelint',
97
+ 'stylelint.config.mjs': 'seti:stylelint',
94
98
  'yarn.clean': 'seti:yarn',
95
99
  'yarn.lock': 'seti:yarn',
96
100
  'webpack.config.js': 'seti:webpack',
97
101
  'webpack.config.cjs': 'seti:webpack',
102
+ 'webpack.config.mjs': 'seti:webpack',
98
103
  'webpack.config.ts': 'seti:webpack',
99
104
  'webpack.config.build.js': 'seti:webpack',
100
105
  'webpack.config.build.cjs': 'seti:webpack',
106
+ 'webpack.config.build.mjs': 'seti:webpack',
101
107
  'webpack.config.build.ts': 'seti:webpack',
102
108
  'webpack.common.js': 'seti:webpack',
103
109
  'webpack.common.cjs': 'seti:webpack',
110
+ 'webpack.common.mjs': 'seti:webpack',
104
111
  'webpack.common.ts': 'seti:webpack',
105
112
  'webpack.dev.js': 'seti:webpack',
106
113
  'webpack.dev.cjs': 'seti:webpack',
114
+ 'webpack.dev.mjs': 'seti:webpack',
107
115
  'webpack.dev.ts': 'seti:webpack',
108
116
  'webpack.prod.js': 'seti:webpack',
109
117
  'webpack.prod.cjs': 'seti:webpack',
118
+ 'webpack.prod.mjs': 'seti:webpack',
110
119
  'webpack.prod.ts': 'seti:webpack',
111
120
  'npm-debug.log': 'seti:npm_ignored',
112
121
  },
@@ -218,8 +227,16 @@ export const definitions: Definitions = {
218
227
  '.properties': 'seti:java',
219
228
  '.js': 'seti:javascript',
220
229
  '.js.map': 'seti:javascript',
230
+ '.cjs': 'seti:javascript',
231
+ '.cjs.map': 'seti:javascript',
232
+ '.mjs': 'seti:javascript',
233
+ '.mjs.map': 'seti:javascript',
221
234
  '.spec.js': 'seti:javascript',
235
+ '.spec.cjs': 'seti:javascript',
236
+ '.spec.mjs': 'seti:javascript',
222
237
  '.test.js': 'seti:javascript',
238
+ '.test.cjs': 'seti:javascript',
239
+ '.test.mjs': 'seti:javascript',
223
240
  '.es': 'seti:javascript',
224
241
  '.es5': 'seti:javascript',
225
242
  '.es6': 'seti:javascript',
package/utils/head.ts CHANGED
@@ -12,7 +12,7 @@ export function createHead(defaults: HeadUserConfig, ...heads: HeadConfig[]) {
12
12
  }
13
13
 
14
14
  /**
15
- * Test if a head config object contains a matching `<title>` or `<meta>` tag.
15
+ * Test if a head config object contains a matching `<title>` or `<meta>` or `<link rel="canonical">` tag.
16
16
  *
17
17
  * For example, will return true if `head` already contains
18
18
  * `<meta name="description" content="A">` and the passed `tag`
@@ -25,6 +25,8 @@ function hasTag(head: HeadConfig, entry: HeadConfig[number]): boolean {
25
25
  return head.some(({ tag }) => tag === 'title');
26
26
  case 'meta':
27
27
  return hasOneOf(head, entry, ['name', 'property', 'http-equiv']);
28
+ case 'link':
29
+ return head.some(({ attrs }) => attrs.rel === 'canonical');
28
30
  default:
29
31
  return false;
30
32
  }