Urgent.News

What's breaking now, across thousands of outlets.

Tech

GitHub Contents API CMS in Next.js: Publish Markdown Without a Database

You can publish from a browser without running a database: an admin form commits a Markdown file to your GitHub repo, and the host redeploys. This post shows that GitHub Contents API CMS pattern in Next.js 16 (App Router), the one rule that trips people up ( sha ), and how to handle a 409. Status first: I built this admin and ran 41 API checks against mock GitHub, dev.to and IndexNow servers. I…

Publishing Markdown articles without a database is possible thanks to the GitHub Contents API in Next.js 16 (App Router). To create or update an article, a user submits a PUT request to the GitHub API, specifying the file path, the article content as a base64-encoded string, and the branch to commit to. If the branch is not specified, the article will be committed to the "main" branch.

The GitHub Contents API is set up as a CMS by creating Markdown files in the "content/articles/" directory, with the slug of the article used as the file name (e.g., "slug.md"). The server-side admin runs within the same Next.js app, keeping the GitHub token secure and out of the browser.

To authenticate with the GitHub API, a fine-grained personal access token is required, with read and write permissions limited to the specific repository. The token should be stored as an environment variable (GITHUB_TOKEN) rather than a publicly exposed variable. Once the token is set up, it can be used to read and write files in the repository.

When reading an article, the server sends a GET request to the GitHub API with the article's slug and branch specified. If the article is found, the server extracts the Markdown content from the response and returns it. If the article is not found, the server returns null.

To write an article, the server sends a PUT request with the article's slug, Markdown content, and current SHA (if available). If the file does not exist or the SHA is stale, the server will return a 409 error. In this case, the server should inform the editor instead of retrying the request.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why we hand over the domain, code and accounts

A website has a visible part and an invisible part. The visible part is what people see when they open the address: pages, type, images.

  • Domain ownership is crucial for website control.
  • Hosting and code access ensures site migration.
  • Comprehensive account map enables smooth operation.

n8n for Beginners in 2026: What It Is, What It Costs and a 6-Step First Workflow

n8n is a workflow automation tool. You connect apps with visual blocks called nodes, and n8n moves data between them when something happens, such as a new form answer or a set time.

  • n8n is a visual workflow automation tool connecting apps via nodes
  • Offers free Community Edition and paid Starter, Pro, Business plans
  • Six-step guide to create first workflow in n8n

My fix was one line. Code review found two holes in it.

The bug I fixed in Microsoft Agent Framework did not crash anything. That is what made it worth fixing. When the framework called Gemini without streaming, the response knew which model had answered.

  • Single-line fix discovered two issues in Microsoft Agent Framework
  • Streaming parser lost model name, causing metric and latency problems
  • Fix remembered server's version throughout stream, resolved fallback issues

More from Friday 16 October →