Skip to content

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Mar 26, 2025

Description

This PR is a very early draft adding support for Iconify and local icons in Starlight.

The early draft PR is opened to provide some material for discussions and also evaluate potential changes in involved libraries. A lot of work, including more robust implementations for some parts, more tests, and documentation, is still needed.

Preview test page: https://deploy-preview-3024--astro-starlight.netlify.app/test/

SCR-20250326-pxwk

Implementation

Most of the implementation relies on the Astro Icon library, altho Starlight does not only uses icons through components but also in different contexts, e.g. remark plugins.

A few high-level details about the implementation:

  • No breaking changes are introduced for existing icons. Starlight's built-in icons are still available and can be used as before.
  • Starlight does not ship with any Iconify icon set (built-in icons are still part of Starlight and not transformed in an Iconify icon set).
  • Users can choose to install any Iconify icon set they want to use.
  • Everywhere a built-in icon can be used, an Iconify or local icon can be used as well.
  • Custom aside icons is built upon Aside: Support custom icons #2261 (which should be merged first for credits), refactored to also support Iconify icons.

Astro Icon configuration

Astro Icon is an integration that supports various configuration options.

Just like expressiveCode, Astro Icon options are currently exposed using an icons (placeholder name) property in the Starlight configuration.

Astro Icon notes

Here are a few notes about Astro Icon that I gathered so far that I would like to discuss with the maintainers of the project (still need to put them in a more friendly format):

  • The issue regarding icon sets not being found when icon sets are part of a library:
    • This issue seems to be related to how installed icon sets are determined which was changed in this PR to fix other issues, e.g. different results with different package managers or when NODE_ENV is set to production.
    • This issue does not affect the current implementation as Starlight does not ship with any Iconify icon set and users have to install them themselves in their projects.
    • This could be an issue if a Starlight plugin decides to ship with an Iconify icon set and use it in its components.
    • I didn't spend enough time yet on the issue, but it seems like the previous approach may work by appending --prod=false to the list command from my initial and quick tests. Will need to investigate more.
  • When using the @iconify/utils helper loadCollectionFromFS() to load collections, by default this helper uses process.cwd() to load collections. Same goes for the importDirectory() helper in @iconify/tools used to load local icons.
    • This can be an issue in some cases, e.g. in Starlight E2E tests where the current working directory is not the project root.
    • This PR includes a patch to Astro Icon using an absolute path.
  • As Starlight uses icons in contexts where Astro Icon cannot be used, e.g. remark plugins, we also need to load local and Iconify icons in such contexts:
    • This PR ships (very) similar implementations to Astro Icon's Iconify and local icons loaders.

Remaining tasks

  • Address all remaining // TODO(HiDeoo) comments
  • Changesets covering all changes across all changed packages
    • @astrojs/starlight
    • @astrojs/starlight-markdoc
  • Remove some test files
    • docs/src/icons/test.svg
    • docs/src/content/docs/test.mdx
    • examples/markdoc/src/content/docs/test.mdoc
  • Uninstall @iconify-json/mdi from starlight-docs and @example/starlight-markdoc
  • Documentation
    • Very early draft documentation just to expose what changed and should definitely be improved
    • In a lot of places, we mention "one of Starlight’s built-in icons" with a link. The sentence should be updated (maybe "supported icons"?) and the link should be updated too if needed.
  • Merge Aside: Support custom icons #2261 before this PR

Copy link

changeset-bot bot commented Mar 26, 2025

⚠️ No Changeset found

Latest commit: 15abae3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added 📚 docs Documentation website changes 🌟 core Changes to Starlight’s main package 🌟 markdoc Changes to Starlight’s Markdoc package labels Mar 26, 2025
Copy link

netlify bot commented Mar 26, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 15abae3
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/67f01239effe6f00086afbd3
😎 Deploy Preview https://deploy-preview-3024--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@HiDeoo HiDeoo marked this pull request as draft March 26, 2025 17:26
@astrobot-houston
Copy link
Contributor

astrobot-houston commented Mar 26, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en components/asides.mdx Source changed, localizations will be marked as outdated.
en guides/authoring-content.mdx Source changed, localizations will be marked as outdated.
en reference/configuration.mdx Source changed, localizations will be marked as outdated.
en reference/icons.mdx Source changed, localizations will be marked as outdated.
en test.mdx Source added, will be tracked.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

HiDeoo added 3 commits April 3, 2025 10:26
* main: (43 commits)
  [ci] format
  i18n(ru): update some translations (withastro#3029)
  chore(deps): update zephyrproject-rtos/action-first-interaction digest to 5885399 (withastro#3027)
  [ci] release (withastro#3022)
  feat: add sourcehut as social option (withastro#3020)
  feat: Add Substack icon to social list (withastro#3013)
  [ci] format
  i18n(zh-cn): Update `overrides.md` and `overriding-components.mdx` (withastro#3006)
  [ci] format
  i18n(zh-cn): Update `i18n.mdx` and Update `plugins.md` (withastro#2940)
  i18n(ko-KR): update `ko.json` (withastro#3021)
  i18n(fr): update `resources/themes` (withastro#3019)
  [ci] format
  Update themes.mdx (withastro#3016)
  i18n(ko-KR): update `theme.mdx` (withastro#3015)
  Add starlight theme nova (withastro#3012)
  i18n(fr): update `reference/plugins.md` (withastro#3011)
  i18n(ko-KR): update `plugins.md` (withastro#3010)
  i18n(de): update `plugins.mdx` (withastro#3009)
  Fix code example in plugin reference (withastro#3005)
  ...
@HiDeoo HiDeoo changed the title Add support for Iconify icons Add support for custom icons Apr 4, 2025
@delucis delucis added the 🌟 minor Change that triggers a minor release label Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 core Changes to Starlight’s main package 📚 docs Documentation website changes 🌟 markdoc Changes to Starlight’s Markdoc package 🌟 minor Change that triggers a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants