Skip to content

ntemposd/ntemposd.github.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

79 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ntemposd.me

Personal website built with Astro, using Notion as a headless CMS.

Live site: https://ntemposd.me


Overview

This project implements a content pipeline:

  • Content is created and managed in Notion
  • Fetched via the Notion API
  • Transformed into Markdown
  • Compiled into a static site during build time

System Design

A custom sync layer connects Notion to the site:

  • Fetches structured content from Notion databases
  • Transforms Notion blocks into Markdown
  • Downloads and caches assets locally
  • Generates content collections for Astro

This allows Notion to act as a CMS while keeping the site fully static.


โœจ Features

  • ๐Ÿ“ Notion CMS - Posts, projects, and experience sync from Notion databases via API
  • ๐Ÿ–ผ๏ธ Image handling - Downloads and caches images locally, preserves Notion captions as Markdown alt text
  • ๐ŸŒ“ Dark mode - System preference detection with manual toggle, persists to localStorage
  • ๐Ÿ“ฑ Responsive nav - Mobile hamburger menu, desktop horizontal nav
  • ๐Ÿ“ง ButtonDown embed - Newsletter subscription iframe on post pages
  • ๐ŸŽจ Tailwind CSS - Responsive styling with typography plugin for prose content
  • ๐Ÿ” SEO basics - Sitemap generation and Open Graph meta tags

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 20.19+ (recommended)
  • npm or pnpm
  • A Notion account with API integration

1. Clone and Install

git clone https://github.com/ntemposd/myastro.git
cd myastro
npm install

2. Set Up Environment Variables

Create a .env file in the root directory:

# Notion API
NOTION_SECRET=secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
NOTION_POSTS_DB_ID=your-posts-database-id
NOTION_PROJECTS_DB_ID=your-projects-database-id
NOTION_EXPERIENCE_DB_ID=your-experience-database-id

# Optional: customize date property name
NOTION_POSTS_DATE_PROP=Date
NOTION_POSTS_STRICT_DATE=true

# Site configuration (local .env)
SITE_BASE_URL=http://localhost:4321

# Optional: Google Analytics (only if you use GA)
PUBLIC_GA_ID=G-XXXXXXXXXX

3. Set Up Notion Databases

Create three Notion databases with the following structures:

Posts Database

  • Title (title)
  • Published (checkbox) or Status (select: "Published")
  • Date (date)
  • Excerpt (text)
  • Tags (multi-select)
  • Slug (text, optional - auto-generated from title if empty)
  • Image (files or URL, optional)

Projects Database

  • Name (title)
  • Type (select)
  • Published (checkbox)
  • Excerpt (text)
  • Tags (multi-select)
  • Link (URL)
  • Image (files or URL)

Experience Database

  • Role (title)
  • Company (text)
  • Start (date)
  • End (date, optional - leave empty for current)
  • Description (text)
  • Location (text, optional)

4. Get Notion API Credentials

  1. Go to Notion Integrations
  2. Create a new integration and copy the "Internal Integration Token"
  3. Share your databases with the integration
  4. Copy each database ID from the URL (the part after the workspace name and before the ?)

5. Run Development Server

npm run dev

Opens at http://localhost:4321


๐Ÿ“ Project Structure

myastro/
โ”œโ”€โ”€ public/    # Static assets served directly
โ”‚   โ”œโ”€โ”€ posts/    # Copied images for dev (avoid 404s)
โ”‚   โ””โ”€โ”€ robots.txt
โ”œโ”€โ”€ scripts/    # Notion sync scripts
โ”‚   โ”œโ”€โ”€ sync-posts.ts
โ”‚   โ”œโ”€โ”€ sync-projects.ts
โ”‚   โ””โ”€โ”€ sync-experience.ts
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ assets/    # Bundled images (hashed in prod)
โ”‚   โ”‚   โ”œโ”€โ”€ posts/
โ”‚   โ”‚   โ””โ”€โ”€ projects/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Share.astro    # Social sharing buttons
โ”‚   โ”‚   โ””โ”€โ”€ MailingListSubscribe.astro    # Newsletter embed
โ”‚   โ”œโ”€โ”€ content/    # Content collections
โ”‚   โ”‚   โ”œโ”€โ”€ config.ts
โ”‚   โ”‚   โ”œโ”€โ”€ posts/    # Synced from Notion
โ”‚   โ”‚   โ”œโ”€โ”€ projects/
โ”‚   โ”‚   โ””โ”€โ”€ experience/
โ”‚   โ”œโ”€โ”€ layouts/
โ”‚   โ”‚   โ””โ”€โ”€ Layout.astro    # Base layout with SEO
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ index.astro
โ”‚   โ”‚   โ”œโ”€โ”€ about.astro
โ”‚   โ”‚   โ”œโ”€โ”€ projects.astro
โ”‚   โ”‚   โ””โ”€โ”€ writing/
โ”‚   โ”‚       โ”œโ”€โ”€ index.astro
โ”‚   โ”‚       โ””โ”€โ”€ [slug].astro
โ”‚   โ””โ”€โ”€ styles/
โ”‚       โ””โ”€โ”€ global.css
โ””โ”€โ”€ package.json

๐Ÿงž Commands

Command Action
npm install Install dependencies
npm run dev Start dev server + sync content
npm run build Build production site + sync content
npm run preview Preview production build locally
npm run sync:content Sync all content from Notion
npm run sync:posts Sync posts only
npm run format Format code with Prettier

๐Ÿ”„ Content Sync Workflow

Content is automatically synced from Notion during dev and build. To manually sync:

npm run sync:content

How it works:

  1. Fetches published entries from Notion databases via API
  2. Downloads images to src/assets/posts/ and public/posts/
  3. Converts Notion blocks to Markdown using notion-to-md
  4. Generates frontmatter from database properties
  5. Writes .md files to src/content/posts/

Note: Image captions from Notion sync as Markdown alt text (![caption](url)). The public/posts/ copy prevents 404s during development before client-side URL rewriting kicks in.


๐ŸŽจ Customization

Update Site Metadata

Edit src/layouts/Layout.astro to change:

  • Site title and description
  • Open Graph images
  • Google Analytics ID

Styling

  • Global styles: src/styles/global.css
  • Tailwind config: tailwind.config.ts
  • Typography (prose): Configured via @tailwindcss/typography

ButtonDown Integration

  1. Update your ButtonDown username in src/components/MailingListSubscribe.astro
  2. The embed iframe will load from https://buttondown.com/api/emails/embed-subscribe/[username]

๐Ÿšข Deployment

Automatically deploys to GitHub Pages on push to main via .github/workflows/deploy.yml.

Setup GitHub Pages

  1. Go to repository Settings โ†’ Pages
  2. Source: GitHub Actions
  3. Configure repository secrets and variables (see below)

GitHub Secrets (Settings โ†’ Secrets โ†’ Actions)

  • NOTION_SECRET
  • NOTION_POSTS_DB_ID
  • NOTION_PROJECTS_DB_ID
  • NOTION_EXPERIENCE_DB_ID
  • PUBLIC_GA_ID (optional)

GitHub Repository Variables (Settings โ†’ Environments โ†’ github-pages โ†’ Variables)

  • SITE_BASE_URL (live URL, e.g., https://<user>.github.io/<repo> or your custom domain)

Push to main triggers automatic build and deploy.


๐Ÿ™‹ Questions?

Feel free to open an issue or reach out via ntemposd.me

๐Ÿ™‹ License

MIT

About

๐ŸŒ My personal website built with Astro and Notion.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors