MC/website/scripts/build-account.mjs
2026-11-27 23:43:05 +00:00

7 lines
2.2 KiB
JavaScript

import {readFileSync,writeFileSync,readdirSync} from 'node:fs';
const web=new URL('../web/',import.meta.url),home=readFileSync(new URL('index.html',web),'utf8');
const header=home.match(/<header>[\s\S]*?<\/header>/)[0].replace(/ aria-current="page"/g,'');
const footer=home.match(/<footer>[\s\S]*?<\/footer>/)[0];
writeFileSync(new URL('account.html',web),'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Your account — dunerealms.com</title><link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="pages.css"><link rel="stylesheet" href="minecraft.css"><link rel="stylesheet" href="lore.css"><script src="pages.js" defer></script><script src="account-embed.js" defer></script></head><body>'+header+'<main id="main" class="account-embedded"><p class="eyebrow">DUNEREALMS.COM / YOUR ACCOUNT</p><h1>Your place in the caravan</h1><p>Sign in, register, link your Minecraft UUID and manage your community rewards. <a href="https://cp.dunerealms.com/" target="_blank" rel="noopener">Open the standalone account panel ↗</a></p><iframe id="account-panel" src="https://cp.dunerealms.com/?embedded=1" title="dunerealms.com account control panel" height="1400" referrerpolicy="no-referrer" allow="clipboard-write https://cp.dunerealms.com"></iframe><noscript><p><a href="https://cp.dunerealms.com/">Open the account panel</a>. JavaScript is required to use account features.</p></noscript></main>'+footer+'</body></html>');
for(const file of readdirSync(web).filter(file=>file.endsWith('.html'))){const url=new URL(file,web);let html=readFileSync(url,'utf8');html=html.replace(/<a href="account.html" class="account-nav">Account<\/a>/g,'');html=html.replace(/(<nav[^>]*aria-label="Main navigation"[^>]*>)/,'$1<a href="account.html" class="account-nav">Account</a>');writeFileSync(url,html);}
const portal=new URL('portal.html',web);let html=readFileSync(portal,'utf8');html=html.replace(/<p class="account-panel-entry">[\s\S]*?<\/p>/g,'').replace('<main>','<main><p class="account-panel-entry"><a href="account.html">Account control panel: UUID linking, rewards & security →</a></p>');writeFileSync(portal,html);