From 934af1cc65c64a1c2bbedd6d7c16d35b3060d4e1 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Thu, 25 Jun 2026 14:00:56 +0900 Subject: SNS共有: twitter:card追加、見出しアンカーを常時表示に改善 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - twitter:card=summary_large_image を追加し、Xでの共有表示を最適化 - 見出しアンカーを常時表示(opacity: 0.3)に変更 クリックで「コピーしました!」のフィードバック表示も追加 - OGPはStarlightが自動生成済み(title/description/image/url) --- astro.config.mjs | 9 ++++++++- src/styles/custom.css | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 6f7f212..b87a554 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -185,6 +185,13 @@ export default defineConfig({ "https://yasutakeyohei.com/img/yasutake-yohei-city-council.jpg", }, }, + { + tag: "meta", + attrs: { + name: "twitter:card", + content: "summary_large_image", + }, + }, { tag: "script", attrs: { type: "application/ld+json" }, @@ -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 = ''; 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 = ''; 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", diff --git a/src/styles/custom.css b/src/styles/custom.css index f765954..f43e7ff 100644 --- a/src/styles/custom.css +++ b/src/styles/custom.css @@ -1051,22 +1051,25 @@ main:has(.home-hero) { /* ── Heading Anchor Links ── */ .heading-anchor { - opacity: 0; + opacity: 0.3; margin-left: -1.2em; padding-right: 0.3em; color: var(--sl-color-gray-3); text-decoration: none; - transition: opacity 0.2s; + transition: + opacity 0.2s, + color 0.2s; float: left; } h2:hover .heading-anchor, -h3:hover .heading-anchor, -.heading-anchor.copied { +h3:hover .heading-anchor { opacity: 1; } .heading-anchor:hover { color: var(--sl-color-accent); + opacity: 1; } .heading-anchor.copied { + opacity: 1; color: var(--sl-color-green-high, #16a34a); } -- cgit v1.3.1