-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
151 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Generates the prefix to be used for a version's URL. The prefix will typically consist of the docs repo's | ||
* set prefix, with the new version appended at the end. | ||
* | ||
* Use this when the target URL needs to point to a version | ||
* of the docs site that does not use the same exact path prefix (i.e. an aliased docs site needs its exact URL slug). | ||
* @param {string} version The version to include at the end of the prefix. | ||
* @param {string} siteBasePrefix The current docs site's base prefix to append the version to. | ||
*/ | ||
export const generateVersionedPrefix = (version, siteBasePrefix) => { | ||
return `/${siteBasePrefix}/${version}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { generatePrefix } from '../components/VersionDropdown/utils'; | ||
import { assertTrailingSlash } from './assert-trailing-slash'; | ||
import { DOTCOM_BASE_URL } from './base-url'; | ||
import { generateVersionedPrefix } from './generate-versioned-prefix'; | ||
import { localizePath } from './locale'; | ||
|
||
export const getUrl = (branchUrlSlug, project, siteMetadata, siteBasePrefix, slug) => { | ||
export const getUrl = (branchUrlSlug, project, siteBasePrefix, slug) => { | ||
if (branchUrlSlug === 'legacy') { | ||
// Avoid trailing slash to ensure query param remains valid | ||
const legacyPath = localizePath(`/docs/legacy/?site=${project}`); | ||
return DOTCOM_BASE_URL + legacyPath; | ||
} | ||
const prefixWithVersion = generatePrefix(branchUrlSlug, siteMetadata, siteBasePrefix); | ||
const prefixWithVersion = generateVersionedPrefix(branchUrlSlug, siteBasePrefix); | ||
return assertTrailingSlash(localizePath(`${prefixWithVersion}/${slug}`)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.