-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
[V2] Versioning Suggestions #2302
Comments
For item 3 above, I would like to see a hook that provides current version and a list of all versions:
I wrote something workable in my Lunr search plugin by using the |
Do you have different Check the Discord post at the bottom from 02/14/2020: https://discordapp.com/channels/398180168688074762/632470883058843648 |
@BoMiddleton yes, I have all of that set up and working. The problem is that the links in the top navbar only point to the most recent version, rather than whatever version the user is currently looking at. Additionally, I can't display different pages depending on the version (unless I parse the URL, which is rather complicated) |
I don't think "pages" should be versioned. I think the idea of "pages" is different from "docs", which has a completely different requirement. If "pages" are versioned, then the following pages become very confusing:
You'll have to maintain a separate list of pages that should be versioned and should not be versioned. Pretty soon this is going to get out of control... Since this thread is about versioning in V2, then I think in your case you can write a custom react component and add that into a doc as part of normal mdx syntax. |
That sounds like a bug. That doesn't happen in V1 |
@Animas I agree we shouldn't have versioned pages, but I would love for there to be a way to fetch the current version inside a page, using something like |
I agree with this too. Just to be clear, I think you meant fetching the current version inside a "doc", not a page since... we're saying pages shouldn't be versioned and in that case, a page doesn't really have a context of what version you're looking at right now. |
We will add the |
@lex111 let me know if there's anything I can do to help |
@nebrelbug well, if you want to implement a similar hook and create the corresponding PR - it would be very very cool 😃 |
I'll take a look, but I wouldn't be able to do any work until Friday 😄. I would enjoy contributing though -- though I've found several bugs and given feedback, I have yet to earn the |
@nebrelbug These are hard problems you've mentioned.
We don't intend to add support for this. Versioning shall be a docs-only feature. Notice that the current versioned docs path is The current docs design is a little flawed. We allow for multiple doc plugins but the versioning approach and commands assume only one docs plugin. In future we should have a namespace for each set of docs, which you define as options passed into the docs plugin. So |
Some things worth mentioning: one deployment per versionIf your docusaurus site changes too much across versions and having only docs versioned is a problme, you could also handle the versioning outside of docusaurus, with separate immutable deployments. This is the strategy of the ReactJS website. This strategy gives the opportunity to affect current version without the risk of breaking something that worked on an older version. useVersion() can only work in docs/sidebar compsThere's currently no concept of "global current version", only docs/sidebar version. On global pages like /live-editor or /contact, there's no version in the url, so we don't know what is the version. At most, we could store the last version browsed by the user in some kind of storage, but that seems hacky (probably possible in userland). global site dependenciesIf you have a live editor like react-live somewhere in the app, in 5 different versions, it's unlikely you'll be able to provide your lib's code in the editor scope for the 5 different lib versions (it might be possible with yarn resolution to load a lib in 2 different versions). It might be better to publish the live playground as a separate app, and integrate it in your doc. For example you could use a unique page, with tabs to select the playground version, and load an iframe or something. If this tab system is annoying, you can also create a versioned doc on which you embed the playground iframe thanks to MDX. |
@slorber I use NPM/Yarn package aliases (https://stackoverflow.com/questions/26414587/how-to-install-multiple-versions-of-package-using-npm) on https://squirrelly.js.org/playground along with tabs to allow users to choose the version of the playground, which means I don't have to use an iframe. |
I'd personally also love a version hook, so bump to this! Also, are there any plans to implement versioning of assets like images, as mentioned here in #1257? |
Bumping this because we desperately need simple versioning ❤️ |
@krillboi that's something I'd like to add. Will see how we could add a provider on top of a whole version. @bravo-kernel what is simple versioning to you? What's missing that you need in D2? |
Awesome @slorber. I have tried to explain this on multiple occasions and always failed to get it across. Perhaps this real world example will work: First the situation:
What we would like:
What we do not want
Hope that makes sense. If you have any additional questions please let me know |
Do you still update v4 docs? If not, you could simply create a docs-v4 branch, deploy it to netlify as a non-versioned D2 deployment, like If you want v4 and v5 as the same unified SPA under same domain: as far as I understand, what you would like is to have IE somehow it's a workflow where you have already released v5 + v5 initial doc, but you still do a lot of documentation work, so that you don't yet want to copy these files to the versioned folder? This feature makes sense to me, we could allow to configure |
Exactly, this:
|
And updates to the v4 would then have to be done in |
☝️ This doesn't quite make sense to me, to be honest. I find it a bit confusing when I read that config. From the example that @bravo-kernel mentioned, my understanding is "v5" is their "next version" if it's not fully completed yet or there isn't a "next version" after v5 (as of right now). So, the existing setup/process/workflow of Docusaurus still make sense to me. Maybe it's just a matter of being able to "label" the next release. That way, in the versioning page/list, "next release" is named "v5" instead of hard coded to "master/unreleased". So, technically you're not creating the "v5" version in Docusaurus, because it's still "in-progress". Not sure if that helps but thought I'd put it out there. I like simplicity and hopefully Docusaurus V2 features does not become over-complicated due to multitude of options that becomes hard to maintain down the road. |
I have a little caveat to add. Let's say I have 3 versions: 1.0, 2.0 and 3.0. This would produce links following this structure:
The problem now arises with 3.0. Since this is current stable version, you will access the introduction doc with simply Now I release 3.0 where Not sure if that was clear enough but TLDR: all versions should have a corresponding link to its version, also if it happens to be current version. |
As much as I understand that most examples and caveats can be valid, they also show the complexity that we (as requesters of simple versioning) are trying to avoid. |
Hey everyone. I believe we already addressed some things of this issue.
There is an RFC here that should cover the issues related to /docs/next, /docs etc... let's move the conversation here but please let me know if you think something is not resolved. |
In case you are interested to check these "internal" hooks, see the DocsVersionNavbarItem.tsx component, which permit to display in the navbar the current version, with a fallback to the "latest version". As you see, it's not so straightforward to use as import React from 'react';
import DefaultNavbarItem from './DefaultNavbarItem';
import {useActiveVersion, useLatestVersion} from '@theme/hooks/useDocs';
const getVersionMainDoc = (version) =>
version.docs.find((doc) => doc.id === version.mainDocId);
export default function DocsVersionNavbarItem({
label: staticLabel,
to: staticTo,
docsPluginId,
...props
}) {
const activeVersion = useActiveVersion(docsPluginId);
const latestVersion = useLatestVersion(docsPluginId);
const version = activeVersion ?? latestVersion;
const label = staticLabel ?? version.label;
const path = staticTo ?? getVersionMainDoc(version).path;
return <DefaultNavbarItem {...props} label={label} to={path} />;
} Unless you use docs multi instance, docsPluginId="default" (undefined should work too) |
💥 Proposal
Hi! As I work on developing my Docusaurus site (https://squirrelly.js.org), I've noticed a few problems with the current versioning system.
docusaurus.config.js
isn't versioned. In my top bar, I link to different docs files. However, no matter what version I'm viewing, they always link to the latest docs (ex./docs/
instead ofdocs/some-version/
).alpha.43
, no matter what version you're currently viewing.With these problems in mind, I'd suggest having a public version variable. This could be provided to MDX files, similarly to
withBaseUrl
. It would also be nice if you could, indocusaurus.config.js
, export a function that accepted a version string as the parameter.Have you read the Contributing Guidelines on issues?
Yes
The text was updated successfully, but these errors were encountered: