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

Docs versioning #298

Merged
merged 27 commits into from
Oct 26, 2021
Merged

Docs versioning #298

merged 27 commits into from
Oct 26, 2021

Conversation

kylegach
Copy link
Collaborator

@kylegach kylegach commented Oct 6, 2021

Description

Add versioning to Storybook docs.

  • Via Netlify's branch deploys, build an instance of the docs portion of the site referencing specific versions from the monorepo.
  • Use Netlify's redirects to proxy the versioned URL to the branch build and Netlify's headers to prevent non-latest pages from being indexed by search engines.
  • Update URLs throughout to include version (unless latest)
    • Ensure relative links, canonical URLs, and social graph images are not broken
  • Add a version selector control to the docs sidebar to allow switching between these versions.
  • When not viewing latest docs, add a banner pointing to the latest version.
  • Other minor changes
    • Remove version from Header
    • Remove "v" prefix from latestVersion
    • Only build addons pages when referencing latest version

Note: This first attempt at the feature will only support a single "next" version. Once we decide on a convention for multiple "next" versions in the monorepo, I can extend the code here to support those, too (in a future PR).

Screenshot

Docs page showing the version in the url, version selector in the sidebar, and version callout above the content
Note: The messaging in the callout above the content is subject to change.

How to Test

  1. Check Chromatic tests
  2. Run the site locally (yarn start & yarn build)
    • Ensure the correct version of docs is built and you can navigate fully
      • Keep in mind the redirects won't work
  3. Run the site locally with a reference branch specified (BRANCH=next yarn start, same for build)
    • Ensure the correct version of docs is built and you can navigate fully
      • Keep in mind the redirects won't work
  4. Ensure that yarn extract-monorepo-docs and yarn link-monorepo-docs still work, with their various arguments
  5. Triple-check anything SEO-related (redirect generation code, canonical URLs, headers), please 😉

TODO

  • Ensure algolia search works w/ and w/o versions
    • Fairly sure it works w/o
    • They provided a path for versioning support, but will wait until we get on their latest beta release
  • Create release-6-0, release-6-1, and release-6-2 branches from their release/*.* counterparts in monorepo

After merging...

  • Create branches in this repo
    • release-6-0, release-6-1, release-6-2
  • Add branches to Netlify build settings

- Makes for easier comparisons to other versions
- Get version from mapping of current branch to SB monorepo branch
- Add current version to FrameworkSelector
@kylegach kylegach changed the title [WIP] Remove version from Header [WIP] Docs versioning Oct 8, 2021
@kylegach kylegach force-pushed the docs-versioning branch 2 times, most recently from ed97294 to 83d065c Compare October 8, 2021 15:52
@domyen
Copy link
Member

domyen commented Oct 12, 2021

@domyen to design a banner to point to the latest version

@kylegach kylegach force-pushed the docs-versioning branch 2 times, most recently from e720a86 to 09c591b Compare October 15, 2021 12:58
gatsby-node.js Outdated
}

let versions;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I need access to this inside onPostBuild, but it's created with data that (I think) is only available inside createPages. So mutating the value is how I share it across closures. Have a better idea?

const { BRANCH } = process.env;
let versionFromBranch;
const nextVersion = shortenVersion(nextVersionFull);
const NEXT_BRANCH = 'next';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to build this in a way that could (eventually) support more than one "next" version. But because we need all available versions ahead of time, we need to know which branches from which to grab those versions, so the 'next' portion has to be hard-coded. Supporting, e.g. 'next-minor' & 'next-major' will require refactoring.

@@ -0,0 +1,14 @@
#!/bin/bash -
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If there's a better way to do this, I'm all ears.

I noticed https://github.com/storybookjs/storybook/blob/next/docs/versions/next.json, but when we're extracting docs from the main branch, the version is incorrect (for our usage, at least): https://github.com/storybookjs/storybook/blob/main/docs/versions/next.json.

site-metadata.js Outdated
@@ -18,7 +18,8 @@ const siteMetadata = {
ogImageAddons: '/images/social/og-addons.png',
siteUrl: homepageUrl, // Used for gatsby-plugin-sitemap
googleSiteVerification: '_OxxMv1o0aRcxPfieLW0BRsMxxIzkpA9Vv6O0AB5xg0',
latestVersion: 'v6.3',
latestVersion: '6.3', // TODO: Could get this from monorepo...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if that's worth another curl (assuming there's not a better way), but pulling this from the monorepo would remove a step from the process to document another version.

@kylegach
Copy link
Collaborator Author

@domyen to design a banner to point to the latest version

@domyen — This is nearly the only thing remaining. Remember that the header changes coming with the Component Catalog work will likely affect the placement.

Even a rough sketch just demonstrating visual placement would be helpful for me to get started. Thanks!

- Build versions list from filtered releases edges
- Preserve relative links
Broken:
- Breaks on branch names like "release/6.2"
    - SB monorepo convention

- BRANCH is a Netlify convention
- Ensure branch names other than "next" and "release/*" extract docs from monorepo's main branch
- Can also use locally
- Was `release/6.2`, which caused character escaping problems
- Store in `context.versions`
- "Stable" and "Pre-release"
@kylegach kylegach marked this pull request as ready for review October 20, 2021 14:46
@kylegach kylegach changed the title [WIP] Docs versioning Docs versioning Oct 20, 2021
@domyen
Copy link
Member

domyen commented Oct 20, 2021

Can we re-order the versions so that the latest appears as the top?

Current:

  • 6.0
  • 6.1
  • 6.2

Proposed:

  • 6.2
  • 6.1.
  • 6.0

@kylegach
Copy link
Collaborator Author

Can we re-order the versions so that the latest appears as the top?

Current:

* 6.0

* 6.1

* 6.2

Proposed:

* 6.2

* 6.1.

* 6.0

Yep. That makes sense now that we have a separate section for pre-release(s). 👍

Copy link
Contributor

@winkerVSbecks winkerVSbecks left a comment

Choose a reason for hiding this comment

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

LGTM the only open issue for me is regarding SB version in the header.

@@ -18,7 +18,8 @@ const siteMetadata = {
ogImageAddons: '/images/social/og-addons.png',
siteUrl: homepageUrl, // Used for gatsby-plugin-sitemap
googleSiteVerification: '_OxxMv1o0aRcxPfieLW0BRsMxxIzkpA9Vv6O0AB5xg0',
latestVersion: 'v6.3',
latestVersion: 6.3, // TODO: Could get this from monorepo...
Copy link
Contributor

Choose a reason for hiding this comment

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

We use this latestVersion in the header for frontpage, blog and tutorials. Like so:

CleanShot 2021-10-20 at 15 03 26@2x

It looks like we don't do that on frontpage any more. Should the other sites be updated to match this? cc: @domyen

Copy link
Contributor

Choose a reason for hiding this comment

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

We actually grab the version from this file in the blog and tutorials repo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oof. Had no idea other repos were referencing this property.

@winkerVSbecks
Copy link
Contributor

@domyen @kylegach I'm a little concerned that I haven't been able to green build after 5 tries. Doing that for every branch after rebasing is going to be a major concern.

Should we split the addon catalog into its own repo along with this change? That's where the instability comes from.

@winkerVSbecks
Copy link
Contributor

There was actually a bug, pushed a fix for it.

@kylegach
Copy link
Collaborator Author

There was actually a bug, pushed a fix for it.

@winkerVSbecks — 🤦‍♂️ Thank you!

- Use pre-release label instead of "New" in VersionCTA badge
- Reword messages in VersionCTA
- Sort-by-newest in VersionSelector
- Remove VersionSelectorTitle styled component
- Move versions list generation into `buildVersions`
- Refactor shape of versions list
@kylegach
Copy link
Collaborator Author

All comments addressed except for the use of latestVersion in other repos (#298 (comment)). If someone can provide me a list of places to check, I can look into that. When I search our GitHub org for "latestVersion" or "site-metadata", I only see results in this repo and in the monorepo.

@winkerVSbecks
Copy link
Contributor

@kylegach these ones:

@kylegach
Copy link
Collaborator Author

Should we split the addon catalog into its own repo along with this change? That's where the instability comes from.

As I understand it, the primary reason this wasn't done initially was shared components between Addon Catalog and the rest of frontpage. We'll be pulling those components into the design system, so that we can use them for https://github.com/storybookjs/component-catalog. At which point, extracting Addon Catalog into its own repo should be relatively straightforward.

kylegach added a commit to chromaui/learnstorybook.com that referenced this pull request Oct 22, 2021
- storybookjs/frontpage#298 updates `latestVersion` to be a number
- As this project pulls the value from that one, it needs to support either format (at least temporarily)
@kylegach
Copy link
Collaborator Author

kylegach commented Oct 22, 2021

@kylegach these ones:

* https://github.com/chromaui/blog

* https://github.com/chromaui/learnstorybook.com

I created PRs in each to support either latestVersion format remove latestVersion from their Headers:

@domyen — We only removed the latest version from the Header of frontpage because it was redundant with the selector in the sidebar. So I kept it in the other projects, which don't have the selector. Let me know if that's the correct choice.

kylegach added a commit to chromaui/learnstorybook.com that referenced this pull request Oct 25, 2021
@kylegach kylegach merged commit d5fda3d into master Oct 26, 2021
@kylegach kylegach deleted the docs-versioning branch October 26, 2021 18:41
kylegach added a commit that referenced this pull request Oct 26, 2021
This was referenced Oct 28, 2021
@kylegach kylegach mentioned this pull request Nov 4, 2021
3 tasks
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