diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-09-01 14:48:45 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-09-01 14:48:45 +0300 |
| commit | 8a6d697308162874a236c84aac0b0f8c7ac01f83 (patch) | |
| tree | ed7dc7e8c6f50d66bde721fae78576aede929f66 /website/src/components/Head.astro | |
| parent | b54a78aa510b87d1e3b56c619b72eaeb59e4a2a1 (diff) | |
refactor: separate website presentation from runtime
Diffstat (limited to 'website/src/components/Head.astro')
| -rw-r--r-- | website/src/components/Head.astro | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/website/src/components/Head.astro b/website/src/components/Head.astro deleted file mode 100644 index dac83b81..00000000 --- a/website/src/components/Head.astro +++ /dev/null @@ -1,67 +0,0 @@ ---- -import { docsVersion } from '../docs-path'; - -const { head } = Astro.locals.starlightRoute; -const version = docsVersion(Astro.url.pathname); ---- - -{head.map(({ tag: Tag, attrs, content }) => <Tag {...attrs} set:html={content} />)} -<meta data-pagefind-filter="version[content]" content={version} /> -{version !== 'stable' && <meta name="robots" content="noindex, nofollow" />} - -<script> - const labels = (() => { - const lang = document.documentElement.lang.toLowerCase(); - if (lang.startsWith('ja')) return { copy: 'リンクをコピー', copied: 'コピーしました' }; - if (lang.startsWith('zh')) return { copy: '复制链接', copied: '已复制' }; - return { copy: 'Copy link', copied: 'Copied' }; - })(); - - function labelHeadingLinks(root: ParentNode = document) { - for (const link of root.querySelectorAll<HTMLAnchorElement>('.sl-anchor-link')) { - link.title = labels.copy; - const section = link.querySelector('.sr-only')?.textContent; - if (section) link.setAttribute('aria-label', `${labels.copy}: ${section}`); - } - } - - labelHeadingLinks(); - document.addEventListener('astro:page-load', () => labelHeadingLinks()); - document.addEventListener('click', async (event) => { - if ( - event instanceof MouseEvent && - (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) - ) { - return; - } - - const target = event.target; - if (!(target instanceof Element)) return; - const link = target.closest('.sl-anchor-link'); - if (!(link instanceof HTMLAnchorElement) || !navigator.clipboard?.writeText) return; - - try { - await navigator.clipboard.writeText(link.href); - } catch { - return; - } - - link.querySelector('.heading-link-copy-feedback')?.remove(); - const feedback = document.createElement('span'); - feedback.className = 'heading-link-copy-feedback'; - feedback.setAttribute('aria-hidden', 'true'); - feedback.textContent = labels.copied; - link.append(feedback); - window.setTimeout(() => feedback.remove(), 1400); - - let status = document.querySelector<HTMLElement>('[data-heading-link-copy-status]'); - if (!status) { - status = document.createElement('span'); - status.className = 'sr-only'; - status.setAttribute('role', 'status'); - status.dataset.headingLinkCopyStatus = ''; - document.body.append(status); - } - status.textContent = labels.copied; - }); -</script> |
