feat(cdn): Add CDN URL configuration and update related references

This commit is contained in:
web@ppanel 2025-03-08 12:54:58 +07:00
parent e4630f8ca9
commit 0c907337e1
3 changed files with 7 additions and 3 deletions

View File

@ -4,6 +4,7 @@ NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
# Site URL and API URL
NEXT_PUBLIC_SITE_URL=https://user.ppanel.dev
NEXT_PUBLIC_API_URL=https://api.ppanel.dev
NEXT_PUBLIC_CDN_URL=https://cdn.jsdelivr.net
# Home Page Settings
NEXT_PUBLIC_HOME_USER_COUNT=999

View File

@ -9,6 +9,8 @@ export const NEXT_PUBLIC_DEFAULT_LANGUAGE =
export const NEXT_PUBLIC_SITE_URL = env('NEXT_PUBLIC_SITE_URL') ?? process.env.NEXT_PUBLIC_SITE_URL;
export const NEXT_PUBLIC_API_URL = env('NEXT_PUBLIC_API_URL') ?? process.env.NEXT_PUBLIC_API_URL;
export const NEXT_PUBLIC_CDN_URL =
env('NEXT_PUBLIC_CDN_URL') || process.env.NEXT_PUBLIC_CDN_URL || 'https://fastly.jsdelivr.net';
export const NEXT_PUBLIC_DEFAULT_USER_EMAIL =
env('NEXT_PUBLIC_DEFAULT_USER_EMAIL') ?? process.env.NEXT_PUBLIC_DEFAULT_USER_EMAIL;

View File

@ -1,14 +1,15 @@
import { NEXT_PUBLIC_CDN_URL } from '@/config/constants';
import matter from 'gray-matter';
const BASE_URL = 'https://cdn.jsdelivr.net/gh/perfect-panel/ppanel-tutorial';
const BASE_URL = `${NEXT_PUBLIC_CDN_URL}/gh/perfect-panel/ppanel-tutorial`;
async function getVersion() {
// API rate limit: 60 requests per hour
const response = await fetch(
'https://api.github.com/repos/perfect-panel/ppanel-tutorial/commits',
'https://data.jsdelivr.com/v1/stats/packages/gh/perfect-panel/ppanel-tutorial/versions',
);
const json = await response.json();
return json[0].sha;
return json[0].version;
}
async function getVersionPath() {