Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/beige-ties-scream.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion docs/src/components/icons-list.astro
Original file line number Diff line number Diff line change
@@ -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?: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Comment thread
delucis marked this conversation as resolved.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/starlight/components/ContentNotice.astro
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/components/MobileTableOfContents.astro
Original file line number Diff line number Diff line change
@@ -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;
---
Expand Down Expand Up @@ -109,7 +109,7 @@ const { toc } = Astro.locals.starlightRoute;
</style>

<script>
import { StarlightTOC } from './TableOfContents/starlight-toc';
import { StarlightTOC } from '../components-internals/TableOfContents/starlight-toc';

class MobileStarlightTOC extends StarlightTOC {
override set current(link: HTMLAnchorElement) {
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/components/Page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (pagefindEnabled) mainDataAttributes['data-pagefind-body'] = '';
<PageFrame>
<Header slot="header" />
{starlightRoute.hasSidebar && <Sidebar slot="sidebar" />}
<script src="./SidebarPersistState"></script>
<script src="../components-internals/SidebarPersistState"></script>
<TwoColumnContent>
<PageSidebar slot="right-sidebar" />
<main
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/components/TableOfContents.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import TableOfContentsList from './TableOfContents/TableOfContentsList.astro';
import TableOfContentsList from '../components-internals/TableOfContents/TableOfContentsList.astro';

const { toc } = Astro.locals.starlightRoute;
---
Expand All @@ -15,4 +15,4 @@ const { toc } = Astro.locals.starlightRoute;
)
}

<script src="./TableOfContents/starlight-toc"></script>
<script src="../components-internals/TableOfContents/starlight-toc"></script>
2 changes: 1 addition & 1 deletion packages/starlight/integrations/asides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
137 changes: 1 addition & 136 deletions packages/starlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*",
Comment thread
delucis marked this conversation as resolved.
"./internal": "./internal.ts",
"./props": "./props.ts",
"./schema": "./schema.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/schemas/icon.ts
Original file line number Diff line number Diff line change
@@ -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[]];

Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 1 addition & 1 deletion packages/starlight/user-components/Aside.astro
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/Card.astro
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/Icon.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { Icons, type StarlightIcon } from '../components/Icons';
import { Icons, type StarlightIcon } from '../components-internals/Icons';

interface Props {
name: StarlightIcon;
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/LinkButton.astro
Original file line number Diff line number Diff line change
@@ -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<HTMLAttributes<'a'>, 'href'> {
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/TabItem.astro
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/rehype-file-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight/user-components/rehype-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading