--- // ガイドのページ(/guide/{slug}。2026-11-15) // LOG とは別の、検索から来る人向けに版が変わるたび書き直す記事。LOG 番号は付けず、記録の一覧には並べない。 // 見た目は記事ページ(src/styles/record.css)を使う。日付は「最終更新」を前に出す import Base from '../../layouts/Base.astro'; import { ymd } from '../../lib/format'; import { abs, AUTHOR, PUBLISHER, SITE, SITE_NAME, textOf } from '../../lib/seo'; import { allCards } from '../../lib/records'; import { allGuides } from '../../lib/guides'; import { getCollection, render } from 'astro:content'; import { existsSync } from 'node:fs'; import { linkifyHtml, linkLogsHtml } from '../../lib/links.mjs'; import { roomyTables } from '../../lib/tables.mjs'; import '../../styles/record.css'; import GuideCard from '../../components/GuideCard.astro'; export async function getStaticPaths() { return (await getCollection('guides')).map((e) => ({ params: { slug: e.data.slug }, props: { entry: e } })); } const { entry } = Astro.props; const d = entry.data; const esc = (s) => s.replace(/&/g, '&').replace(/ h.depth === 2); const toc = heads.length ? `` : ''; let body = entry.rendered?.html || ''; const at = toc ? body.search(/]/) : -1; body = !toc ? body : at >= 0 ? body.slice(0, at) + toc + body.slice(at) : toc + body; const LOGS = Object.fromEntries((await allCards()).map((c) => [c.day, c.slug])); body = roomyTables(linkifyHtml(linkLogsHtml(body, LOGS, d.slug, false, true, false))); const path = `/guide/${d.slug}`; const url = SITE + path; const published = d.published.toISOString(); const updated = d.updated.toISOString(); const description = d.meta_description || textOf(entry.body, 120); // SNS・検索の画像:HTML のサムネイルは書き出した /og/…jpg、画像のサムネイルは同じ名前の .jpg(webp を読めない SNS があるため) const ogFromThumb = !d.thumb ? null : /\.html$/.test(d.thumb) ? d.thumb.replace(/^\/thumbs\//, '/og/').replace(/\.html$/, '.jpg') : d.thumb.replace(/\.webp$/, '.jpg'); const ogImage = ogFromThumb && existsSync(`public${ogFromThumb}`) ? ogFromThumb : undefined; const others = (await allGuides()).filter((g) => g.slug !== d.slug); const jsonLd = [ { '@context': 'https://schema.org', '@type': 'Article', headline: d.title, description, url, mainEntityOfPage: url, inLanguage: 'ja', datePublished: published, dateModified: updated, image: ogImage ? [abs(ogImage)] : undefined, articleSection: 'ガイド', keywords: d.tags?.length ? d.tags.join(', ') : undefined, author: AUTHOR, publisher: PUBLISHER, isPartOf: { '@type': 'WebSite', name: SITE_NAME, url: SITE + '/' }, }, { '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: [ { '@type': 'ListItem', position: 1, name: SITE_NAME, item: SITE + '/' }, { '@type': 'ListItem', position: 2, name: 'ガイド', item: `${SITE}/guide` }, { '@type': 'ListItem', position: 3, name: d.title, item: url }, ], }, ]; ---
{d.thumb && (/\.html$/.test(d.thumb) ?
: {d.title})}
ガイド最終更新 {ymd(updated)}{updated !== published && 公開 {ymd(published)}}

{d.title}

{others.length > 0 && ( )}