arcjet / arcjet-docs

Arcjet's documentation.
https://docs.arcjet.com
Creative Commons Attribution 4.0 International
9 stars 2 forks source link

Architecture redesign #55

Open blaine-arcjet opened 2 months ago

blaine-arcjet commented 2 months ago

As I was working on the bots docs revamp, I thought about some wants for the new architecture. We can all contribute on this issue.

davidmytton commented 2 months ago

Good list! We're using Starlight by Astro which has some interesting features we could take more advantage of. Some comments:

blaine-arcjet commented 2 months ago

That was a specific decision to allow us to use syntax checking, formatting, etc as if they were real code examples to avoid errors. The downside is you have to bundle all the dependencies in the repo. I'm also not sure how well it will work with other languages as we move on from JS.

I was actually thinking about this over the weekend and you touched on it a bit. I think we should type check with TypeScript only as a lint (and the same for compiling/linting with any other language). This would allow us to still build and preview the docs before the SDKs are released.

morekid commented 2 months ago

I've explored a layout considering the points discussed, you can see all the mocks here. Let me know if this covers everything UX wise and your feedback in general, eg: if you'd like to see some specific use cases.

As for the content duplication, I need to investigate the implementation a bit to see what's possible and how to tackle it. Starting on this now.

morekid commented 2 months ago

I've setup a docs branch that uses the Starlight Versions plugin. To make it work I had to move all non-mdx files outside the docs/ collection and adjust the referenced import paths (needed to be absolute) and asset paths (needed to be relative).

Even with these changes the plugin is not a complete solution as it ignores everything else, eg: the content in the newly created snippets/ folder is not versioned, which for us would be a requisite. We could move the snippets back into the content but they'd have to be wrapped in .mdx. Also worth mentioning that assets are versioned to their immediate parent which might or might not be desirable.

I couldn't test the search locally.

Also couldn't find an easy way to customize the placement of the version banners and switcher that appear when the plugin is installed.

Custom versioning

We could implement our own versioning script. This would create a version folder in content/docs/ and copy over all files. Then run though each file and for any referenced asset create a copy into a versioned folder and update the path so that it links to the versioned resource.

Even with this in place we'd still need to handle the versioned sidebar, pagination, search, ... .


Some useful content:


Edit 1: Official workaround for multiple sidebars using component overrides.

morekid commented 2 months ago

Alternative https://mintlify.com/

davidmytton commented 2 months ago

In our discussion yesterday we came to the conclusion that the versioning plugin wasn't a good enough solution because it didn't add much and was difficult to customize. We also discussed the idea of branching, but I think that would be too difficult to manage in GitHub and figuring out the deploys - see also the problems mentioned at https://github.com/withastro/starlight/discussions/957#discussioncomment-7407797

Mintlify has versioning, but I'm reluctant to use a commercial product for a core part of the Arcjet product experience (looks like it could get expensive as well).

We're limited by Starlight's sidebar. We'd could develop our own dynamic sidebar based on the selected version using component overrides. This could be based on placing content in subdirectories, but we could also use frontmatter in the MDX to query the relevant pages.

morekid commented 2 months ago

Apologies for the lengthy comment, I did my test of Mintlify:

Then specifically on features:

There's surely more to test but I don't feel that the product is advanced enough for our use case or without relying on their support extensively. Plus it's expensive.


I explored the code from the Starlight Versions plugin, the main pain points in functionality remain the ability to version snippets and the difficulty in visual customization. We could get around the former by manually versioning our snippets (and using paths accordingly), and I could design around the latter to make it work. So perhaps not an option to ditch necessarily.


Branch versioning

@davidmytton curious to know what you think of this approach.

see also the problems mentioned at https://github.com/withastro/starlight/discussions/957#discussioncomment-7407797

I don't necessarily agree with these points:

  1. Versioning is a maintenance burden regardless and both folder and branch based have pros and cons in this respect. Something to consider is that with folder based the repo can become big and unwieldy in a short span of versions.
  2. A theme/template left behind visually can actually be a feature where people are not disoriented by the new changes and can navigate the docs they know from the version they're using. I see that as an advantage where we can decide to update past versions of the docs or not. Whereas with folders, the template will always need to take into account past versions which might limit us in making bolder updates later on.
blaine-arcjet commented 2 months ago

From another issue we have:

When Next.js has a warning or an error, it often includes a link to a page in their documentation (e.g. https://nextjs.org/docs/messages/prerender-error). We should design a similar system in our docs where we can link to an individual page that explains the warning/error and suggested fixes. Also, these URLs should be short and clean (e.g. not linking to a heading).

morekid commented 2 months ago

Find the exploration for displaying the page content dynamically https://github.com/arcjet/arcjet-docs/pull/82.

blaine-arcjet commented 1 month ago

I think it might be worth exploring the Content Layer API, which is currently an experimental API but would give us the flexibility to build the collections we need.