Skip to content

fix: add version information to default docs links #14205

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

Merged
merged 5 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor slightly
  • Loading branch information
bcpeinhardt committed Aug 8, 2024
commit 52d60dc40d935b9e92a72983c16feb3fc61363b5
9 changes: 7 additions & 2 deletions site/src/utils/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ function defaultDocsUrl(): string {
const docsUrl = "https://coder.com/docs";
// If we can get the specific version, we want to include that in default docs URL.
let version = getStaticBuildInfo()?.version;
if (!version) {
return docsUrl;
}

// Strip the postfix version info that's not part of the link.
const i = version?.indexOf("-") ?? -1;
if (version.index >= 0) {
if (i >= 0) {
version = version.slice(0, i);
}
return version ? `${docsUrl}/@${version}` : docsUrl;
return `${docsUrl}/@${version}`;
}

// Add cache to avoid DOM reading all the time
Expand Down
Loading