Skip to content

Commit 4295b29

Browse files
committed
fixup!
1 parent 1b38c51 commit 4295b29

5 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/generators/legacy-html-all/generate.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export async function generate(input) {
4949

5050
const templateValues = {
5151
api: 'all',
52+
path: 'all',
5253
added: '',
5354
section: 'All',
5455
version: `v${config.version.version}`,

src/generators/legacy-html/generate.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export async function processChunk(slicedInput, itemIndices, navigation) {
5656

5757
const template = {
5858
api: head.api,
59+
path: head.path,
5960
added: head.introduced_in ?? '',
6061
section: head.heading.data.name || apiAsHeading,
6162
toc,

src/generators/legacy-html/utils/buildDropdowns.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export const buildNavigation = navigationContents =>
4848
* Note.: We use plain strings here instead of HAST, since these are just
4949
* templates and not actual content that needs to be transformed.
5050
*
51-
* @param {string} api The current API node name
51+
* @param {string} path The current API node name
5252
* @param {string} added The version the API was added
5353
* @param {Array<import('../../../parsers/types').ReleaseEntry>} versions All available Node.js releases
5454
*/
55-
export const buildVersions = (api, added, versions) => {
55+
export const buildVersions = (path, added, versions) => {
5656
const config = getConfig('legacy-html');
5757

5858
const compatibleVersions = getCompatibleVersions(added, versions);
@@ -64,7 +64,7 @@ export const buildVersions = (api, added, versions) => {
6464

6565
const ltsLabel = isLts ? '<b>LTS</b>' : '';
6666

67-
return `<li><a href="${getVersionURL(parsedVersion, api, config.baseURL)}">${parsedVersion} ${ltsLabel}</a></li>`;
67+
return `<li><a href="${getVersionURL(parsedVersion, path, config.baseURL)}">${parsedVersion} ${ltsLabel}</a></li>`;
6868
});
6969

7070
return (

src/generators/legacy-html/utils/replaceTemplateValues.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
*/
2323
export const replaceTemplateValues = (
2424
apiTemplate,
25-
{ api, added, section, toc, nav, content },
25+
{ path, api, added, section, toc, nav, content },
2626
config,
2727
{ skipGitHub = false, skipGtocPicker = false } = {}
2828
) => {
@@ -36,11 +36,11 @@ export const replaceTemplateValues = (
3636
.replace('__CONTENT__', content)
3737
.replace(/__TOC_PICKER__/g, buildToC(toc))
3838
.replace(/__GTOC_PICKER__/g, skipGtocPicker ? '' : buildNavigation(nav))
39-
.replace('__ALTDOCS__', buildVersions(api, added, config.changelog))
39+
.replace('__ALTDOCS__', buildVersions(path, added, config.changelog))
4040
.replace(
4141
'__EDIT_ON_GITHUB__',
4242
skipGitHub
4343
? ''
44-
: buildGitHub(`${populate(GITHUB_EDIT_URL, config)}${api}.md`)
44+
: buildGitHub(`${populate(GITHUB_EDIT_URL, config)}${path}.md`)
4545
);
4646
};

src/utils/file.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const writeFile = (file, ...args) =>
2626
* @returns {string}
2727
*/
2828
export const href = (to, from) => {
29+
if (to.includes('://')) {
30+
return to;
31+
}
32+
2933
const a = to.split('/').filter(Boolean);
3034
const b = from.split('/').slice(0, -1).filter(Boolean);
3135

0 commit comments

Comments
 (0)