1import { bindInstallControl, installControlMarkup } from './install';2import { element, query, setPageTitle } from './shared';3import { clearTheme } from './theme';45const CLI_VERBS = new Set([6 'access', 'connect', 'daemon', 'grant', 'host', 'link', 'login', 'request',7 'resolve', 'run', 'service', 'set',8]);910function highlightCliExamples(container: Element) {11 container.querySelectorAll('pre > code').forEach((code) => {12 const source = code.textContent;13 if (!source.trimStart().startsWith('devsite ')) return;1415 const highlighted = document.createDocumentFragment();16 let wordIndex = 0;17 let output = false;18 source.split(/(\s+)/).forEach((token) => {19 if (!token || /^\s+$/.test(token)) {20 highlighted.append(token);21 if (token.includes('\n')) wordIndex = 0;22 return;23 }2425 // A line that starts with # is example output, not part of the command.26 if (wordIndex === 0) output = token.startsWith('#');27 const span = document.createElement('span');28 if (output) span.className = 'command-output';29 else if (wordIndex === 0 && token === 'devsite') span.className = 'command-executable';30 else if (wordIndex <= 2 && CLI_VERBS.has(token)) span.className = 'command-verb';31 else if (token.startsWith('--')) span.className = 'command-option';32 else if (/^(?:dmt|dsp|dss|dst)_/.test(token)) span.className = 'command-secret';33 else span.className = 'command-value';34 span.textContent = token;35 highlighted.append(span);36 wordIndex += 1;37 });38 code.replaceChildren(highlighted);39 });40}4142export function renderSignedOut() {43 setPageTitle('home');44 clearTheme();45 query<HTMLElement>('.brand strong').hidden = true;46 const main = element('main');47 const template = element<HTMLTemplateElement>('home-template');48 main.replaceChildren(template.content.cloneNode(true));49 query<HTMLElement>('[data-install-control]', main).innerHTML = installControlMarkup();5051 const footer = element('page-footer');52 footer.innerHTML = `53 <nav aria-label="Footer">54 <ul><li><a href="https://github.com/FelineStateMachine/devsite"55 target="_blank" rel="noopener">GitHub</a></li></ul>56 </nav>`;57 footer.hidden = false;58 bindInstallControl();59 highlightCliExamples(main);60}