diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-06-25 14:00:56 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-06-25 14:00:56 +0900 |
| commit | 934af1cc65c64a1c2bbedd6d7c16d35b3060d4e1 (patch) | |
| tree | e19ae275cdba5ae49200907bd3dd884e1eae7ef9 /astro.config.mjs | |
| parent | c40643a98487d0dbe4d9b89877fb98249055c31d (diff) | |
SNS共有: twitter:card追加、見出しアンカーを常時表示に改善
- twitter:card=summary_large_image を追加し、Xでの共有表示を最適化
- 見出しアンカーを常時表示(opacity: 0.3)に変更
クリックで「コピーしました!」のフィードバック表示も追加
- OGPはStarlightが自動生成済み(title/description/image/url)
Diffstat (limited to 'astro.config.mjs')
| -rw-r--r-- | astro.config.mjs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/astro.config.mjs b/astro.config.mjs index 6f7f212..b87a554 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -186,6 +186,13 @@ export default defineConfig({ }, }, { + tag: "meta", + attrs: { + name: "twitter:card", + content: "summary_large_image", + }, + }, + { tag: "script", attrs: { type: "application/ld+json" }, content: JSON.stringify({ @@ -225,7 +232,7 @@ export default defineConfig({ { tag: "script", content: - "document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('.sl-markdown-content h2[id], .sl-markdown-content h3[id]').forEach(h => { const a = document.createElement('a'); a.href = '#' + h.id; a.className = 'heading-anchor'; a.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>'; a.title = 'この見出しへのリンクをコピー'; a.addEventListener('click', e => { e.preventDefault(); const url = location.origin + location.pathname + '#' + h.id; navigator.clipboard.writeText(url).then(() => { a.classList.add('copied'); setTimeout(() => a.classList.remove('copied'), 1500); }); }); h.prepend(a); }); });", + "document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('.sl-markdown-content h2[id], .sl-markdown-content h3[id]').forEach(h => { const a = document.createElement('a'); a.href = '#' + h.id; a.className = 'heading-anchor'; a.innerHTML = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>'; a.title = 'クリックでこの見出しのURLをコピー'; a.addEventListener('click', e => { e.preventDefault(); const url = location.origin + location.pathname + '#' + h.id; navigator.clipboard.writeText(url).then(() => { a.classList.add('copied'); a.title = 'コピーしました!'; setTimeout(() => { a.classList.remove('copied'); a.title = 'クリックでこの見出しのURLをコピー'; }, 2000); }); }); h.prepend(a); }); });", }, { tag: "script", |
