Skip to content

Commit 8f45209

Browse files
committed
fix css
1 parent a728372 commit 8f45209

7 files changed

Lines changed: 315 additions & 277 deletions

File tree

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `posts/` holds Org sources, including special pages (`about.org`, `404.org`, `index.org`, `index-cn.org`).
5+
- Post files use date-first names like `YYYY-MM-DD-slug.org`; Chinese variants use `-cn.org`.
6+
- `static/` contains site assets (`css/`, `js/`, `favicon.svg`, `robots.txt`) copied to `public/static/` during builds.
7+
- `templates/post-template.org` is the starter template for new posts.
8+
- `build.el` defines Org publish logic; `build.sh`, `minify.sh`, and `generate-sitemap.sh` orchestrate CLI builds.
9+
- `public/` is generated output; do not edit it manually.
10+
11+
## Build, Test, and Development Commands
12+
- `npm ci`: install Node-based tooling.
13+
- `make build` or `npm run build`: generate HTML into `public/`.
14+
- `make build-prod` or `npm run build:prod`: build plus asset minification.
15+
- `make serve` or `npm run serve`: serve `public/` locally at `http://localhost:8000`.
16+
- `make dev`: watch `posts/` and `static/` and rebuild on change (`inotifywait` required).
17+
- `npm run format`: format JS/CSS/JSON/Markdown/YAML.
18+
- `npm run format:check`: CI-style formatting check.
19+
20+
## Coding Style & Naming Conventions
21+
- Prettier config (`.prettierrc`): 2-space indentation, single quotes, semicolons, 100-column width, LF endings.
22+
- Shell scripts should use `bash` + `set -euo pipefail` and remain ShellCheck-clean.
23+
- Org posts must include `#+TITLE`, `#+AUTHOR`, and `#+DATE`; use `#+DRAFT: true` for unpublished work.
24+
- Keep filenames kebab-case and date-prefixed (example: `2026-02-12-my-post.org`).
25+
26+
## Testing Guidelines
27+
- There is no unit-test suite; quality gates are lint/build checks.
28+
- Run before push:
29+
- `./build.sh`
30+
- `shellcheck *.sh` (and any modified shell scripts)
31+
- `npm run format:check`
32+
- CI additionally validates Org metadata and checks generated HTML internal links.
33+
34+
## Commit & Pull Request Guidelines
35+
- Follow existing history style: short, imperative commit subjects (for example, `fix lint`, `update about`, `refactor`).
36+
- Keep commits focused; separate content changes from tooling refactors when possible.
37+
- PRs should include: concise change summary, linked issue (if applicable), screenshots for UI/content styling changes, and confirmation that local checks pass.
38+
39+
## Configuration & Security Tips
40+
- Start from `.blogrc.example`; keep personal or deployment-specific values in `.blogrc`/environment variables.
41+
- Do not commit secrets; CI and publish workflows already read values like `BLOG_URL`, `BLOG_AUTHOR`, and `BLOG_EMAIL` from environment/secrets.

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile for blog operations
22

3-
.PHONY: all build clean serve dev install-deps new-post publish help
3+
.PHONY: all build clean serve server dev install-deps new-post publish help
44

55
# Default target
66
all: build
@@ -26,9 +26,13 @@ clean:
2626

2727
# Serve the blog locally
2828
serve: build
29+
@[ -d public ] || { echo "Build output not found: public/"; exit 1; }
2930
@echo "Serving blog at http://localhost:8000"
3031
@cd public && python3 -m http.server 8000
3132

33+
# Alias for serve
34+
server: serve
35+
3236
# Development mode with auto-rebuild
3337
dev:
3438
@echo "Starting development mode..."
@@ -78,4 +82,4 @@ help:
7882
@echo " make install-deps - Install required dependencies"
7983
@echo " make new-post - Create a new blog post"
8084
@echo " make publish - Build and publish to git"
81-
@echo " make help - Show this help message"
85+
@echo " make help - Show this help message"

README.md

Lines changed: 41 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,63 @@
1-
# Emacs Org-mode Blog Setup
1+
# Org-Mode Blog
22

3-
This blog is configured in your Doom Emacs with the Claude Code documentation style.
3+
Static blog generator powered by Emacs Org publish, with shell-based build scripts and GitHub Pages deployment.
44

5-
## Usage
5+
## Prerequisites
66

7-
### Create a new blog post
7+
- Emacs
8+
- Node.js 16+ and npm
9+
- Python 3 (for local preview server)
810

9-
- Use `SPC B n` (capital B) to create a new post
10-
- Enter the title when prompted
11-
- The post will be created with automatic filename and filled template
12-
13-
### Publish your blog
14-
15-
- Use `SPC B p` (capital B) to publish all posts
16-
- Files will be generated in `~/blog/public/`
17-
- Run `./build.sh` for command-line building
18-
- Run `make build-prod` for production build with minification
19-
20-
### Directory Structure
21-
22-
```
23-
~/blog/
24-
├── posts/ # Your org-mode blog posts
25-
├── static/ # CSS, JS, and other assets
26-
│ ├── css/ # Stylesheets
27-
│ ├── js/ # JavaScript files
28-
│ └── favicon.svg # Site favicon
29-
├── templates/ # Post templates
30-
├── public/ # Generated HTML output
31-
├── .github/ # GitHub Actions workflows
32-
│ └── workflows/
33-
│ ├── publish.yml # Main deployment workflow
34-
│ ├── pr-preview.yml # Pull request previews
35-
│ └── ci.yml # Continuous integration
36-
├── build.sh # Build script
37-
├── generate-sitemap.sh # Sitemap generator
38-
├── minify.sh # Asset minification
39-
├── Makefile # Build automation
40-
├── .blogrc # Configuration file
41-
└── htmlize.el # Syntax highlighting support
42-
```
43-
44-
### Configuration
45-
46-
The blog can be configured through environment variables in `.blogrc`:
11+
## Quick Start
4712

4813
```bash
49-
export BLOG_AUTHOR="your-name"
50-
export BLOG_EMAIL="your-email@example.com"
51-
export BLOG_URL="https://your-domain.com"
52-
export MINIFY_ASSETS="false" # Set to "true" for production
53-
```
54-
55-
### Workflow
56-
57-
1. Create new post: `SPC B n` (capital B) in Doom Emacs
58-
2. Write your content in org-mode
59-
3. Publish locally: `SPC B p` (capital B) in Doom Emacs or run `./build.sh`
60-
4. Serve locally: `make serve` or `cd ~/blog/public && python -m http.server`
61-
5. Deploy: Push to GitHub, automatic deployment via Actions
62-
63-
### Working with Drafts
64-
65-
To create draft posts that won't be published:
66-
67-
1. Add `#+DRAFT: true` to the post header
68-
2. When ready to publish, change to `#+DRAFT: false` or remove the line
69-
3. Draft posts are excluded from the sitemap and won't be built
70-
71-
Example draft post header:
72-
73-
```org
74-
#+TITLE: My Draft Post
75-
#+DATE: <2025-01-01>
76-
#+AUTHOR: bytenoob
77-
#+DRAFT: true
78-
#+OPTIONS: toc:t num:nil
14+
npm ci
15+
cp .blogrc.example .blogrc
16+
./build.sh
17+
make serve
7918
```
8019

81-
### Features
82-
83-
The blog includes:
84-
85-
- **Modern Design**: Clean, responsive design inspired by Claude Code docs
86-
- **Automatic Features**:
87-
- Archive/index generation with newest-first sorting
88-
- Date extraction from filenames and metadata
89-
- Cache busting for CSS/JS assets
90-
- Sitemap.xml generation for SEO
91-
- 404 error page
92-
- **Developer Experience**:
93-
- Colored build output with progress indicators
94-
- Production build with asset minification
95-
- GitHub Actions for CI/CD
96-
- Pull request preview builds
97-
- **User Experience**:
98-
- Dark mode support
99-
- Mobile responsive design
100-
- Fast page loads with optimized assets
101-
- Comprehensive syntax highlighting
102-
103-
### Syntax Highlighting
104-
105-
The blog supports syntax highlighting for code blocks through a dual approach:
106-
107-
1. **Server-side highlighting** (via htmlize.el):
108-
- Emacs Lisp, Python, JavaScript, Shell, HTML/CSS, SQL
109-
110-
2. **Client-side fallback** (via JavaScript):
111-
- Go, Rust, JSON, YAML
112-
- Automatically applied for better accuracy
20+
Open `http://localhost:8000`.
11321

114-
To add support for more languages:
22+
## Common Commands
11523

116-
1. Install the Emacs mode in `~/.config/doom/packages.el`
117-
2. Run `doom sync` to install
118-
3. Test with `./build.sh`
119-
4. If needed, extend the JavaScript fallback in `static/js/blog.js`
24+
- `make build` or `npm run build`: Build site into `public/`
25+
- `make build-prod` or `npm run build:prod`: Build and minify assets
26+
- `make serve` or `npm run serve`: Build and preview locally
27+
- `make dev`: Watch `posts/` and `static/`, then rebuild on change
28+
- `npm run format`: Format JS/CSS/JSON/MD/YAML
29+
- `npm run format:check`: Check formatting
12030

121-
### GitHub Actions
31+
## Project Layout
12232

123-
The blog includes three workflows:
33+
- `posts/`: Org source files for posts and pages
34+
- `static/`: CSS, JS, images, favicon, robots
35+
- `templates/`: Post template(s)
36+
- `build.el`: Org publish configuration
37+
- `build.sh`, `minify.sh`, `generate-sitemap.sh`: Build pipeline scripts
38+
- `public/`: Generated output (do not edit directly)
12439

125-
1. **publish.yml**: Main deployment to GitHub Pages
126-
- Triggers on push to main branch
127-
- Builds site with production optimizations
128-
- Deploys to GitHub Pages
40+
## Writing Posts
12941

130-
2. **pr-preview.yml**: Preview builds for pull requests
131-
- Generates preview artifacts
132-
- Comments on PR with build statistics
42+
Create posts in `posts/` using `YYYY-MM-DD-slug.org` naming. Include:
13343

134-
3. **ci.yml**: Continuous integration checks
135-
- Validates Org file syntax and metadata
136-
- Runs ShellCheck on scripts
137-
- Tests build process
138-
- Checks for broken internal links
44+
- `#+TITLE:`
45+
- `#+AUTHOR:`
46+
- `#+DATE:`
13947

140-
### Deployment
48+
Set `#+DRAFT: true` to keep a post unpublished.
14149

142-
#### GitHub Pages
50+
## Deployment
14351

144-
1. Enable GitHub Pages in repository settings
145-
2. Set source to "GitHub Actions"
146-
3. Push to main branch to trigger deployment
52+
Push to `main` to trigger `.github/workflows/publish.yml` and deploy to GitHub Pages.
14753

148-
#### Custom Domain
54+
For configuration, use `.blogrc` and/or repository secrets (`BLOG_URL`, `BLOG_AUTHOR`, `BLOG_EMAIL`).
14955

150-
1. Add `CNAME` file to `static/` directory
151-
2. Update `BLOG_URL` in `.blogrc` or GitHub Secrets
152-
3. Configure DNS settings with your domain provider
56+
## CI Checks
15357

154-
### Troubleshooting
58+
PRs run `.github/workflows/ci.yml`, including:
15559

156-
- **Build errors**: Check `build.sh` output for detailed error messages
157-
- **Syntax highlighting issues**: Ensure required Emacs modes are installed
158-
- **GitHub Actions failures**: Check workflow logs in Actions tab
159-
- **Local preview issues**: Ensure Python 3 is installed for local server
60+
- Org metadata validation
61+
- Shell script linting
62+
- Build verification
63+
- Internal HTML link checks

build.el

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
;;; Code:
77

88
;; Set up directories
9-
(setq blog-directory (file-name-as-directory (or (getenv "GITHUB_WORKSPACE") (expand-file-name "~/blog"))))
9+
;; Prefer explicit env vars, then CI workspace, then the directory of this file.
10+
(setq blog-directory
11+
(file-name-as-directory
12+
(expand-file-name
13+
(or (getenv "BLOG_DIR")
14+
(getenv "GITHUB_WORKSPACE")
15+
(and load-file-name (file-name-directory load-file-name))
16+
default-directory))))
1017
(setq blog-posts-directory (concat blog-directory "posts/"))
1118
(setq blog-publish-directory (concat blog-directory "public/"))
1219
(setq blog-static-directory (concat blog-directory "static/"))
@@ -101,7 +108,7 @@
101108
<link rel=\"icon\" type=\"image/svg+xml\" href=\"/static/favicon.svg\">
102109
<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">
103110
<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>
104-
<link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">
111+
<link href=\"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Source+Sans+3:wght@400;500;600&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600&display=swap\" rel=\"stylesheet\">
105112
<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/css/blog.css?v=" (or (getenv "CSS_VERSION") "1") "\" />
106113
<script src=\"/static/js/blog.js?v=" (or (getenv "JS_VERSION") "1") "\" defer></script>"))
107114

@@ -234,4 +241,4 @@
234241
(message "Blog published successfully!"))
235242

236243
(provide 'build)
237-
;;; build.el ends here
244+
;;; build.el ends here

build.sh

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ if [ "$INCREMENTAL_BUILD" != "true" ]; then
2929
echo -e "${YELLOW}Tip:${NC} Use INCREMENTAL_BUILD=true $0 to skip unchanged files"
3030
fi
3131

32+
# Emacs is required to publish Org files.
33+
if ! command -v emacs > /dev/null 2>&1; then
34+
echo -e "${YELLOW}Error:${NC} emacs is required but was not found in PATH."
35+
exit 1
36+
fi
37+
3238
# Get version numbers for cache busting based on file modification time
3339
CSS_VERSION=$(stat -c %Y static/css/blog.css 2> /dev/null || stat -f %m static/css/blog.css 2> /dev/null || echo "1")
3440
JS_VERSION=$(stat -c %Y static/js/blog.js 2> /dev/null || stat -f %m static/js/blog.js 2> /dev/null || echo "1")
@@ -41,27 +47,28 @@ export JS_VERSION
4147
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4248

4349
# Run Emacs in batch mode to publish the blog
44-
if emacs --batch \
50+
if ! emacs --batch \
4551
--load "$SCRIPT_DIR/build.el" \
4652
--funcall blog/publish-all; then
47-
echo -e "${GREEN}Build complete!${NC} HTML files generated in public/"
53+
echo -e "${YELLOW}Error:${NC} build failed."
54+
exit 1
55+
fi
4856

49-
# Generate sitemap
50-
if [ -x "./generate-sitemap.sh" ]; then
51-
./generate-sitemap.sh
52-
fi
57+
echo -e "${GREEN}Build complete!${NC} HTML files generated in public/"
58+
59+
# Generate sitemap
60+
if [ -x "./generate-sitemap.sh" ]; then
61+
./generate-sitemap.sh
62+
fi
63+
64+
# Show build statistics
65+
if [ -d "public" ]; then
66+
POST_COUNT=$(find public -name "*.html" -not -name "index.html" -not -name "index-cn.html" | wc -l)
67+
TOTAL_SIZE=$(du -sh public | cut -f1)
68+
echo -e "${GREEN}Generated:${NC} $POST_COUNT posts"
69+
echo -e "${GREEN}Total size:${NC} $TOTAL_SIZE"
5370

54-
# Show build statistics
55-
if [ -d "public" ]; then
56-
POST_COUNT=$(find public -name "*.html" -not -name "index.html" -not -name "index-cn.html" | wc -l)
57-
TOTAL_SIZE=$(du -sh public | cut -f1)
58-
echo -e "${GREEN}Generated:${NC} $POST_COUNT posts"
59-
echo -e "${GREEN}Total size:${NC} $TOTAL_SIZE"
60-
61-
if [ "$INCREMENTAL_BUILD" = "true" ]; then
62-
echo -e "${GREEN}Mode:${NC} Incremental build"
63-
fi
71+
if [ "$INCREMENTAL_BUILD" = "true" ]; then
72+
echo -e "${GREEN}Mode:${NC} Incremental build"
6473
fi
65-
else
66-
echo -e "${YELLOW}Build completed with warnings${NC}"
6774
fi

0 commit comments

Comments
 (0)