Skip to content

Commit 54b7ea9

Browse files
committed
Add staging directory for preview posts
- Created staging/ directory for preview-only posts - Added _config_preview.yml to include staging posts in builds - Updated preview workflow to copy modified posts to staging - Posts are staged during PR preview, moved to _posts/ after merge
1 parent eb4c4a2 commit 54b7ea9

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

.github/workflows/preview.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,32 @@ jobs:
2727
ruby-version: '3.1'
2828
bundler-cache: true
2929

30+
- name: Setup staging for preview
31+
if: github.event.action != 'closed'
32+
run: |
33+
# Copy any new or modified post files to staging directory
34+
# This allows preview of posts before they go live
35+
mkdir -p staging
36+
37+
# Find modified .md files in _posts directory from this PR
38+
git diff --name-only origin/main...HEAD | grep "^_posts/.*\.md$" | while read file; do
39+
if [ -f "$file" ]; then
40+
echo "Staging post: $file"
41+
cp "$file" "staging/$(basename "$file")"
42+
fi
43+
done
44+
45+
# List staged files for debugging
46+
echo "Staged posts:"
47+
ls -la staging/ || echo "No posts staged"
48+
3049
- name: Build Jekyll site
3150
if: github.event.action != 'closed'
3251
run: |
3352
# Remove CNAME file for previews to avoid routing conflicts
3453
rm -f CNAME
35-
bundle exec jekyll build
54+
# Build with preview config that includes staging posts
55+
bundle exec jekyll build --config _config.yml,_config_preview.yml
3656
env:
3757
JEKYLL_ENV: production
3858

_config_preview.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Preview-specific configuration
2+
# This extends the main _config.yml for preview builds
3+
4+
# Collections for staging posts
5+
collections:
6+
staging:
7+
output: true
8+
permalink: /:collection/:name/
9+
10+
# Make staging posts appear in site.posts
11+
defaults:
12+
- scope:
13+
path: "staging"
14+
type: "staging"
15+
values:
16+
layout: "post"
17+
18+
# Include staging directory in the build
19+
include:
20+
- staging

staging/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Staging Directory
2+
3+
This directory contains markdown post files that are being staged for preview before publication.
4+
5+
## Structure:
6+
- `staging/` - Contains draft/preview post files
7+
- `_posts/` - Contains published post files
8+
9+
## Workflow:
10+
1. During preview builds, new post `.md` files are copied here
11+
2. Jekyll builds the site with both `_posts/` and `staging/` content
12+
3. After review and approval, posts are moved from `staging/` to `_posts/`
13+
4. Staging directory is cleaned up after merge

0 commit comments

Comments
 (0)