Removing orphan content/posts/ from an earlier broken sync (Contentlayer slug gotcha)

2026-04-07

Small cleanup PR, but it's worth a paragraph on why the orphans existed in the first place — the root cause is a nice little gotcha in how Contentlayer derives slugs.

The orphans

Four files under content/posts/ that were byte-identical to the same names under content/md/:

content/posts/end-to-end.md
content/posts/hello-world.md
content/posts/test-post.md
content/posts/test-post-2.md

diff confirmed byte-equality against their twins in content/md/. Nothing in the repo referenced content/posts/ — no imports, no Contentlayer config path, no route. They were pure dead weight.

Root cause

The vault-to-blog sync workflow (lives in StevieIsmagic/stevie-second-brain/.github/workflows/sync-to-blog.yml) used to rsync the vault's Published/ directory into content/posts/ in this repo. That was the wrong destination, because this repo's Contentlayer config computes slugs like this:

slug: doc._raw.flattenedPath.replace(/^(md|mdx)\//, '')

The regex strips a leading md/ or mdx/ off the flattened path, and nothing else. So:

  • A file at content/md/hello-world.md has flattenedPath = "md/hello-world" → slug hello-world → URL /blog/hello-world. ✅
  • A file at content/posts/hello-world.md has flattenedPath = "posts/hello-world" → slug posts/hello-world → URL /blog/posts/hello-world. ❌

The old sync was quietly publishing everything under /blog/posts/* instead of /blog/*. The posts existed, they rendered, they just lived at the wrong URL. Nobody noticed because they were test posts.

The fix (in two parts)

Phase 2 of the vault sync pipeline, done earlier, repointed the rsync target from content/posts/ to content/md/. That's when new posts started resolving at the correct /blog/<slug> URLs. But it didn't remove the old tree — rsync was now writing to a different destination, and the orphans under content/posts/ were left sitting there, still byte-identical, still dead.

This PR is the deletion. Four files gone, nothing imports them, nothing references them, content/posts/ is unlinked from the repo entirely.

Verification

  • diff -r content/posts/ content/md/ | grep -v '^Only in content/md' → each content/posts/*.md was byte-identical to its content/md/*.md twin.
  • grep -rn "content/posts" . (excluding .git and node_modules) → no hits after removal.
  • Any live /blog/posts/* URLs will 404 after merge. They were test posts, so intended — if anybody had bookmarked /blog/posts/hello-world I'd feel bad, but nobody did.

The cleaner fix to make this class of mistake impossible going forward would be tightening the slug regex to fail loudly on unexpected top-level directories, rather than silently keeping them in the URL. Filing that as a follow-up — not blocking this PR.


PR: https://github.com/StevieIsmagic/vercel_blog/pull/7