diff --git a/assets/images/1.png b/assets/images/1.png new file mode 100644 index 0000000..ac3e349 Binary files /dev/null and b/assets/images/1.png differ diff --git a/data/friends.yaml b/data/friends.yaml new file mode 100644 index 0000000..99958bd --- /dev/null +++ b/data/friends.yaml @@ -0,0 +1,15 @@ +groups: + - title: "Recommended" + links: + - name: "Astro" + avatar: "https://astro.build/favicon.svg" + description: "The web framework for content-driven websites" + url: "https://astro.build" + - name: "Bun" + avatar: "https://bun.sh/favicon.svg" + description: "Incredibly fast JavaScript runtime, bundler, test runner, and package manager" + url: "https://bun.sh" + - name: "Tailwind CSS" + avatar: "https://tailwindcss.com/favicons/favicon.ico" + description: "A utility-first CSS framework for rapid UI development" + url: "https://tailwindcss.com" diff --git a/pages/about.md b/pages/about.md new file mode 100644 index 0000000..0adddab --- /dev/null +++ b/pages/about.md @@ -0,0 +1,17 @@ +--- +title: "About" +description: "About this blog and its author." +--- + +## About This Blog + +This blog is built with modern web technologies: + +- **Bun** + **Astro** for fast builds and static generation +- **Markdown** as the content format +- **Git** as the content management system +- **TailwindCSS** for responsive design + +## About The Author + +A developer who loves open source and building things with code. diff --git a/pages/friends.md b/pages/friends.md new file mode 100644 index 0000000..a321666 --- /dev/null +++ b/pages/friends.md @@ -0,0 +1,10 @@ +--- +title: "Friends" +description: "Friendly links and recommended blogs." +--- + +## Blogroll + +- [Astro](https://astro.build) - The web framework for content-driven websites +- [Bun](https://bun.sh) - Incredibly fast JavaScript runtime, bundler, test runner, and package manager +- [TailwindCSS](https://tailwindcss.com) - A utility-first CSS framework diff --git a/posts/2026/05/ddmt-blog-setup.md b/posts/2026/05/ddmt-blog-setup.md new file mode 100644 index 0000000..04a2c4d --- /dev/null +++ b/posts/2026/05/ddmt-blog-setup.md @@ -0,0 +1,212 @@ +--- +title: "Ddmt-Blog Setup and Configuration Guide" +date: 2026-05-15 +description: "Step-by-step guide to deploy and configure Ddmt-Blog with Docker, environment variables, and Gitea webhooks." +category: "tech" +tags: ["tutorial", "docker", "gitea", "deployment"] +author: "ddmt" +--- + +## Prerequisites + +- A Gitea instance (or any Git host with webhook support) +- Docker and Docker Compose (recommended), or Bun installed locally +- An SSH deploy key with read access to your content repository + +## Quick Start with Docker + +The fastest way to get running: + +```bash +git clone https://github.com/ddmt/Ddmt-Blog.git +cd Ddmt-Blog +cp .env.example .env +# Edit .env with your configuration +docker compose up -d +``` + +The blog will be available at `http://localhost:4321`. + +## Environment Variables + +All configuration is done through environment variables in the `.env` file. + +### Site Settings + +| Variable | Default | Description | +|---|---|---| +| `SITE_URL` | `http://0.0.0.0:4321` | Public URL of your blog | +| `SITE_TITLE` | `My Blog` | Blog title shown in header | +| `SITE_DESCRIPTION` | `A blog powered by Bun + Astro` | Default meta description | +| `SITE_AUTHOR` | `ddmt` | Default author name | +| `SITE_LOCALE` | `zh-CN` | HTML lang attribute | + +### Webhook Settings + +| Variable | Default | Description | +|---|---|---| +| `WEBHOOK_SECRET` | `change-me-in-production` | Secret for Gitea webhook signature verification | + +### Git Sync Settings + +| Variable | Default | Description | +|---|---|---| +| `GIT_REPO_URL` | (empty) | SSH URL of your content repository. Leave empty to disable auto-sync. | +| `GIT_DEPLOY_KEY` | (empty) | SSH private key for repository access. Leave empty to disable auto-sync. | + +### Server Settings + +| Variable | Default | Description | +|---|---|---| +| `PORT` | `4321` | Port the Bun server listens on | + +## Gitea Webhook Configuration + +1. Go to your repository Settings > Webhooks > Add Webhook +2. Set the target URL to `http://your-server:4321/api/webhook` +3. Set the secret to match your `WEBHOOK_SECRET` +4. Select "Push events" as the trigger +5. Content type: `application/json` + +The webhook will trigger a pull and rebuild on every push. + +## Content Structure + +All content lives in the `content/` directory: + +``` +content/ + posts/2026/05/my-article.md # Blog posts + pages/about.md # Template pages + data/friends.yaml # Structured data + data/site.json # Auto-generated site info + assets/images/ # Static images +``` + +### Writing a Post + +Create a Markdown file in `content/posts/yyyy/mm/`: + +```markdown +--- +title: "My New Post" +date: 2026-05-15 +description: "A short description for SEO." +category: "tech" +tags: ["tutorial", "web"] +cover: "/assets/images/cover.jpg" +pinned: false +draft: false +--- + +Your content here... +``` + +### Frontmatter Fields + +| Field | Required | Description | +|---|---|---| +| `title` | Yes | Post title | +| `date` | Yes | Publication date | +| `description` | No | Short description for meta tags | +| `category` | No | Post category (default: "uncategorized") | +| `tags` | No | Array of tags | +| `cover` | No | Cover image URL | +| `pinned` | No | Pin to top of homepage | +| `draft` | No | Exclude from build | + +### Template Pages + +Pages use content from `content/pages/` and optional data from `content/data/`: + +- `about.md` -- Renders the About page +- `friends.md` + `data/friends.yaml` -- Renders Friends page with link groups + +### Friends Data Format + +```yaml +groups: + - title: "Blogroll" + links: + - name: "Example Blog" + avatar: "https://example.com/avatar.png" + description: "A great blog about things" + url: "https://example.com" +``` + +## Docker Deployment + +### Dockerfile + +The Dockerfile copies the project (excluding `dist/`, `content/`, and dev files), installs git, and starts the server. Content is synced and built at startup. + +### Docker Compose + +```yaml +services: + blog: + build: . + ports: + - "4321:4321" + env_file: .env + volumes: + - blog-content:/app/content + restart: unless-stopped +``` + +The `content/` volume persists your blog content across container restarts. On first start, if `GIT_REPO_URL` is configured, the container will clone the repository automatically. + +### Building and Running + +```bash +docker compose build +docker compose up -d +``` + +### Logs + +```bash +docker compose logs -f blog +``` + +## Manual Deployment (Without Docker) + +```bash +bun install +# Edit .env +bun run build +bun run start +``` + +## Reverse Proxy (Nginx) + +```nginx +server { + listen 80; + server_name blog.example.com; + + location / { + proxy_pass http://127.0.0.1:4321; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} +``` + +## Troubleshooting + +**Webhook not triggering rebuilds:** +- Check that `WEBHOOK_SECRET` matches in both `.env` and Gitea +- Verify the webhook URL is reachable from Gitea +- Check server logs: `docker compose logs blog` + +**Content not appearing:** +- Ensure `GIT_REPO_URL` and `GIT_DEPLOY_KEY` are set correctly +- Check that the deploy key has read access to the repository +- Verify the content directory structure matches the expected layout + +**Search not working:** +- Pagefind indexes are built at build time +- Rebuild after adding new content: `bun run build` \ No newline at end of file diff --git a/posts/2026/05/hello-world.md b/posts/2026/05/hello-world.md new file mode 100644 index 0000000..47b3638 --- /dev/null +++ b/posts/2026/05/hello-world.md @@ -0,0 +1,33 @@ +--- +title: "Hello World" +date: 2026-05-13 +description: "This is my first blog post, built with Bun + Astro." +category: "tech" +tags: ["blog", "astro", "bun"] +pinned: true +author: "ddmt" +--- + +## Welcome!!! + +This is the first post on my new blog, built with an exciting modern stack: + +- **Bun** as the JavaScript runtime +- **Astro** as the web framework +- **TailwindCSS** for styling +- **Shiki** for code highlighting + +## Code Example + +```typescript +import { defineConfig } from "astro/config"; + +export default defineConfig({ + site: "https://example.com", + output: "static", +}); +``` + +## What's Next + +Stay tuned for more posts about web development, system design, and open source projects. diff --git a/posts/2026/05/introducing-ddmt-blog.md b/posts/2026/05/introducing-ddmt-blog.md new file mode 100644 index 0000000..bf869c6 --- /dev/null +++ b/posts/2026/05/introducing-ddmt-blog.md @@ -0,0 +1,76 @@ +--- +title: "Ddmt-Blog: A Git-Driven Markdown Blog" +date: 2026-05-15 +description: "Introduction to Ddmt-Blog, a lightweight blog system powered by Bun, Astro, and Git webhooks." +category: "tech" +tags: ["blog", "astro", "bun", "git", "markdown"] +pinned: true +author: "ddmt" +--- + +## What is Ddmt-Blog + +Ddmt-Blog is a lightweight, HTML-first blog system built on top of Bun and Astro. It uses Markdown files as the single source of truth for all content, with Git as the content management layer. + +No database. No admin panel. Just Markdown, Git, and a fast build pipeline. + +## Core Principles + +- **Git-driven content** -- Your Gitea (or compatible) repository IS your CMS. Push a Markdown file, and the blog rebuilds automatically via webhook. +- **Markdown as data** -- Every post, page, and piece of structured data lives in `.md` or `.yaml` files under the `content/` directory. +- **Static-first, SPA-enhanced** -- The site builds to static HTML by default, with Astro's ClientRouter for smooth client-side page transitions. +- **Zero database** -- No SQL, no Redis, no external storage. Everything is files on disk. +- **Lightweight runtime** -- A single Bun process serves static files, handles webhooks, and triggers rebuilds. + +## Tech Stack + +| Layer | Technology | +|---|---| +| Runtime | Bun | +| Framework | Astro 6 | +| Styling | TailwindCSS 4 | +| Search | Pagefind | +| Code Highlight | Shiki | +| Content Sync | Git SSH + Gitea Webhook | + +## How It Works + +1. You write a Markdown file and push it to your Git repository. +2. Gitea sends a webhook POST to the blog server. +3. The server verifies the signature, pulls the latest content, and triggers a full Astro rebuild. +4. The new static files are served immediately. + +The entire cycle -- from push to live -- takes a few seconds. + +## Project Structure + +``` +content/ + posts/ # Markdown articles (yyyy/mm/slug.md) + pages/ # Template pages (about.md, friends.md) + data/ # Structured data (friends.yaml, site.json) + assets/ # Static images and files +src/ + pages/ # Astro routes and templates + layouts/ # Page layouts + components/ # UI components + server/ # Webhook and sync logic +app/ + server.ts # Bun HTTP server entry point +``` + +## Features + +- Author card and website info from webhook data +- Category and tag system +- Full-text search via Pagefind +- Dark/light theme toggle +- RSS feed and sitemap +- SEO meta tags and OpenGraph +- Friends page with YAML-driven link groups +- Archive and timeline views +- Build info footer (commit SHA + build time) + +## Next Steps + +Check out the [configuration guide](/article/ddmt-blog-setup) for deployment instructions, environment variables, and Docker setup. diff --git a/posts/2026/05/test-post.md b/posts/2026/05/test-post.md new file mode 100644 index 0000000..e1a9802 --- /dev/null +++ b/posts/2026/05/test-post.md @@ -0,0 +1,34 @@ +--- +title: "Test-Post" +date: 2026-05-15 +description: "This is Test Post" +category: "tech" +tags: ["test", "bun"] +pinned: false +author: "ddmt" +--- + +## Welcome + +This is the first post on my new blog, built with an exciting modern stack: + +- **Bun** as the JavaScript runtime +- **Astro** as the web framework +- **TailwindCSS** for styling +- **Shiki** for code highlighting + +## Code Example + +```typescript +import { defineConfig } from "astro/config"; + +export default defineConfig({ + site: "https://example.com", + output: "static", +}); +``` + +## What's Next + +Stay tuned for more posts about web development, system design, and open source projects. +