Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "./constants" specifier in "@astrojs/starlight" package #1161

Closed
1 task
kdheepak opened this issue Nov 28, 2023 · 2 comments
Closed
1 task

Missing "./constants" specifier in "@astrojs/starlight" package #1161

kdheepak opened this issue Nov 28, 2023 · 2 comments

Comments

@kdheepak
Copy link

What version of starlight are you using?

0.13.1

What version of astro are you using?

3.2.3

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Firefox

Describe the Bug

I guess this is more of a question than a bug report.

I was trying to override the Hero component with a component that had the following frontmatter:

---
import { Image } from "astro:assets";
import { PAGE_TITLE_ID } from "@astrojs/starlight/constants";
import type { Props } from "@astrojs/starlight/props";
import CallToAction from "@astrojs/starlight/components/CallToAction.astro";
...

but wasn't able to import PAGE_TITLE_ID. Is that expected?

image

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.
@HiDeoo
Copy link
Member

HiDeoo commented Nov 28, 2023

Thanks for your report.

but wasn't able to import PAGE_TITLE_ID. Is that expected?

Indeed, at the moment this is not possible. This is tracked in this issue and more spefically this comment which contains a section regarding constants:

Maybe we take a similar approach and expose constants on the route data objects as well to avoid documenting the extra export? I agree that it’s useful to have this exposed — I already had to use _top without the constant in a docs example.

The only workaround at the moment to use the hardcoded string _top for now.

Note that depending on your need, it's also possible to re-use the <Hero/> component built-in with Starlight in your component override so that you don't have to re-implement it from scratch and would not have this issue but it depends on your use case and what you want to achieve.

@kdheepak
Copy link
Author

Note that depending on your need, it's also possible to re-use the component built-in with Starlight in your component override so that you don't have to re-implement it from scratch and would not have this issue but it depends on your use case and what you want to achieve.

Good idea! I wanted to change the layout of the Hero component and I assume that the only way was to reimplement it. I have hardcoded _top for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants