@@ -7,22 +7,20 @@ import type { GitHubApiFile } from '@/types';
77import { getGitHubApiDocsUrl } from '@/util/gitHubUtils' ;
88import { parseRichTextIntoPlainText } from '@/util/stringUtils' ;
99
10- const getPathnameForApiFile = ( name : string ) =>
11- `api/${ name . replace ( '.md' , '.html' ) } ` ;
10+ const getPathnameForApiFile = ( name : string , version : string ) =>
11+ `docs/ ${ version } / api/${ name . replace ( '.md' , '.html' ) } ` ;
1212
1313// This is the Route Handler for the `GET` method which handles the request
1414// for a digest and metadata of all API pages from the Node.js Website
1515// @see https://nextjs.org/docs/app/building-your-application/routing/router-handlers
1616export const GET = async ( ) => {
1717 const releases = await getReleaseData ( ) ;
1818
19- const latestLTSRelease = releases . find ( release =>
19+ const { versionWithPrefix } = releases . find ( release =>
2020 [ 'Active LTS' , 'Maintenance LTS' ] . includes ( release . status )
21- ) ;
21+ ) ! ;
2222
23- const gitHubApiResponse = await fetch (
24- getGitHubApiDocsUrl ( latestLTSRelease ! . versionWithPrefix )
25- ) ;
23+ const gitHubApiResponse = await fetch ( getGitHubApiDocsUrl ( versionWithPrefix ) ) ;
2624
2725 return gitHubApiResponse . json ( ) . then ( ( apiDocsFiles : Array < GitHubApiFile > ) => {
2826 // maps over each api file and get the download_url, fetch the content and deflates it
@@ -41,7 +39,7 @@ export const GET = async () => {
4139
4240 return {
4341 filename,
44- pathname : getPathnameForApiFile ( name ) ,
42+ pathname : getPathnameForApiFile ( name , versionWithPrefix ) ,
4543 content : deflatedSource ,
4644 } ;
4745 }
0 commit comments