mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-29 22:24:31 +02:00
feat: switch api url and bypass cache while prerendering
This commit is contained in:
parent
e7a34c2ae9
commit
fe5877ade5
16
src/lib/utils.ts
Normal file
16
src/lib/utils.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { prerendering } from "$app/environment";
|
||||
|
||||
export function api_url(endpoint: string): string {
|
||||
let url = `https://releases.revanced.app/${endpoint}`;
|
||||
|
||||
if (prerendering) {
|
||||
url += '?cacheBypass=';
|
||||
// Just add some random stuff to the string. Doesn't really matter what we add.
|
||||
// This is here to make sure we bypass the cache while prerendering.
|
||||
for (let i = 0; i < 6; i++) {
|
||||
url += Math.floor(Math.random() * 10).toString();
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import type { Repository } from 'src/data/types';
|
||||
|
||||
import { api_url } from '$lib/utils';
|
||||
|
||||
export type ContribData = { repositories: Repository[] };
|
||||
|
||||
export const prerender = true;
|
||||
@ -7,7 +9,7 @@ export const prerender = true;
|
||||
export async function load({
|
||||
fetch
|
||||
}): Promise<ContribData> {
|
||||
const response = await fetch('https://releases.rvcd.win/contributors');
|
||||
const response = await fetch(api_url('contributors'));
|
||||
const data = await response.json();
|
||||
return data;
|
||||
};
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { readable } from 'svelte/store';
|
||||
import type { Patch } from 'src/data/types';
|
||||
|
||||
import { api_url } from '$lib/utils';
|
||||
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
export type PatchesData = { patches: Patch[]; packages: string[] };
|
||||
|
||||
export async function load({
|
||||
fetch
|
||||
}): Promise<PatchesData> {
|
||||
const response = await fetch('https://releases.rvcd.win/patches');
|
||||
const response = await fetch(api_url('patches'));
|
||||
const patches = await response.json();
|
||||
let packages: string[] = [];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user