Blog
The LongTerMemory blog is a static content marketing site built with Astro v5. It serves content about spaced repetition, learning science, AI-powered education, and memory techniques.
It is deployed at longtermemory.com/b/ as a subdirectory of the main domain.
Tech Stack
Astro v5
Static site generation
Tailwind CSS v3
Utility-first styling (purple/gradient theme)
Content Collections + Zod
Type-safe content with schema validation
Fuse.js
Client-side full-text search
Shiki
Syntax highlighting (GitHub Dark theme)
Development Commands
cd blog
npm install # Install dependencies
npm run dev # Dev server → http://localhost:4321/b/
npm run build # Production build → dist/
npm run preview # Preview production build locallyNote: No test suite is configured for this project.
Configuration
Key settings in astro.config.mjs:
Site URL:
https://longtermemory.comBase path:
/b— all routes and internal links are prefixed with/bSyntax highlighting: GitHub Dark via Shiki
Prefetch: enabled for faster navigation
Routing
File-based routing under src/pages/:
/b/
index.astro
Homepage (featured + all posts)
/b/{slug}/
[...slug].astro
Individual blog post
/b/categories/
categories/index.astro
All categories
/b/categories/{category}/
categories/[category].astro
Posts by category
/b/about/
about.astro
About page
/b/rss.xml
rss.xml.js
RSS feed
/b/sitemap-index.xml
(auto-generated)
Sitemap — build only
Content Management
Content is managed via Astro Content Collections with strict Zod schemas defined in src/content.config.ts.
Adding a Blog Post
Create
src/content/blog/your-slug.mdAdd required frontmatter:
Write content in Markdown below the frontmatter
The filename (without
.md) becomes the URL slug automatically
Draft and scheduled posts: Posts with draft: true are never published. Posts with a future pubDate are excluded from the build until the server rebuilds on or after that date.
Adding an Author
Create
src/content/authors/author-slug.json:
Reference the author in posts via
authorSlug: "author-slug"
Author bios and social links are displayed inline at the bottom of each blog post. There are no dedicated author pages.
Import Aliases
@components
src/components/
@layouts
src/layouts/
@utils
src/utils/index.ts
@types
src/types/index.ts
@content
src/content/
@styles
src/styles/
Components
All components are in src/components/ using .astro format:
SEO.astro
Meta tags, Open Graph, Twitter Card, structured data
Header.astro
Navigation with search trigger (Cmd/Ctrl + K)
Footer.astro
Site footer
BlogCard.astro
Post preview card
SearchModal.astro
Full-text search via Fuse.js
TableOfContents.astro
Auto-generated from H2–H4 headings
SocialShare.astro
Share buttons (Twitter, LinkedIn, Facebook, Reddit, Email)
AuthorCard.astro
Author bio with social links
Newsletter.astro
Email subscription form
SEO
The blog has comprehensive SEO built in:
Sitemap: auto-generated at build time (
sitemap-index.xml+sitemap-0.xml)Priorities: Homepage (1.0) > Posts (0.9) > Categories index (0.7) > Category pages (0.6) > Static pages (0.5)
Structured data:
BlogPostingschema on post pages,BreadcrumbListon all pages,Organizationschema inSEO.astroMeta tags: Open Graph, Twitter Card, canonical URL, language/geo, author, category
RSS feed: auto-generated at
/b/rss.xml
Utility Functions (src/utils/index.ts)
calculateReadingTime(content)
Word-count based (200 WPM)
extractTableOfContents(content)
Parses H2–H4 headings
getRelatedPosts(posts, currentPost, limit)
Tag-based similarity
generateBlogPostStructuredData(post, authorName, siteUrl)
JSON-LD
generateShareUrls(url, title)
Social sharing URLs
Deployment
Build and Deploy
The deploy script:
Commits and pushes local changes to git
SSHes into the server, pulls the latest code
Runs
npm installandnpm run buildThe
dist/directory is served directly from the configured server path
Scheduled Publishing
Since the build happens server-side, a daily cron job can trigger a rebuild to publish date-scheduled posts automatically — no code changes required. Posts whose pubDate is today will appear in the next build.
A dedicated cron-build.sh script (on the server) handles this:
Sources
nvmsonpmis available in the cron environmentSkips the build if no post is scheduled for today
Logs output to a rotating log file
Example crontab entry (on the server):
Last updated