--- // シリーズのページに、Google スプレッドシートの中身を表として直接載せる(元は iframe の埋め込み)。 // 中身は src/lib/sheets.ts(Google の写し・サイトのデザインの値)。タブが2つ以上あれば、表の上に切り替えを出す import { getSheet } from '../lib/sheets'; interface Props { id: string; height?: number } const { id, height } = Astro.props; const sheet = getSheet(id); // 色の値(#d2d2d2 など)には、その色の小さな四角を添える const swatch = (c: string) => /^#[0-9a-f]{3,8}$/i.test(c); // 中身が短い列(番号・状態など)は折り返さない const narrow = (rows: string[][], i: number) => rows.slice(1).every((r) => (r[i] || '').length <= 6); // 1つ目のセルにだけ文字がある行は、表の中の小見出しとして扱う const isSection = (r: string[]) => r.length > 1 && r[0] && r.slice(1).every((c) => !c); --- {sheet && (

{sheet.title}

{sheet.tabs.length > 1 && (
{sheet.tabs.map((t, i) => ( ))}
)} {sheet.tabs.map((t, i) => { const [head, ...body] = t.rows; return (
1 ? 'tabpanel' : undefined} hidden={i > 0} style={height ? `max-height:${height}px` : undefined}> {head.map((c, k) => )} {body.map((r) => isSection(r) ? : {r.map((c, k) => )})}
{c}
{r[0]}
{swatch(c) && }{c}
); })}
)}