mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
fix(site): include HLS CDN script in installation builder (#907)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { Renderer, Skin, UseCase } from '@/stores/installation';
|
||||
|
||||
const CDN_BASE = 'https://cdn.jsdelivr.net/npm/@videojs/html/cdn';
|
||||
|
||||
function getCdnFileName(useCase: UseCase, skin: Skin): string {
|
||||
if (useCase === 'background-video') return 'background';
|
||||
if (skin === 'minimal-video') return 'video-minimal';
|
||||
if (skin === 'minimal-audio') return 'audio-minimal';
|
||||
return skin;
|
||||
}
|
||||
|
||||
function getCdnMediaSubpath(renderer: Renderer): string | null {
|
||||
const map: Partial<Record<Renderer, string>> = {
|
||||
hls: 'hls-video',
|
||||
};
|
||||
|
||||
return map[renderer] ?? null;
|
||||
}
|
||||
|
||||
export function generateCdnCode(useCase: UseCase, skin: Skin, renderer: Renderer): string {
|
||||
const name = getCdnFileName(useCase, skin);
|
||||
const mediaSubpath = getCdnMediaSubpath(renderer);
|
||||
|
||||
const scriptLines = [`<script type="module" src="${CDN_BASE}/${name}.js"></script>`];
|
||||
|
||||
if (mediaSubpath) {
|
||||
scriptLines.push(`<script type="module" src="${CDN_BASE}/media/${mediaSubpath}.js"></script>`);
|
||||
}
|
||||
|
||||
return `${scriptLines.join('\n')}
|
||||
<link rel="stylesheet" href="${CDN_BASE}/${name}.css" />`;
|
||||
}
|
||||
Reference in New Issue
Block a user