HiDeoo / starlight-blog

Starlight plugin to add a blog to your documentation
https://starlight-blog-docs.vercel.app
MIT License
106 stars 10 forks source link

Integration of a Persistent Navigation Link between Blog and Documentation Sections #50

Open bjorne84 opened 2 weeks ago

bjorne84 commented 2 weeks ago

Is your feature request related to a problem?

Yes, it's related to navigation issues within the site.

Describe the solution you'd like

I would like a feature where a persistent navigation link or button is available that connects the blog section directly back to the documentation/wiki part of the site. This could be a simple "Back to Documentation" button or a more integrated navigational element in the site's header or sidebar.

Describe alternatives you've considered

No response

Additional Context

No response

HiDeoo commented 1 week ago

Thanks for the feedback, super appreciated :raised_hands:

This is definitely an area that I want to improve in the plugin but I have not yet figured out what would be the best way to do it:

I am open to suggestions and feedback on this topic but until then, this is something that could be achieved using a Starlight override for the ThemeSelect component.

This is the component overriden by the blog plugin to add the link to the blog at the right of the header and by providing your own override, you would be able to have control over the link or add one for the documentation.

Just like the blog plugin override, you own override will need to reuse the built-in ThemeSelect component after adding your own custom links which would change based on the current route.

An example of the override could look like this:

---
import Default from '@astrojs/starlight/components/ThemeSelect.astro'
import type { Props } from '@astrojs/starlight/props'

const isBlog = Astro.props.slug.startsWith('blog')
---

<div>
  <a href="/">Docs</a>
  <a href="/blog/">Blog</a>
</div>
<Default {...Astro.props}><slot /></Default>

<style>
  div {
    border-inline-end: 1px solid var(--sl-color-gray-5);
    display: none;
    gap: var(--sl-nav-gap);
    padding-inline-end: 1rem;
  }

  @media (min-width: 50rem) {
    div {
      display: flex;
    }
  }

  a {
    color: var(--sl-color-text-accent);
    font-weight: 600;
    text-decoration: none;
  }
</style>
bjorne84 commented 5 days ago

Great, I think your example override works fine for desktop and for mobile just a simple link link in the Sidebar, just as the existing override adds a link to the blog if its not a blog !isBlog && (

)

About the configuration, well a true/false to show the link or not and label text,