diff --git a/.changeset/beige-ties-scream.md b/.changeset/beige-ties-scream.md new file mode 100644 index 00000000000..587b74de16a --- /dev/null +++ b/.changeset/beige-ties-scream.md @@ -0,0 +1,7 @@ +--- +'@astrojs/starlight': minor +--- + +Fixes autocomplete for components exported from `@astrojs/starlight/components/*` + +**⚠️ Potentially breaking change:** This change moves some files used in Starlight’s component internals out of the `components/` directory. Direct use of these files was not and is not officially supported. If you previously imported `TableOfContents/starlight-toc.ts`, `TableOfContents/TableOfContentsList.astro`, `Icons.ts`, or `SidebarPersistState.ts`, please review your code when updating. diff --git a/docs/src/components/icons-list.astro b/docs/src/components/icons-list.astro index e0e37a98207..1ae9ca5074a 100644 --- a/docs/src/components/icons-list.astro +++ b/docs/src/components/icons-list.astro @@ -1,6 +1,6 @@ --- import { Icon } from '@astrojs/starlight/components'; -import { Icons, type StarlightIcon } from '../../../packages/starlight/components/Icons'; +import { Icons, type StarlightIcon } from '../../../packages/starlight/components-internals/Icons'; interface Props { labels?: { diff --git a/packages/starlight/__tests__/remark-rehype/rehype-file-tree.test.ts b/packages/starlight/__tests__/remark-rehype/rehype-file-tree.test.ts index 5c94c7e5c82..30364306774 100644 --- a/packages/starlight/__tests__/remark-rehype/rehype-file-tree.test.ts +++ b/packages/starlight/__tests__/remark-rehype/rehype-file-tree.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; import { processFileTree } from '../../user-components/rehype-file-tree'; -import { Icons, type StarlightIcon } from '../../components/Icons'; +import { Icons, type StarlightIcon } from '../../components-internals/Icons'; describe('validation', () => { test('throws an error with no content', () => { diff --git a/packages/starlight/components/Icons.ts b/packages/starlight/components-internals/Icons.ts similarity index 100% rename from packages/starlight/components/Icons.ts rename to packages/starlight/components-internals/Icons.ts diff --git a/packages/starlight/components/SidebarPersistState.ts b/packages/starlight/components-internals/SidebarPersistState.ts similarity index 100% rename from packages/starlight/components/SidebarPersistState.ts rename to packages/starlight/components-internals/SidebarPersistState.ts diff --git a/packages/starlight/components/TableOfContents/TableOfContentsList.astro b/packages/starlight/components-internals/TableOfContents/TableOfContentsList.astro similarity index 100% rename from packages/starlight/components/TableOfContents/TableOfContentsList.astro rename to packages/starlight/components-internals/TableOfContents/TableOfContentsList.astro diff --git a/packages/starlight/components/TableOfContents/starlight-toc.ts b/packages/starlight/components-internals/TableOfContents/starlight-toc.ts similarity index 100% rename from packages/starlight/components/TableOfContents/starlight-toc.ts rename to packages/starlight/components-internals/TableOfContents/starlight-toc.ts diff --git a/packages/starlight/components/ContentNotice.astro b/packages/starlight/components/ContentNotice.astro index 28858f97810..da226887f6f 100644 --- a/packages/starlight/components/ContentNotice.astro +++ b/packages/starlight/components/ContentNotice.astro @@ -1,5 +1,5 @@ --- -import type { StarlightIcon } from '../components/Icons'; +import type { StarlightIcon } from '../components-internals/Icons'; import Icon from '../user-components/Icon.astro'; interface Props { diff --git a/packages/starlight/components/MobileTableOfContents.astro b/packages/starlight/components/MobileTableOfContents.astro index 13c4f8657b0..f9f5d590f95 100644 --- a/packages/starlight/components/MobileTableOfContents.astro +++ b/packages/starlight/components/MobileTableOfContents.astro @@ -1,6 +1,6 @@ --- import Icon from '../user-components/Icon.astro'; -import TableOfContentsList from './TableOfContents/TableOfContentsList.astro'; +import TableOfContentsList from '../components-internals/TableOfContents/TableOfContentsList.astro'; const { toc } = Astro.locals.starlightRoute; --- @@ -109,7 +109,7 @@ const { toc } = Astro.locals.starlightRoute; +
+ diff --git a/packages/starlight/integrations/asides.ts b/packages/starlight/integrations/asides.ts index d534d382618..f5ee07ce8b5 100644 --- a/packages/starlight/integrations/asides.ts +++ b/packages/starlight/integrations/asides.ts @@ -15,7 +15,7 @@ import type { Plugin, Transformer } from 'unified'; import { visit } from 'unist-util-visit'; import type { RemarkRehypePluginOptions } from './remark-rehype'; import type { StarlightIcon } from '../types'; -import { Icons } from '../components/Icons'; +import { Icons } from '../components-internals/Icons'; import { fromHtml } from 'hast-util-from-html'; import type { Element } from 'hast'; import { throwInvalidAsideIconError } from './asides-error'; diff --git a/packages/starlight/package.json b/packages/starlight/package.json index 09cd731ca10..f0ca3a6df1b 100644 --- a/packages/starlight/package.json +++ b/packages/starlight/package.json @@ -30,142 +30,7 @@ ".": "./index.ts", "./locals": "./locals.ts", "./components": "./components.ts", - "./components/LanguageSelect.astro": { - "types": "./components/LanguageSelect.astro.tsx", - "import": "./components/LanguageSelect.astro" - }, - "./components/Select.astro": { - "types": "./components/Select.astro.tsx", - "import": "./components/Select.astro" - }, - "./components/Banner.astro": { - "types": "./components/Banner.astro.tsx", - "import": "./components/Banner.astro" - }, - "./components/LastUpdated.astro": { - "types": "./components/LastUpdated.astro.tsx", - "import": "./components/LastUpdated.astro" - }, - "./components/Sidebar.astro": { - "types": "./components/Sidebar.astro.tsx", - "import": "./components/Sidebar.astro" - }, - "./components/MarkdownContent.astro": { - "types": "./components/MarkdownContent.astro.tsx", - "import": "./components/MarkdownContent.astro" - }, - "./components/SidebarPersister.astro": { - "types": "./components/SidebarPersister.astro.tsx", - "import": "./components/SidebarPersister.astro" - }, - "./components/SidebarSublist.astro": { - "types": "./components/SidebarSublist.astro.tsx", - "import": "./components/SidebarSublist.astro" - }, - "./components/ContentPanel.astro": { - "types": "./components/ContentPanel.astro.tsx", - "import": "./components/ContentPanel.astro" - }, - "./components/MobileMenuFooter.astro": { - "types": "./components/MobileMenuFooter.astro.tsx", - "import": "./components/MobileMenuFooter.astro" - }, - "./components/SiteTitle.astro": { - "types": "./components/SiteTitle.astro.tsx", - "import": "./components/SiteTitle.astro" - }, - "./components/EditLink.astro": { - "types": "./components/EditLink.astro.tsx", - "import": "./components/EditLink.astro" - }, - "./components/MobileMenuToggle.astro": { - "types": "./components/MobileMenuToggle.astro.tsx", - "import": "./components/MobileMenuToggle.astro" - }, - "./components/SkipLink.astro": { - "types": "./components/SkipLink.astro.tsx", - "import": "./components/SkipLink.astro" - }, - "./components/MobileTableOfContents.astro": { - "types": "./components/MobileTableOfContents.astro.tsx", - "import": "./components/MobileTableOfContents.astro" - }, - "./components/SocialIcons.astro": { - "types": "./components/SocialIcons.astro.tsx", - "import": "./components/SocialIcons.astro" - }, - "./components/FallbackContentNotice.astro": { - "types": "./components/FallbackContentNotice.astro.tsx", - "import": "./components/FallbackContentNotice.astro" - }, - "./components/DraftContentNotice.astro": { - "types": "./components/DraftContentNotice.astro.tsx", - "import": "./components/DraftContentNotice.astro" - }, - "./components/Page.astro": { - "types": "./components/Page.astro.tsx", - "import": "./components/Page.astro" - }, - "./components/StarlightPage.astro": { - "types": "./components/StarlightPage.astro.tsx", - "import": "./components/StarlightPage.astro" - }, - "./components/AnchorHeading.astro": { - "types": "./components/AnchorHeading.astro.tsx", - "import": "./components/AnchorHeading.astro" - }, - "./components/Footer.astro": { - "types": "./components/Footer.astro.tsx", - "import": "./components/Footer.astro" - }, - "./components/PageFrame.astro": { - "types": "./components/PageFrame.astro.tsx", - "import": "./components/PageFrame.astro" - }, - "./components/TableOfContents.astro": { - "types": "./components/TableOfContents.astro.tsx", - "import": "./components/TableOfContents.astro" - }, - "./components/Head.astro": { - "types": "./components/Head.astro.tsx", - "import": "./components/Head.astro" - }, - "./components/PageSidebar.astro": { - "types": "./components/PageSidebar.astro.tsx", - "import": "./components/PageSidebar.astro" - }, - "./components/ThemeProvider.astro": { - "types": "./components/ThemeProvider.astro.tsx", - "import": "./components/ThemeProvider.astro" - }, - "./components/Header.astro": { - "types": "./components/Header.astro.tsx", - "import": "./components/Header.astro" - }, - "./components/PageTitle.astro": { - "types": "./components/PageTitle.astro.tsx", - "import": "./components/PageTitle.astro" - }, - "./components/ThemeSelect.astro": { - "types": "./components/ThemeSelect.astro.tsx", - "import": "./components/ThemeSelect.astro" - }, - "./components/Hero.astro": { - "types": "./components/Hero.astro.tsx", - "import": "./components/Hero.astro" - }, - "./components/Pagination.astro": { - "types": "./components/Pagination.astro.tsx", - "import": "./components/Pagination.astro" - }, - "./components/TwoColumnContent.astro": { - "types": "./components/TwoColumnContent.astro.tsx", - "import": "./components/TwoColumnContent.astro" - }, - "./components/Search.astro": { - "types": "./components/Search.astro.tsx", - "import": "./components/Search.astro" - }, + "./components/*": "./components/*", "./internal": "./internal.ts", "./props": "./props.ts", "./schema": "./schema.ts", diff --git a/packages/starlight/schemas/icon.ts b/packages/starlight/schemas/icon.ts index 49462371fe0..90de556ce39 100644 --- a/packages/starlight/schemas/icon.ts +++ b/packages/starlight/schemas/icon.ts @@ -1,5 +1,5 @@ import { z } from 'astro/zod'; -import { Icons, type StarlightIcon } from '../components/Icons'; +import { Icons, type StarlightIcon } from '../components-internals/Icons'; const iconNames = Object.keys(Icons) as [StarlightIcon, ...StarlightIcon[]]; diff --git a/packages/starlight/types.ts b/packages/starlight/types.ts index c549ca8afd9..bce63617aec 100644 --- a/packages/starlight/types.ts +++ b/packages/starlight/types.ts @@ -4,4 +4,4 @@ export type { StarlightUserConfigWithPlugins as StarlightUserConfig, HookParameters, } from './utils/plugins'; -export type { StarlightIcon } from './components/Icons'; +export type { StarlightIcon } from './components-internals/Icons'; diff --git a/packages/starlight/user-components/Aside.astro b/packages/starlight/user-components/Aside.astro index 1c01bca6cd7..4ee70c21244 100644 --- a/packages/starlight/user-components/Aside.astro +++ b/packages/starlight/user-components/Aside.astro @@ -1,7 +1,7 @@ --- import { AstroError } from 'astro/errors'; import Icon from './Icon.astro'; -import { Icons, type StarlightIcon } from '../components/Icons'; +import { Icons, type StarlightIcon } from '../components-internals/Icons'; import { throwInvalidAsideIconError } from '../integrations/asides-error'; const asideVariants = ['note', 'tip', 'caution', 'danger'] as const; diff --git a/packages/starlight/user-components/Card.astro b/packages/starlight/user-components/Card.astro index 224db05b960..a3e77b8d507 100644 --- a/packages/starlight/user-components/Card.astro +++ b/packages/starlight/user-components/Card.astro @@ -1,6 +1,6 @@ --- import Icon from './Icon.astro'; -import type { StarlightIcon } from '../components/Icons'; +import type { StarlightIcon } from '../components-internals/Icons'; interface Props { icon?: StarlightIcon; diff --git a/packages/starlight/user-components/Icon.astro b/packages/starlight/user-components/Icon.astro index 16b24dee591..148c86e256f 100644 --- a/packages/starlight/user-components/Icon.astro +++ b/packages/starlight/user-components/Icon.astro @@ -1,5 +1,5 @@ --- -import { Icons, type StarlightIcon } from '../components/Icons'; +import { Icons, type StarlightIcon } from '../components-internals/Icons'; interface Props { name: StarlightIcon; diff --git a/packages/starlight/user-components/LinkButton.astro b/packages/starlight/user-components/LinkButton.astro index 6480c92f36c..2149359837e 100644 --- a/packages/starlight/user-components/LinkButton.astro +++ b/packages/starlight/user-components/LinkButton.astro @@ -1,6 +1,6 @@ --- import type { HTMLAttributes } from 'astro/types'; -import type { StarlightIcon } from '../components/Icons'; +import type { StarlightIcon } from '../components-internals/Icons'; import Icon from './Icon.astro'; interface Props extends Omit, 'href'> { diff --git a/packages/starlight/user-components/TabItem.astro b/packages/starlight/user-components/TabItem.astro index 0bd9fa6df54..0fa53d37e1b 100644 --- a/packages/starlight/user-components/TabItem.astro +++ b/packages/starlight/user-components/TabItem.astro @@ -1,6 +1,6 @@ --- import { TabItemTagname } from './rehype-tabs'; -import type { StarlightIcon } from '../components/Icons'; +import type { StarlightIcon } from '../components-internals/Icons'; interface Props { icon?: StarlightIcon; diff --git a/packages/starlight/user-components/rehype-file-tree.ts b/packages/starlight/user-components/rehype-file-tree.ts index 72f658a03c1..cc8ba431df6 100644 --- a/packages/starlight/user-components/rehype-file-tree.ts +++ b/packages/starlight/user-components/rehype-file-tree.ts @@ -6,7 +6,7 @@ import { fromHtml } from 'hast-util-from-html'; import { toString } from 'hast-util-to-string'; import { rehype } from 'rehype'; import { CONTINUE, SKIP, visit } from 'unist-util-visit'; -import { Icons, type StarlightIcon } from '../components/Icons'; +import { Icons, type StarlightIcon } from '../components-internals/Icons'; import { definitions } from './file-tree-icons'; declare module 'vfile' { diff --git a/packages/starlight/user-components/rehype-tabs.ts b/packages/starlight/user-components/rehype-tabs.ts index b989a81fda8..34194855f5d 100644 --- a/packages/starlight/user-components/rehype-tabs.ts +++ b/packages/starlight/user-components/rehype-tabs.ts @@ -2,7 +2,7 @@ import type { Element } from 'hast'; import { select } from 'hast-util-select'; import { rehype } from 'rehype'; import { CONTINUE, SKIP, visit } from 'unist-util-visit'; -import type { StarlightIcon } from '../components/Icons'; +import type { StarlightIcon } from '../components-internals/Icons'; interface Panel { panelId: string;