From 365df157b40d7fd4e344a5cd96823a17cbf7f5bc Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Fri, 6 Mar 2026 14:45:00 -0700 Subject: [PATCH] Add Recently Added notebooks section to homepage Server-rendered section between Featured and Explore showing the 4 most recently modified notebooks, excluding featured and untitled ones. Compact card layout with engine badge, cell count, and relative date. --- frontend/src/components/RecentNotebooks.astro | 92 +++++++++++++++++++ frontend/src/pages/index.astro | 6 ++ 2 files changed, 98 insertions(+) create mode 100644 frontend/src/components/RecentNotebooks.astro diff --git a/frontend/src/components/RecentNotebooks.astro b/frontend/src/components/RecentNotebooks.astro new file mode 100644 index 0000000..bf0febd --- /dev/null +++ b/frontend/src/components/RecentNotebooks.astro @@ -0,0 +1,92 @@ +--- +import { Icon } from 'astro-icon/components'; +import type { NotebookSummary } from '../lib/types'; + +interface Props { + notebooks: NotebookSummary[]; +} + +const FEATURED_IDS = new Set([ + 'rc-lowpass-filter', + '555-astable-blinker', + 'common-emitter-amplifier', +]); + +const { notebooks } = Astro.props; + +const recent = notebooks + .filter((nb) => !FEATURED_IDS.has(nb.id) && nb.title !== 'Untitled Notebook') + .sort((a, b) => new Date(b.modified).getTime() - new Date(a.modified).getTime()) + .slice(0, 4); + +function formatDate(iso: string): string { + try { + return new Date(iso).toLocaleDateString('en-US', { + month: 'short', + day: 'numeric', + timeZone: 'UTC', + }); + } catch { + return iso; + } +} + +const engineColor: Record = { + ngspice: { border: 'border-blue-500/30', bg: 'bg-blue-500/10', text: 'text-blue-400' }, + ltspice: { border: 'border-amber-500/30', bg: 'bg-amber-500/10', text: 'text-amber-400' }, +}; +--- + +{recent.length > 0 && ( +
+
+ +

Recently Added

+
+ + +
+)} diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astro index b1f3c42..2d8398f 100644 --- a/frontend/src/pages/index.astro +++ b/frontend/src/pages/index.astro @@ -4,6 +4,7 @@ import NotebookLayout from '../layouts/NotebookLayout.astro'; import NotebookGallery from '../components/NotebookGallery'; import PipelineStrip from '../components/PipelineStrip.astro'; import FeaturedNotebooks from '../components/FeaturedNotebooks.astro'; +import RecentNotebooks from '../components/RecentNotebooks.astro'; import OscilloscopeDisplay from '../components/OscilloscopeDisplay.astro'; import { fetchNotebookList } from '../lib/server-api'; import type { NotebookSummary } from '../lib/types'; @@ -150,6 +151,11 @@ try { + +
+ +
+