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

fix: using wrong field to deconstruct in 'CallToAction' component #2182

Closed
wants to merge 2 commits into from

Conversation

hartmut-co-uk
Copy link

Description

Closes (no issue created)

What does this PR change?

  • Fixes what a bug to pass html attribs to the CallToAction component.
  • This allows to e.g. pass the class attribute <CallToAction class="px-1">...</CallToAction>

Note: I'm actually not sure if the Prop interface definition is correct (attrs?: Omit<HTMLAttributes<'a'>, 'href'> | undefined;) or what the purpose for this is?!?

Copy link

changeset-bot bot commented Aug 9, 2024

🦋 Changeset detected

Latest commit: 2abab7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Aug 9, 2024
Copy link

netlify bot commented Aug 9, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 2abab7e
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/66b6542d1759dd0008a11688
😎 Deploy Preview https://deploy-preview-2182--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: 92 (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.

@astrobot-houston
Copy link
Collaborator

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@hartmut-co-uk hartmut-co-uk changed the title fix: using wrong field to deconstruct fix: using wrong field to deconstruct in 'CallToAction' component Aug 9, 2024
@delucis
Copy link
Member

delucis commented Aug 9, 2024

Hi @hartmut-co-uk! Thanks for the PR.

I believe this code is working as expected. You can pass extra attributes using the attrs prop to actions (including class if you want) as shown in the reference for the hero frontmatter property. Here’s an example with a custom class for each action:

---
title: My Home Page
hero:
  title: 'My project with custom action appearance'
  actions:
    - text: Tell me more
      link: /getting-started/
      attrs:
        class: more-link
    - text: View on GitHub
      link: https://github.com/astronaut/my-project
      attrs:
        class: github-link
---

If you still believe there to be a bug please open an issue with a reproduction so we have a bit more context on what is not working.

@delucis delucis closed this Aug 9, 2024
@hartmut-co-uk
Copy link
Author

OK, thanks Understood @delucis!
I'm re-using the component elsewhere and based on the example provided the following also works for me:

<CallToAction attrs={{class: "minimal"}} link="/abc/">...</CallToAction>

@delucis
Copy link
Member

delucis commented Aug 11, 2024

Ah cool, yes that’s not officially supported yet, but the experience will be improved once we merge #1784 — which removes CallToAction in favour of a proper <LinkButton> component.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants