Skip to content

Commit

Permalink
refactor(website): extract layouts and use more server components (#9027
Browse files Browse the repository at this point in the history
)

Closes #8920
Closes #8997
  • Loading branch information
suneettipirneni authored Jan 10, 2023
1 parent 158db47 commit 39c4de2
Show file tree
Hide file tree
Showing 73 changed files with 1,830 additions and 1,475 deletions.
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"ariakit": "^2.0.0-next.41",
"cmdk": "^0.1.20",
"meilisearch": "^0.30.0",
"next": "^13.0.7-canary.1",
"next": "^13.1.2-canary.4",
"next-mdx-remote": "^4.2.0",
"next-themes": "npm:@wits/next-themes@latest",
"react": "^18.2.0",
Expand Down
26 changes: 26 additions & 0 deletions apps/website/src/app/docAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';

export async function fetchVersions(packageName: string): Promise<string[]> {
const response = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, {
next: { revalidate: 3_600 },
});

return response.json();
}

export async function fetchModelJSON(packageName: string, version: string): Promise<unknown> {
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
const res = await readFile(
join(process.cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'),
'utf8',
);
return JSON.parse(res);
}

const response = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${version}.api.json`, {
next: { revalidate: 3_600 },
});

return response.json();
}
Loading

2 comments on commit 39c4de2

@vercel
Copy link

@vercel vercel bot commented on 39c4de2 Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 39c4de2 Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.