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

feat: dynamic docs content structure #82

Merged
merged 117 commits into from
Oct 17, 2024
Merged

Conversation

morekid
Copy link
Contributor

@morekid morekid commented Sep 19, 2024

This is the exploration for consolidating the page structure and adding the flexibility to show content based on framework.

Find the working example at /docs/rate-limiting/quick-start.

Things to note:

  • Everything under /docs uses the page layout at /src/pages/docs/[...slug].astro, which loads a custom sidebar. Besides multiple sidebars, this also adds the flexibility of further layout customization later on.
  • With this approach all frontmatter for each page will need to be generic and not dependent on the framework, and as such will be indexed for SEO. We can however customize the title/description content displayed on the page, although not always in a straightforward manner.
  • All titles need to be explicitly typed in the root page if we want them to be in the automatic page TOC on the right. This is why I'm adding them as <slots /> in a few cases. However this will always make them available for the TOC of any framework, which is also not desirable(see the multiple 4. ... links in the page. Haven't found a workaround for this yet, but can investigate more. The fallback is that we take it into account when writing the page content: framework dependent titles won't appear in the TOC.
  • It's feasible to explore a totally custom page TOC, replacing the one that Starlight ships with.
  • UPDATE: I've added a custom TOC component and collection schema scaffold to address the above. This is a proof of concept I can refine, but it's 99% there and I like that we can build the index as we like in the frontmatter for each page. It's still probably a good idea to add the titles as slots as it is currently so that we can always use markdown and the id attrs are automatically generated.
  • The non-docs prefixed URLs are still accessible so we might need to then redirect /* > /docs/*.
  • The code language preference is persisted when using Starlight's <Tabs /> built in syncKey prop.
  • This still doesn't handle linkable URLs based on framework, which in this approach should be done with params.

There's of course a considerable amount of manual work to port everything over the new approach.

Screen.Recording.2024-09-19.at.15.49.57.mov

Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
arcjet-docs ✅ Ready (Inspect) Visit Preview 1 resolved Oct 17, 2024 2:40pm

@morekid morekid mentioned this pull request Sep 19, 2024
@morekid
Copy link
Contributor Author

morekid commented Sep 23, 2024

cc @bendechrai

@morekid
Copy link
Contributor Author

morekid commented Sep 23, 2024

Added a custom TOC component approach.

@davidmytton
Copy link
Contributor

Concept looks good. Why do we have to have the /docs prefix? Seems redundant if we're at docs.arcjet.com ?

At https://arcjet-docs-3jr1p35n6-arcjet.vercel.app/docs/rate-limiting/quick-start I see multiple ordered list items in the TOC:

image

- more robust
- adds flexibility to specify different framework sets
- catch difference between displayed vs user-selected framework
@morekid
Copy link
Contributor Author

morekid commented Oct 16, 2024

@davidmytton added plugins for expressive code for collapsing sections and showing line numbers, I've also added the Aj code syntax theme.

You can test like so on a <Code /> component:

<Code
  ...
  mark={[1, {range: "3-6"}, {range: "8-12", label: "test"}]}
  ins={[{range: "13-15", label: "no"}]}
  del={[{range: "20"}]}
  collapse={"22-28"}
/>

@davidmytton
Copy link
Contributor

Code theme looks great! It only has dark mode though - is that right? Fine by me either way.

When you collapse the viewsize, the Next.js icon doesn't show properly in the theme switcher. The others do.

image

@morekid
Copy link
Contributor Author

morekid commented Oct 17, 2024

Code theme looks great! It only has dark mode though - is that right? Fine by me either way.

Yes, I don't have a light variant with expressive code atm, but everything in place and just needs some time to design/fill in the light theme vars. Regardless of whether the code stays dark in light mode it will still need brightness/contrast adjustments.

When you collapse the viewsize, the Next.js icon doesn't show properly in the theme switcher. The others do.

Yep, will fix.

Copy link
Contributor

@davidmytton davidmytton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morekid all the docs are migrated. Can you give it a final review and then it's ready to merge!

@morekid
Copy link
Contributor Author

morekid commented Oct 17, 2024

@davidmytton looks all good, fixed a few cosmetic issues + the Next.js icon rendering.

@morekid morekid mentioned this pull request Oct 17, 2024
@davidmytton davidmytton merged commit 50cac65 into main Oct 17, 2024
4 checks passed
@davidmytton davidmytton deleted the morekid/docs-architecture branch October 17, 2024 14:55
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

Successfully merging this pull request may close these issues.

3 participants