mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
65 lines
2.5 KiB
JavaScript
65 lines
2.5 KiB
JavaScript
const listDir = require('@sukka/listdir');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const rootPath = path.resolve(__dirname, '../');
|
|
|
|
(async () => {
|
|
const list = await listDir(rootPath, {
|
|
ignoreHidden: true,
|
|
ignorePattern: /node_modules|Build|.DS_Store|\.(json|html|md|js)|LICENSE/
|
|
});
|
|
|
|
const html = template(list);
|
|
|
|
await fs.promises.writeFile(path.join(rootPath, 'index.html'), html, 'utf-8');
|
|
})();
|
|
|
|
/**
|
|
* @param {string[]} urlList
|
|
* @returns {string}
|
|
*/
|
|
function template(urlList) {
|
|
const date = new Date();
|
|
|
|
return `
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Surge Ruleset Server | Sukka (@SukkaW)</title>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
<link href="https://cdn.skk.moe/favicon.ico" rel="icon" type="image/ico">
|
|
<link href="https://cdn.skk.moe/favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
|
|
<link href="https://cdn.skk.moe/favicon/android-chrome-192x192.png" rel="icon" type="image/png" sizes="192x192">
|
|
<link href="https://cdn.skk.moe/favicon/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
|
|
<link href="https://cdn.skk.moe/favicon/favicon-16x16.png" rel="icon" type="image/png" sizes="16x16">
|
|
<link href="https://cdn.skk.moe/favicon/safari-pinned-tab.svg" rel="mask-icon" color="#fcfcfc">
|
|
<meta name="description" content="Sukka 自用的 Surge 规则组">
|
|
<meta property="og:title" content="Surge Ruleset | Sukka (@SukkaW)">
|
|
<meta property="og:type" content="Website">
|
|
<meta property="og:url" content="https://ruleset.skk.moe/">
|
|
<meta property="og:image" content="https://cdn.skk.moe/favicon/android-chrome-192x192.png">
|
|
<meta property="og:description" content="Sukka 自用的 Surge 规则组">
|
|
<meta name="twitter:card" content="summary">
|
|
<link rel="canonical" href="https://ruleset.skk.moe/">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1.5.0/css/pico.min.css">
|
|
</head>
|
|
<body>
|
|
<main class="container">
|
|
<h1>Sukka Surge Ruleset Server</h1>
|
|
<p>Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="https://github.com/SukkaW/Surge/blob/master/LICENSE" target="_blank">AGPL-3.0</a></p>
|
|
<p>Last Updated: ${date.toISOString()}</p>
|
|
<hr>
|
|
<br>
|
|
<ul>
|
|
${urlList.sort().map(url => `
|
|
<li><a href="${url}" target="_blank">${url}</a></li>
|
|
`).join('')}
|
|
</ul>
|
|
</main>
|
|
</body>
|
|
</html>
|
|
`
|
|
}
|