mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-14 16:36:18 -08:00
refactor(build): [SITE-BUILD-01] stage outputs and stabilize documentation builds
This commit is contained in:
1 parent
078cd9ef72
commit
a468cb2c39
72 files changed
+2396
-748
No files matched your search
+52
-25
@@ -1,27 +1,54 @@
|
||||
(function () {
|
||||
if (window['run-code-init']) return;
|
||||
window['run-code-init'] = true;
|
||||
document.addEventListener('click', (event) => {
|
||||
if (event.target.className === 'run-code' || event.target.getAttribute('classname') === 'run-code') {
|
||||
event.preventDefault();
|
||||
const codeElement = event.target.nextElementSibling.querySelector('pre code');
|
||||
if (codeElement) {
|
||||
const libs = event.target.dataset.libs || '';
|
||||
const code = encodeURIComponent(codeElement.innerText);
|
||||
const isDev = location.hostname === 'localhost';
|
||||
const env = isDev ? 'http://localhost:8082' : 'https://artplayer.org';
|
||||
const url = env + '/?libs=' + libs + '&code=' + code;
|
||||
window.open(url);
|
||||
}
|
||||
}
|
||||
// Generated by yarn build:site-assets. Do not edit.
|
||||
(() => {
|
||||
// packages/artplayer-vitepress/browser/navigation.ts
|
||||
function isDevelopment(hostname) {
|
||||
return ["localhost", "127.0.0.1", "[::1]", "::1"].includes(hostname.toLowerCase());
|
||||
}
|
||||
function runCodeUrl(location, libraries, code) {
|
||||
const hostname = location.hostname === "::1" ? "[::1]" : location.hostname;
|
||||
const origin = isDevelopment(hostname) ? `http://${hostname}:8082` : "https://artplayer.org";
|
||||
return `${origin}/?libs=${encodeURIComponent(libraries)}&code=${encodeURIComponent(code)}`;
|
||||
}
|
||||
function languageDestination(url, language, initialized, englishPaths) {
|
||||
const current = new URL(url);
|
||||
if (initialized || isDevelopment(current.hostname) || language.toLowerCase().startsWith("zh") || !language || !current.pathname.startsWith("/document/"))
|
||||
return { remember: false, target: null };
|
||||
if (current.pathname.startsWith("/document/en/"))
|
||||
return { remember: true, target: null };
|
||||
const relative = current.pathname.slice("/document/".length);
|
||||
const counterpart = englishPaths.includes(relative);
|
||||
const target = new URL(counterpart ? `/document/en/${relative}` : "/document/en/", current.origin);
|
||||
if (counterpart) {
|
||||
target.search = current.search;
|
||||
target.hash = current.hash;
|
||||
}
|
||||
return { remember: true, target: target.href };
|
||||
}
|
||||
function installNavigation(host, englishPaths) {
|
||||
const marker = "run-code-init";
|
||||
if (Reflect.get(host, marker))
|
||||
return;
|
||||
Reflect.set(host, marker, true);
|
||||
host.document.addEventListener("click", (event) => {
|
||||
const element = event.target instanceof Element ? event.target : null;
|
||||
const button = element?.closest('.run-code, [classname="run-code"]');
|
||||
const code = button?.nextElementSibling?.querySelector("pre code");
|
||||
if (!(button instanceof HTMLElement) || !code)
|
||||
return;
|
||||
event.preventDefault();
|
||||
const text = code.innerText ?? code.textContent ?? "";
|
||||
host.open(runCodeUrl(host.location, button.dataset.libs || "", text));
|
||||
});
|
||||
})();
|
||||
try {
|
||||
const result = languageDestination(host.location.href, host.navigator.language, !!host.localStorage.getItem("lang-init"), englishPaths);
|
||||
if (result.remember)
|
||||
host.localStorage.setItem("lang-init", "true");
|
||||
if (result.target)
|
||||
host.location.href = result.target;
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
const language = window.navigator?.language || '';
|
||||
const isDev = location.hostname === 'localhost';
|
||||
if (!language.startsWith('zh') && !localStorage.getItem('lang-init') && !isDev) {
|
||||
localStorage.setItem('lang-init', 'true');
|
||||
window.location.href = 'https://artplayer.org/document/en/';
|
||||
}
|
||||
})();
|
||||
// <stdin>
|
||||
installNavigation(window, ["advanced/built-in.html", "advanced/built-in", "advanced/class.html", "advanced/class", "advanced/event.html", "advanced/event", "advanced/global.html", "advanced/global", "advanced/plugin.html", "advanced/plugin", "advanced/property.html", "advanced/property", "component/contextmenu.html", "component/contextmenu", "component/controls.html", "component/controls", "component/layers.html", "component/layers", "component/setting.html", "component/setting", "", "index.html", "start/i18n.html", "start/i18n", "start/option.html", "start/option"]);
|
||||
})();
|
||||
Reference in new issue
Block a user