mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 03:34:45 +12:00
chore(website): switch to revalidate on fetch level
This commit is contained in:
parent
3ea4d26ee9
commit
0019700869
5 changed files with 5 additions and 10 deletions
|
@ -81,9 +81,6 @@ function resolveMemberSearchParams(packageName: string, member: ApiItem): URLSea
|
|||
return params;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/numeric-separators-style
|
||||
export const revalidate = 3600;
|
||||
|
||||
export async function generateMetadata({ params }: { params: ItemRouteParams }) {
|
||||
const member = (await fetchHeadMember(params))!;
|
||||
const name = `discord.js${member?.displayName ? ` | ${member.displayName}` : ''}`;
|
||||
|
|
|
@ -20,9 +20,6 @@ export interface VersionRouteParams {
|
|||
version: string;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/numeric-separators-style
|
||||
export const revalidate = 3600;
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: VersionRouteParams[] = [];
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { NextResponse, type NextRequest } from 'next/server';
|
|||
import { PACKAGES } from './util/constants';
|
||||
|
||||
async function fetchLatestVersion(packageName: string) {
|
||||
const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`);
|
||||
const res = await fetch(`https://docs.discordjs.dev/api/info?package=${packageName}`, { cache: 'no-store' });
|
||||
const data: string[] = await res.json();
|
||||
|
||||
return data.at(-2);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const fetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
const res = await fetch(url, { next: { revalidate: 3_600 } });
|
||||
return res.json();
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ import { connect } from '@planetscale/database';
|
|||
import { fetch } from 'undici';
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
process.exit(0);
|
||||
setFailed('DATABASE_URL is not set');
|
||||
}
|
||||
|
||||
const pkg = getInput('package', { required: true });
|
||||
|
@ -14,13 +14,14 @@ const version = getInput('version') || 'main';
|
|||
|
||||
const sql = connect({
|
||||
fetch,
|
||||
url: process.env.DATABASE_URL,
|
||||
url: process.env.DATABASE_URL!,
|
||||
});
|
||||
|
||||
const globber = await create(`packages/${pkg}/docs/docs.api.json`);
|
||||
for await (const file of globber.globGenerator()) {
|
||||
const data = await readFile(file, 'utf8');
|
||||
try {
|
||||
console.log(`Uploading ${file} with ${version}...`);
|
||||
await sql.execute('replace into documentation (version, data) values (?, ?)', [version, data]);
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
|
|
Loading…
Reference in a new issue