npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@softure-ai/blog

v0.5.4

Published

SOFTURE AI blog module: articles and glossary terms kept as Markdown files with a strict YAML frontmatter (extendable by the app's own fields), stored in the module's Postgres schema by the softure-blog publish command (dry run by default, all or nothing,

Readme

@softure-ai/blog

Articles and glossary terms kept as Markdown files in the app's repository, and a publish command that brings the module's tables to the state of those files. The files are the source of truth: there is no editor and no CMS, a text changes only through a commit and softure-blog publish.

1. What it provides

  • A strict article file format: a YAML frontmatter with English keys (an unknown key is an error), extendable by the app's own fields, then the Markdown body.
  • blog.articles and blog.slug_history with database constraints for every invariant that fits one.
  • softure-blog publish: a dry run by default; with --commit, all files or none; unchanged files are skipped by their content hash; a slug change keeps the old slug as a redirect; one pillar per cluster. Files from paths or from standard input (--stdin, for a release through an ssh pipe), a line contract for scripts (--format lines), and the dates and old slugs of an existing blog imported on the first publish (--history).
  • Read functions for the pages: getPublishedArticle, findArticleBySlug, findSlugRedirect, listArticles.
  • renderArticle(markdown, options): the body as safe HTML on the server (no raw HTML, safe link schemes only, marked external links, images under the app's image policy), heading ids and an optional table of contents, glossary links on the first mention of a term, block plugins for the app's own fenced blocks and ::directive{…} lines, reading time.
  • Pages, each mounted with one re-export line (@softure-ai/blog/next): the listing grouped by cluster with the pillar first, an article (dates, summary, contents, FAQ, sources, signature, disclaimer, BlogPosting/BreadcrumbList/FAQPage JSON-LD), the glossary index and a term page (DefinedTerm, the articles that explain it), the optional "how our texts are made" page, an article's OG card. Their canonical, Open Graph, JSON-LD and feed URLs follow @softure-ai/seo's origin, host and trailing-slash rule when the app lists seo() (core's getSiteUrls), and appOrigin otherwise.
  • createBlogRedirects (@softure-ai/blog/proxy): 301 from an old slug, 410 for a withdrawn text, in the app's proxy.ts; createBlogMarkdown answers an article or term asked for with Accept: text/markdown with its Markdown (toArticleMarkdown), for agents.
  • @softure-ai/blog/styles.css: the pages and the rendered body on the --sft-* tokens.
  • Discovery: an RSS 2.0 feed (serveBlogRss), "read next" under every article (its cluster first, the pillar on top), and, with @softure-ai/seo (optional): sitemap entries with each text's real lastmod (blogSitemap()) and an IndexNow submit of the changed addresses after softure-blog publish --commit (submitBlogChanges for an app's own publishing path), or, with @softure-ai/jobs (optional), a blog.indexnow job that the app's worker submits with retries (@softure-ai/blog/jobs).
  • A cache refresh route (refreshBlogCache, rate-limited through @softure-ai/security, a secret from BLOG_REFRESH_SECRET): softure-blog publish --commit calls it before the IndexNow submit, so the running app shows the change at once instead of after revalidateSeconds.
  • A text quality gate: softure-blog check reports structure, link, style, voice and YMYL findings with file and line, and publish refuses a text going public with an error. Language rulesets (en, pl), severity overrides and rule plugins for the app's own domain; numbers next to a data block checked against the block, fact rules for values the app knows per year, and softure-blog refresh listing the texts whose numbers wait for a check.
  • softure-blog skill install: an agent skill for writing the texts, generated from the gate's rules and the app's config, with --check for CI.

2. Installation

npm install @softure-ai/blog @softure-ai/ui

@softure-ai/ui is a peer dependency (any 0.1.x), like the optional @softure-ai/security, @softure-ai/seo and @softure-ai/jobs: the app installs it once, so the theme tokens come from one copy. Importing @softure-ai/blog/styles.css from JavaScript is safe with tree-shaking, because the package marks its CSS as a side effect.

Then add blog() to the modules of softure.config.ts and run softure migrate.

3. Configuration

import { blog } from "@softure-ai/blog";
import { de } from "./messages/de"; // the app's own translation
import { z } from "zod";

blog({
  // The folder `softure-blog publish` reads when no path is given. Default: "content/blog".
  contentDir: "content/blog",
  // Extra slugs an article may not take. The routes' own segments (the glossary, the method page
  // when on) are reserved by themselves. Default: none.
  reservedSlugs: [],
  // The app's own frontmatter keys, checked by the app's schema. Default: none.
  fields: z.object({ scenario: z.string().regex(/^[a-z]=\d+(&[a-z]=\d+)*$/).optional() }),
  // The pages' brand: title suffix, signature, JSON-LD author and publisher, OG card colours (hex)
  // and fonts (§8). Default: none (no suffix, no author, the ui theme's dark colours, next/og's font).
  // colors.muted is the OG card's label line (default: the foreground).
  brand: { name: "Example", colors: { background: "#0b0b0c", foreground: "#f5f5f5", accent: "#7aa2f7" } },
  // Mount the method page at routes.method. Default: false (the route answers 404).
  methodPage: true,
  // The texts are written by an AI model: the method page opens with the disclosure (AI Act art. 50(4),
  // method.aiTitle / method.aiBody) and "who writes" says method.whoBodyAi. Default: false.
  aiDisclosure: false,
  // A note under every article and term, per locale (en required). Default: none.
  disclaimer: { en: "Education, not financial advice.", de: de.blog.disclaimer },
  // The heading of each cluster on the listing, per locale; a missing key shows the key. Default: {}.
  clusters: { "investing-basics": { en: "Investing basics", de: de.blog.investingBasics } },
  // Block plugins of renderArticle, used by the pages. Default: [].
  blocks: [],
  // Hosts of the app besides APP_ORIGIN's and seo's canonical host, whose links are not external. Default: [].
  siteHosts: ["www.example.com"],
  // What follows an external link in a body: "icon-and-text" (a ↗ hidden from screen readers and a
  // visually hidden "opens in a new tab"), "text" (the hidden words only) or "none". Default: "icon-and-text".
  externalLinkMarker: "icon-and-text",
  // The `@id` fragments of the JSON-LD nodes (no `#`): `<url>#article`, `<term url>#term`,
  // `<glossary url>#glossary`. An app that already published other fragments keeps them here.
  jsonLd: { ids: { article: "article", term: "term", glossary: "glossary" } },
  // The listing's cluster sections are `<cluster>-<key>`; an article's middle breadcrumb points there.
  // Default: { cluster: "cluster" }.
  anchors: { cluster: "cluster" },
  // The language tags per locale: `bcp47` for JSON-LD inLanguage and the feed's <language> (default:
  // the app's locale), `openGraph` for og:locale (language_TERRITORY; default the locale's likely one, "en_US" for
  // "en", "de_AT" for "de-AT"). Keys are any BCP 47 tag.
  locales: { de: { bcp47: "de-DE", openGraph: "de_DE" } },
  // The 410 page of a withdrawn text: extra links, or the app's own body (§4). Default: one link to the listing.
  gonePage: { links: [] },
  // Which images bodies may show: site paths and https images on these hosts (subdomains included),
  // with a width and height the app knows. Used by the pages and the quality gate. Default: none
  // (every image renders as its alt text and the gate refuses it).
  images: { hosts: ["cdn.example.com"], dimensions: (src) => imageSizes[src] ?? null },
  // How long the cached reads hold; keep equal to the pages' `revalidate`. Default: 300.
  revalidateSeconds: 300,
  // The app's own sections of the generated writing skill (see "The writing skill"). Default: none.
  skill: { sections: [] },
  // Every route can move: blog({ routes: { index: "/articles" } }).
});

Routes: index /blog (articles at /blog/<slug>), glossary /blog/glossary (terms at /blog/glossary/<slug>), method /blog/how-we-write.

fields may not reuse a key of the module (FRONTMATTER_KEYS). Its parsed value is stored in articles.fields, enters the content hash and must be plain JSON.

The quality gate

On by default with the en ruleset; quality: false turns it off. Every key is optional:

blog({
  quality: {
    language: "pl",                        // the ruleset: "en" (default) or "pl"
    ymyl: { ownCalculationMark: "our calculation" }, // or true / false (default): sources, sourced numbers, no profit promises
    voice: {
      forbidFirstPersonSingular: true,     // texts signed by the editors: no "I", "my"
      // a global RegExp; wordPattern (from @softure-ai/blog) adds the i flag and word edges in any alphabet
      phrases: [{ id: "finance-cliche", pattern: wordPattern("in the world of finance"), message: "say what happens instead" }],
    },
    limits: { words: { article: { min: 600, max: 4000 } }, answerWords: 70 }, // the defaults
    severity: { exclamation: "error", "lead-number": "off" }, // per rule: "error", "warning" or "off"
    paths: { terms: "/glossary" },  // only to override the routes: articles default to routes.index, terms to routes.glossary
    ownOrigins: ["https://www.example.com"], // absolute links that count as internal, besides appOrigin and seo's origin
    appDir: "src/app",                     // routes for internal links; default src/app, else app
    privateRouteSegments: ["api", "(app)"], // route folders that are no link target; default ["api"]
    plugins: [factsPlugin],                // the app's own rules, see Hooks
    blocks: [chartBlock],                  // the block plugins of renderArticle: their requires (and numbers) are checked
    facts: [ikeLimit],                     // values the texts quote that the app knows per year (below)
  },
});

The rules, by group (listQualityRules(getQualitySettings(config)) lists them with their effective severity; the writing skill is kept in step with it):

| Group | Rules (errors bold) | | --- | --- | | file | file: the frontmatter parses and the slug equals the file name | | structure | title-length, description-length, as-of-future, stale, summary-missing, lead (a paragraph first), lead-length, lead-number, heading-h1, heading-order, sections (two ##), section-question, section-answer, section-answer-length, length (a warning above the maximum), footnote-undefined, footnote-unused | | links | internal-links (a warning for a term), internal-link-target (check only), external-link-https, external-link-dead (--external only), term-form-conflict (check only: a checked published term shares a form with another published term; publish refuses it whatever its severity) | | images | image-source (a site path or a host of blog({ images }); every image while the app has no policy), image-alt, image-dimensions (the policy's dimensions knows it) | | style (ruleset) | announcement, these-days, not-only-but-also, not-x-but-y, not-x-but-y-bare (pl; an error in copy), verdict-label, fragile-spot, meta-commentary, throat-clearing, empty-conclusion, crucial, plays-a-role, puffery, chatbot-phrases, emoji, filler-words, exclamation, straight-quotes (pl), title-case-heading (pl) | | style (rhythm) | dashes, dashes-paragraph, bold-density, bold-labels, triads, long-sentences, monotone-rhythm, repeated-openings, stacked-asides | | voice | first-person-singular and the app's phrases, when configured | | ymyl | sources-missing, source-https, number-source, footnote-source, footnote-not-in-sources, profit-promise, when ymyl is on | | blocks | block-requires: a fenced block of a block plugin has the frontmatter keys it requires, when blocks is set; block-numbers: every significant number of the paragraph right before and right after a block is one of the block's numbers, when a block plugin has numbers | | facts | the app's fact rules (quality.facts), each under its own id | | plugin | the plugins' rules, plugin-failed, plugin-rule-undeclared |

Style patterns match the prose of the body and the title, description and summary (errors only there). A warning pattern is reported once per text with its count. A significant number is an amount, a percentage or a number from 1000 up, in the ruleset's notation; years, ages, small counts and legal references ("art. 27", "section 401") need no source. Messages are English: they are read by developers and by the agents that write the texts.

Copy that is not an article. Landing and calculator text, a post pasted into a forum or a social network, a list mail: checkCopyText(text, { mode, quality }) (/server) runs the ruleset's patterns, the app's voice, the profit promises (with ymyl) and the rhythm rules over plain paragraphs, with no frontmatter, structure, links or facts. Pass the same quality object as blog({ quality }); language, voice, ymyl, limits and severity apply, and invalid options throw.

import { checkCopyText, formatFinding, hasQualityErrors } from "@softure-ai/blog/server";

const { findings } = checkCopyText(post, { mode: "channel", quality: { language: "pl" } });
if (hasQualityErrors(findings)) throw new Error(findings.map(formatFinding).join("\n"));

Lines count from 1 in the text given. Copy is judged stricter than an article, since one tell weighs more in a short text:

| Rule | In copy | | --- | --- | | a ruleset pattern with copySeverity | that severity (not-x-but-y-bare is an error) | | stacked-asides | an error: two worded asides (two words of two letters or more; formula variables do not count) in one sentence, or three in a post of up to 300 words | | dash-pivot | an error: a spaced em or en dash between words, or an em dash glued to two words (small—they); a dash with a number on both sides is a range and passes (2020 – 2024, 20% – 30%) | | channel-markup | mode: "channel" only, an error per kind of markdown a plain-text editor shows as is: bold, italics, headings, bracket links, embedded images, quotes, tables, inline code, code blocks, rules, HTML. Bare URLs and - / 1. lists pass; bold-density and bold-labels are left to it |

mode: "copy" (the default) reads markdown as prose, for text the app renders itself. dash-pivot and channel-markup are copy rules only: the article catalog and the writing skill do not list them.

Numbers next to a block. A block plugin with numbers(block) (the block's numbers, as numbers or as strings in the ruleset's notation) gets the block-numbers rule: the significant numbers of the paragraph right before the block and right after it must each equal one of them, so the prose and the chart or table cannot drift apart. A percentage compares by its number (4.5 for "4.5%"). A throwing numbers is a block-numbers error, not a crash.

Fact rules. A value a text quotes that the app knows per year (a contribution limit, a tax rate):

import { factRule } from "@softure-ai/blog/server";

export const ikeLimit = factRule({
  id: "ike-limit",
  description: "the yearly IKE contribution limit",
  // a sentence that quotes the value; group 1, when there is one, is where the value stands
  patterns: [/IKE limit\D*(\d.*)/i, /limit (?:of|for) IKE/i],
  allowedValues: (year) => ({ 2025: [2_652_000], 2026: [2_826_050] })[year], // nothing: the year is not checked
  unit: "cents",       // "value" (default), "cents" or "bps": the values are hundredths of the text's number
  expires: "yearly",   // "yearly", "quarterly" or "never" (default), for softure-blog refresh
  severity: "error",   // default
  onUnknownYear: "warn", // "skip" (default) or "warn": no year of the sentence has values
});

In every sentence of the body that matches a pattern, the value is the first number (years and legal references skipped) of group 1 of the first pattern that captures one, so "Paying in 1,000 a month keeps you under the IKE limit of 28,260.50" reads 28,260.50. Without such a group (none, or no number in it) the value is the first number of the sentence. The sentence's years are every year it names, else the year of current_as_of; the value passes when it is one of allowedValues(year) for any of them, and is otherwise a finding of the rule's id. When none of the years has values, the sentence passes unchecked, or with onUnknownYear: "warn" is a warning of the rule's id ("no value known for 2031"; quality.severity overrides it like any finding of the rule). The rules join the catalog (group facts), so the writing skill lists them.

Texts to refresh. softure-blog refresh [<path>...] [--today <YYYY-MM-DD>] lists, without a database, the published texts whose numbers wait for a check: current_as_of older than limits.staleAfterDays, or a quoted fact rule whose value changed (its year or quarter began) after current_as_of. It exits 0: it reports, it does not gate. findTextsToRefresh(files, settings, today) (/server) is the same list for an app's own report.

The article file

One file per text, named <slug>.md:

---
id: index-funds            # stable key, given once; never change it
slug: index-funds          # the address; equals the file name without .md
kind: article              # article | term (a glossary definition); default article
forms: [tax wrapper]       # term only, required: the phrases that link to the definition
cluster: investing-basics  # the topic for "read next" lists; optional
pillar: true               # the main text of its cluster: one per cluster, needs cluster; default false
title: Index funds in plain words
description: One or two sentences for search results and the social card.
summary: A few sentences with numbers for the "in short" box; optional.
status: published          # draft | published | withdrawn
current_as_of: 2026-10-01  # the day the facts were checked
published_at: 2026-10-01   # optional; a day (midnight UTC) or a moment with an offset; default: first publication
sources:
  - name: Fund factsheet
    url: https://example.com/factsheet
faq:
  - question: Is it safe?
    answer: It follows the market, up and down.
---

The Markdown body.

Rules:

  • Slug change: change slug and rename the file, keep id. The old slug goes to the slug history and redirects to the new one. A slug another article has now, or had before, is refused.
  • Glossary forms: a form belongs to one published term (forms equal up to a capital first letter are one). publish refuses a run that leaves a form with two terms, one of them in the run, naming the form and both slugs; a conflict only between stored terms is a warning. check reports it as term-form-conflict. The renderer links such a form to the first term it was given.
  • Withdrawal: status: withdrawn. The row stays and its address answers 410. Do not delete the file: a deleted file changes nothing in the database.
  • Update date: updated_at moves by itself when the content of a published text changes (title, description, summary, body, date of the facts, sources, FAQ, cluster, forms, fields), never on a status, slug, publication date or pillar change alone.

4. Mounting

Each page is one file in the app. Next reads dynamic and revalidate only as literals in the app's own file, so they stay there; revalidate should equal revalidateSeconds.

// app/blog/page.tsx: the listing, rendered per request over cached reads
export { BlogIndexPage as default, generateBlogIndexMetadata as generateMetadata } from "@softure-ai/blog/next";
export const dynamic = "force-dynamic";

// app/blog/[slug]/page.tsx: an article, kept for 300 s (ISR); slots take the app's components
import { BlogArticlePage, type BlogArticlePageProps } from "@softure-ai/blog/next";
export { generateArticleMetadata as generateMetadata, generateBlogStaticParams as generateStaticParams } from "@softure-ai/blog/next";
export const revalidate = 300;
export default function Page({ params }: Pick<BlogArticlePageProps, "params">) {
  return <BlogArticlePage params={params} cta={<MyCta />} afterArticle={<Waitlist placement="blog" />} />;
}

// app/blog/[slug]/opengraph-image.tsx
export { BlogArticleOgImage as default, generateBlogStaticParams as generateStaticParams } from "@softure-ai/blog/next";
export const size = { width: 1200, height: 630 };
export const contentType = "image/png";
export const revalidate = 300;

// app/blog/glossary/page.tsx          GlossaryIndexPage, generateGlossaryIndexMetadata; dynamic = "force-dynamic"
// app/blog/glossary/[slug]/page.tsx   GlossaryTermPage, generateTermMetadata, generateBlogStaticParams; revalidate
// app/blog/how-we-write/page.tsx      BlogMethodPage, generateMethodMetadata (with methodPage: true)

// app/blog/rss.xml/route.ts: the feed of published articles and terms, linked from the listing and articles
export { serveBlogRss as GET } from "@softure-ai/blog/next";
export const dynamic = "force-dynamic";

With @softure-ai/seo, the blog joins its sitemap through a contributor; app/sitemap.ts must then be force-dynamic (the contributor reads the database):

// softure.config.ts (the root entry: this file also loads in plain Node and in bundles outside Next)
import { blog, blogSitemap } from "@softure-ai/blog";
seo({ sitemap: { contributors: [blogSitemap()] }, indexNow: { key: "..." } });

The entries are the listing, the articles, the glossary and its terms, each dated by its last content change (updated_at, else published_at), and the method page without a date; an empty listing or glossary is left out (it is noindex). Paths only: seo makes them absolute with its canonical rule. The contributor reads with one query per sitemap request, not through the pages' Next cache.

A publish from the command runs outside the app and cannot reach its cache. To show the change at once instead of after revalidateSeconds, mount the refresh route, list security() with the blog's bucket, and set one secret (32+ characters, e.g. openssl rand -base64 32) as BLOG_REFRESH_SECRET for both the running app and the command:

// app/api/blog/refresh/route.ts (routes.refresh, default /api/blog/refresh)
export { refreshBlogCache as POST } from "@softure-ai/blog/next";

// softure.config.ts
import { BLOG_RATE_LIMIT_BUCKETS, blog } from "@softure-ai/blog";
security({ clientIp: cloudflareIp(), buckets: { ...BLOG_RATE_LIMIT_BUCKETS } });

The route counts every request in the blog-refresh bucket (10 per 15 minutes per client address; callers without one, such as the command on a private network name, share one count) before it checks Authorization: Bearer <secret>, then expires the blog's cache tag at once (revalidateTag(BLOG_CACHE_TAG, { expire: 0 }): the next request reads the tables, the cached pages included). Answers: 204 refreshed, 401 a missing or wrong secret, 429 over the bucket (retry-after), 503 when counting fails, 500 when BLOG_REFRESH_SECRET is unset or short (logged by name). Without security() or its bucket the route throws a setup error naming the fix.

301 and 410 are answered before the page, in proxy.ts (Node.js runtime, Next 16):

import { createBlogRedirects } from "@softure-ai/blog/proxy";
const blogRedirects = createBlogRedirects(softureConfig);

export async function proxy(request: NextRequest) {
  return (await blogRedirects(request)) ?? NextResponse.next();
}

createBlogProxy (below, under "Markdown for agents") answers Markdown first and then the redirects. It handles GET and HEAD on the blog's text paths only, keeps the query on a redirect, remembers a decision for 60 s (ttlMs) and passes a request on when the database fails. Import the styles after ui's: @import "@softure-ai/blog/styles.css";. A data change shows after revalidateSeconds, or at once with revalidateTag(BLOG_CACHE_TAG, { expire: 0 }) (the refresh route above, for the command). Custom OG fonts: an own opengraph-image.tsx calling renderArticleOgImage({ title, label, brand, fonts }).

Articles on the app's own pages. getFeaturedArticles(config, { limit }) (/next) answers published articles for a featured strip, the pillars first and then the newest (selectFeaturedArticles in /server is the pure part). On a prerendered page (a home page), getStaticPublishedArticles(config) answers none during next build (there is no database) and none, logged, when the read fails, so the page still renders; readForStaticPage(read, { onError }) (/server) wraps any read the same way.

The content folder in scripts. readArticleDir(dir) (/server and /cli) reads the folder as softure-blog does: every *.md file directly in it except README.md, sorted by name, as { ok: true, files: [{ name, text, path }] }, or { ok: false, error }. A test store or a script hands the files to runBlogPublish or checkArticleFiles.

The quality gate resolves internal links under the blog's routes (index for articles, glossary for terms), so moving a route moves the check with it; quality.paths only overrides them.

The 410 page carries the module's copy (gone.*) and one link to the listing. gonePage.links adds further ways on (a path from the site root or an https URL, a label per locale, at most five), and gonePage.render writes the whole body with the app's own HTML and styles; the proxy still answers 410 with text/html:

blog({
  gonePage: {
    links: [{ href: "/calculator", label: { en: "Try the calculator", de: de.blog.goneCalculator } }],
    // or the whole page: (input) => html, with input.copy, input.lang, input.indexPath, input.links
    render: ({ copy, lang, indexPath, links }) => renderMyGonePage({ copy, lang, indexPath, links }),
  },
});

Own page components. An app whose blog keeps its own look mounts its own pages and keeps the rest. generate*Metadata, generateBlogStaticParams and BlogArticleOgImage mount next to its own page as above. For a text the app already read (getTextBySlug), /next builds the same metadata and JSON-LD the ready-made pages use, with no database read, so the app can extend them:

// app/blog/[slug]/page.tsx with the app's own view
import { buildArticleJsonLd, buildArticleMetadata, getTextBySlug } from "@softure-ai/blog/next";
import { getSoftureConfig } from "@softure-ai/core/next";
import { notFound } from "next/navigation";

export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
  const config = getSoftureConfig();
  const article = await getTextBySlug(config, (await params).slug);
  return article?.status === "published" && article.kind === "article" ? buildArticleMetadata(config, article) : {};
}

export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
  const config = getSoftureConfig();
  const article = await getTextBySlug(config, (await params).slug);
  if (article?.status !== "published" || article.kind !== "article") notFound();
  return (
    <MyArticleView article={article}>
      <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: buildArticleJsonLd(config, article) }} />
    </MyArticleView>
  );
}

The builders: buildBlogIndexMetadata(config, { isEmpty, images }), buildArticleMetadata(config, article), buildGlossaryIndexMetadata(config, { isEmpty, images }), buildTermMetadata(config, term), buildMethodMetadata(config, { images }), buildArticleJsonLd(config, article), buildTermJsonLd(config, term) and buildGlossaryJsonLd(config, terms) (null without terms); the JSON-LD comes serialized, safe inside a <script>. getCrumbLabels(config) gives the breadcrumb names for getArticleCrumbs/getTermCrumbs (/server); getPageContext, renderPageBody and getRelatedArticles render the rest, and RelatedList (/ui) renders the "read next" section from getRelatedArticles' result.

Every page's openGraph carries og:locale. Next replaces the layout's openGraph with the page's object (no deep merge), so the static pages (listing, glossary index, method page) would lose the layout's card: pass it as images, e.g. buildBlogIndexMetadata(config, { isEmpty, images: [{ url: "/opengraph-image", width: 1200, height: 630 }] }). Articles and terms point at their own card.

A body and a term's "explained in these texts" list take the input the ready-made pages build, so an own page links and lists exactly as they do:

const [articles, terms] = await Promise.all([getPublishedArticles(config), getPublishedTerms(config)]);
const body = renderPageBody(term, getBodyOptions(config, terms)); // renderPageBody from /server
const explainedIn = findArticlesLinkingTermFor(config, { articles, termSlug: term.slug, terms });

getBodyOptions(config, terms) is the RenderPageBodyOptions of the pages (the glossary, routes, blog options, appOrigin and the canonical site origin, the copy); findArticlesLinkingTermFor is findArticlesLinkingTerm (/server) over it. It reads the links without rendering the articles, so no block plugin runs on a term page.

What the builders write, so an app moving published pages onto them can match its old output:

  • the JSON-LD @id fragments, the cluster anchor and the language tags come from jsonLd, anchors and locales (above);
  • a page title is pages.titleWithBrand ({title} | {brand}), a glossary term's glossary.termTitleWithBrand; override either message per locale;
  • canonical, Open Graph and JSON-LD URLs are absolute on the site origin (@softure-ai/seo's when listed);
  • articles and terms carry og:published_time and og:modified_time, the days the page shows;
  • buildGlossaryJsonLd gives null without terms (an empty DefinedTermSet says nothing).
  • the glossary index's DefinedTermSet (name, description, url per term) is what @softure-ai/agent-ready's WebMCP findTerm reads, so a rendered glossary needs nothing more for that tool.

Any field can still be replaced by spreading the result: { ...buildTermMetadata(config, term), title }.

getBodyOptions, findArticlesLinkingTermFor and getPageContext need no request scope: /server exports the same functions, for a renderer outside Next.

The package's views in the app's look. An app with its own design system keeps the views and gives them its classes, its page frame and its cards. Every ready-made page takes view (and the listing renderCard); a view from /ui reads the same fields from its context:

// app/blog/[slug]/page.tsx
import { BlogArticlePage, type BlogArticlePageProps } from "@softure-ai/blog/next";
import { Breadcrumbs, type BlogLayoutSlotProps, type BlogViewOptions } from "@softure-ai/blog/ui";

function BlogFrame({ context, title, lead, crumbs, meta, children }: BlogLayoutSlotProps) {
  return (
    <PageFrame title={title} lead={lead} aside={meta}>
      {crumbs === undefined ? null : <Breadcrumbs crumbs={crumbs} label={context.messages.pages.breadcrumbs} context={context} />}
      {children}
    </PageFrame>
  );
}

const view: BlogViewOptions = {
  classNames: { article: "prose", card: "card", cardTitle: "card-title", visuallyHidden: "sr-only" },
  unstyled: true, // only the app's classes; leave it out to add them after the package's
  layout: BlogFrame, // the app's frame instead of <main class="blog-page"> and its header
  disclaimer: <p>Education, not financial advice. <a href="/terms">Terms</a></p>,
};

export default function Page(props: BlogArticlePageProps) {
  return <BlogArticlePage {...props} view={view} />;
}
// app/blog/page.tsx: <BlogIndexPage view={view} renderCard={({ article, href, isLead }) => <AppCard … />} />
  • classNames names the element, the class without blog- in camelCase: page, header, title, lead, crumbs, card, cardLead, cardTitle, article, section, disclaimer… (BLOG_SLOT_CLASSES lists them with their defaults). The "read next" list has related, relatedTitle, relatedList and relatedItem; the last three have no default class (styles.css styles them through .blog-related). The app's class follows the package's, which sits in the softure layer, so it wins.
  • unstyled drops the blog-* classes. Text meant for screen readers only keeps blog-visually-hidden until classNames.visuallyHidden names the app's own class.
  • layout gets { context, title, lead, crumbs, meta, children }; without it the markup is the package's.
  • renderCard gets { article, href, isLead, context } and replaces the card inside its list item.
  • disclaimer replaces the configured one: a string renders in a paragraph, any other node as given.

The method page's copy is messages.method, one paragraph per section. When a section needs more (a list of the checks, a link to the app's calculator, a mailto: address for corrections), BlogMethodPage and BlogMethodView take sections, the app's own in place of the default five:

// app/blog/how-we-write/page.tsx
import { BlogMethodPage, generateMethodMetadata } from "@softure-ai/blog/next";
import type { BlogMethodSection } from "@softure-ai/blog/ui";

const sections: BlogMethodSection[] = [
  { id: "checks", title: "What we check", body: <ul><li>Every number against its source</li></ul> },
  { id: "calculator", title: "Our calculator", body: <p>The numbers come from <a href="/calculator">the calculator</a>.</p> },
  { id: "corrections", title: "Corrections", body: <p>Write to <a href="mailto:[email protected]">[email protected]</a>.</p> },
];

export default function Page() {
  return <BlogMethodPage sections={sections} />; // `view` as on the other pages
}
export { generateMethodMetadata as generateMetadata };
  • id is the section's anchor (#checks) and heading id; a string body renders in a paragraph, any other node as given.
  • The sections replace all five defaults, "who writes" included. With aiDisclosure the disclosure section (id ai) still opens the page, so no section may take that id, and the app's own "who writes" must not claim human editorial control. The signature and the disclaimer still close the page.

The commands:

softure-blog publish [<path>...] [--commit] [--withdraw] [--no-indexnow] [--app-url <origin>]
                     [--stdin [--name <slug>.md]] [--history <file.json>] [--format text|lines] [--config <file>]
softure-blog check [<path>...] [--external] [--today <YYYY-MM-DD>] [--config <file>]
softure-blog skill install [--dir <path>] [--command <cmd>] [--check] [--config <file>]
  • <path> is a file or a folder (every *.md but README.md, by name); without one, contentDir.
  • --commit writes; without it the command prints what it would do and writes nothing.
  • --withdraw publishes the one given file as withdrawn (taking a text down at once); set the file's status too, or the next full publish brings the text back.
  • A done run prints one cache: line. With BLOG_REFRESH_SECRET set, a commit that changed a text posts to the app's refresh route on appOrigin (--app-url <origin> for another way in, such as http://web:3000 in a container network; redirects are not followed) before the IndexNow submit; a dry run prints the address. Without the secret the line says the app shows the change after revalidateSeconds. A failed refresh is a warning naming the answer: the publish stays written, the IndexNow submit still goes out and the exit code stays 0. --no-indexnow does not skip it.
  • With seo({ indexNow: { key } }) enabled, a run ends with one indexnow: line. A commit submits the addresses whose answer changed (a text public before or after, its old slug after a rename, the listing or the glossary of its kind) as canonical URLs on seo's origin; a dry run prints them; --no-indexnow skips the submit (e.g. a local or CI database). A failed submit is a warning: the publish stays written and the exit code stays 0. With a blog.indexnow queue in jobs({ queues }), a commit enqueues the submit instead and prints indexnow: queued <n> URL(s) as job <id> on blog.indexnow ("already queued as job " while a job with the same addresses waits); the worker sends it ("The IndexNow submit as a job" below). A dry run still prints the URLs.
  • --stdin reads the files from standard input instead of paths: with --name <slug>.md, the one file's text; without it, a JSON bundle {"files":[{"name":"<slug>.md","text":"…"}]} (a whole folder, and optionally "history", the content of a --history file, so a container needs no file for it). A release that publishes inside a container through an ssh gateway pipes the content in, so the image needs no copy of content/. --stdin takes no paths; --withdraw with it needs --name.
  • --history <file.json> imports the earlier life of an existing blog (see "Moving an existing blog in").
  • --format lines prints the line contract below instead of the text for people.
  • Exit codes: 0 done, 1 refused or failed (nothing written), 2 usage error.

Output, one line per text, then a summary:

added index-funds none -> published/index-funds
changed bonds draft/bonds -> published/bonds
moved bonds bond-basics -> bonds
summary: added 1, changed 1, unchanged 12
dry run: nothing written; pass --commit to write

The line contract (--format lines), for a release script that greps the output. Every line goes to standard output and starts blog|; fields are separated by |, and a | or a line break inside a value becomes a space. Keys are stable: a new one may be added, an existing one never changes meaning. A run prints exactly one outcome line: blog|written, blog|dry-run, blog|refused or blog|failed|<message>.

blog|warning|<subject>|<message>
blog|error|<subject>|<message>
blog|change|<added|changed|unchanged>|<id>|<status/slug before, or none>|<status/slug after>
blog|moved|<id>|<old slug>|<new slug>
blog|imported|<id>|<published_at ISO, or none>|<old slugs>
blog|summary|<added>|<changed>|<unchanged>
blog|written
blog|cache|off|<revalidateSeconds>         | skipped | dry-run|<url> | refreshed|<url> | failed|<code>|<reason>
blog|indexnow|off|<reason>                 | skipped | dry-run|<count>|<urls> | submitted|<count>|<status>|<paths> | failed|<code>|<reason>|<paths>
               | queued|<count>|<job id>|<new|duplicate>|<paths>
# A release step: the content goes in on stdin, the contract comes back.
node -e 'const fs = require("fs"); const dir = "content/blog";
  const files = fs.readdirSync(dir).filter((n) => n.endsWith(".md") && n !== "README.md").sort()
    .map((name) => ({ name, text: fs.readFileSync(`${dir}/${name}`, "utf8") }));
  process.stdout.write(JSON.stringify({ files }))' > bundle.json
OUT="$(ssh deploy@host 'docker compose exec -T app node blog.cjs publish --stdin --commit --format lines' < bundle.json)"
grep -q '^blog|written$' <<< "$OUT" || { grep '^blog|\(error\|failed\)' <<< "$OUT"; exit 1; }

Moving an existing blog in. An app that already published its texts from its own tables keeps their published_at (often only in its database, not in the files), their updated_at and their old slugs with --history <file.json>. On the first publish of each article (no row in blog.articles yet), the article takes published_at from the history unless its file sets one, updated_at from the history, and its old slugs enter blog.slug_history (301s keep working); the run prints imported for it. An article that already has a row ignores its entry, so the same file can stay in a release script; an entry for an article outside the run is a warning. An old slug another article holds refuses the run.

{
  "articles": [
    {
      "id": "index-funds",
      "published_at": "2026-03-01T08:00:00+01:00",
      "updated_at": "2026-06-15T10:30:00Z",
      "old_slugs": [{ "slug": "what-is-an-index-fund", "changed_at": "2026-04-01T00:00:00Z" }]
    },
    { "id": "draft-text", "published_at": null }
  ]
}

published_at is required (null for a text never published), updated_at needs it, ids and slugs are kebab-case, each article and old slug appears once. Timestamps reach Postgres as the text given, so a timestamptz copied to the microsecond (…:12.421579Z) is stored to the microsecond and an import can be checked by equality in SQL; Postgres rounds digits past the sixth. One query over an app's own tables (here blog_articles(id, published_at, updated_at) and blog_slug_history(old_slug, article_id, changed_at)) writes the file:

\copy (SELECT json_build_object('articles', coalesce(json_agg(json_build_object(
  'id', a.id, 'published_at', a.published_at, 'updated_at', a.updated_at,
  'old_slugs', coalesce((SELECT json_agg(json_build_object('slug', h.old_slug, 'changed_at', h.changed_at))
                         FROM blog_slug_history h WHERE h.article_id = a.id), '[]'::json))), '[]'::json))
  FROM blog_articles a) TO 'history.json'

publishArticle(ctx, input, { history }) and runBlogPublish(ctx, files, { history }) (with parseArticleHistory(json)) are the same import without the command line.

Like softure migrate, the bin loads softure.config.(ts|mts|js|mjs) with Node and opens database.handle when the config sets one, otherwise database.url. When Node cannot load the config (path aliases, a bundled container), call runBlogCli from an app script:

// scripts/blog.ts
import { runBlogCli } from "@softure-ai/blog/cli";
import config from "../softure.config";

process.exitCode = await runBlogCli({ config, argv: process.argv.slice(2) });

A bundler can pack that script into one file: the CLI loads the optional @softure-ai/jobs peer only through @softure-ai/blog/jobs, by a specifier bundlers do not follow, so a bundle without jobs builds and starts. An app that bundles the script and uses the blog.indexnow queue passes the enqueue in, so the bundle carries it:

import { enqueueBlogIndexNow } from "@softure-ai/blog/jobs";

process.exitCode = await runBlogCli({ config, argv: process.argv.slice(2), enqueueIndexNow: enqueueBlogIndexNow });

Without it, a bundle with no node_modules/@softure-ai/blog next to it reports the enqueue as the blog.indexnow_enqueue_failed warning (the publish stays written).

publish runs the quality gate on every file going public (status published, not --withdraw); one error refuses the run. The gate in publish does not resolve internal link targets, since a container that publishes may hold no app folder; run check in CI for those. runBlogCli({ gate }) replaces the gate; runBlogPublish in @softure-ai/blog/server is the same run without a command line. After an app's own run, submitBlogChanges(config, run.changes, { commit: run.committed }) submits the same addresses; inside Next, call revalidateTag(BLOG_CACHE_TAG, { expire: 0 }) first, and outside it requestBlogRefresh(config, run.changes, { commit: run.committed }) (@softure-ai/blog/server), so a crawler that answers the ping at once gets the new text.

The IndexNow submit as a job

A synchronous submit is tried once: when IndexNow is slow it holds up the publish, and when it fails the addresses reach the engines only at the next publish. An app that runs @softure-ai/jobs moves the submit to its worker, which retries it:

// softure.config.ts
modules: [
  seo({ indexNow: { key: process.env.INDEXNOW_KEY } }),
  jobs({ queues: { "blog.indexnow": { maxAttempts: 8, backoff: { baseSeconds: 30, maxSeconds: 3600 } } } }),
  blog(),
],

// src/jobs/handlers.ts: the worker's handlers
import { blogJobHandlers } from "@softure-ai/blog/jobs";
export const handlers: JobHandlers = { ...blogJobHandlers, ...appHandlers };
  • The queue switches it on: with blog.indexnow in jobs({ queues }), softure-blog publish --commit enqueues one job after the commit and the cache refresh, with the changed paths as its payload, and sends nothing itself. Without the queue (or without jobs()), the submit stays synchronous.
  • The worker must have blogJobHandlers; a queue without its handler keeps its jobs pending (getQueueStats shows the backlog).
  • The handler builds the canonical URLs from the worker's config and submits them. It succeeds on 200 or 202; retries with the queue's backoff when the engine cannot be reached (blog.indexnow_unreachable) or answers 5xx (blog.indexnow_server_error); retries after Retry-After on a 429 (blog.indexnow_rate_limited, the backoff without the header); and fails at once on any other 4xx (blog.indexnow_rejected), an invalid key or a URL off the site (blog.indexnow_refused), or when seo or its key is missing from the worker's config (blog.indexnow_not_configured).
  • Dedup: the job's key is a hash of its paths, so a re-run with the same addresses while a job waits returns that job (duplicate) instead of a second submit.
  • A failed enqueue (the database refused it) is a warning, blog.indexnow_enqueue_failed, like a failed submit: the publish stays written.
  • An app's own publishing path calls enqueueBlogIndexNow({ db, clock, config }, run.changes) (@softure-ai/blog/jobs) after runBlogPublish commits and after its cache refresh, instead of submitBlogChanges. It returns the same { paths, outcome }, with queued, skipped or not_configured (no job is written that could never succeed).

check and skill install need no database, nor a database URL: the bin loads the config with the database optional for them (@softure-ai/core's withDatabaseOptional), so a CI job without DATABASE_URL runs them. An app script that runs them wraps its own import the same way: const { default: config } = await withDatabaseOptional(() => import("../softure.config")). check reads the files (default: contentDir), resolves internal links against the app's routes and the published texts of contentDir, compares the glossary forms of the checked terms with every published term there, reads every brand.fonts source as the OG card's route does (a path from the working directory, an https URL fetched, so a job with such a font needs network), and prints one line per finding:

content/blog/index-funds.md:12: error [crucial] "crucial": a favourite word of language models; name what depends on the thing
content/blog/bonds.md: OK
check: 2 file(s), 1 error(s), 0 warning(s): red, do not publish

Exit codes: 0 green (warnings allowed), 1 an error, 2 usage error. --external also requests every external link (HEAD, then GET when a server refuses HEAD; 2xx after redirects). Run it weekly with the reusable workflow of this repository, .github/workflows/blog-links.yml (its header holds the snippet for the app). Its input runs-on picks the runner, as for the deploy workflows (deploy README, "Runner").

The writing skill

softure-blog skill install writes an agent skill for writing the blog's texts into .claude/skills/blog-write/ (--dir to change). It walks the agent through a text: the question, facts with sources, a draft by an answer-first structure, a rewrite by the rules, check, a sceptical second agent with its own prompt, check --external, and publish. The package ships the templates in skill/; the command fills them from the app's config:

  • the language of the texts, the content folder, the article and glossary paths and every limit;
  • references/rules.md: exactly the rules the app's gate enforces (listQualityRules), each with its effective severity, what the gate looks for and what to write instead; the app's voice phrases and plugin rules with their own descriptions; a rule set to "off" is left out;
  • the YMYL passages (sources, footnotes, the own calculation mark) only when ymyl is on, and the editors' "we" when voice.forbidFirstPersonSingular is on;
  • the app's own sections from blog({ skill: { sections } }) (below).

The app adds its own procedure (where its numbers come from, its block plugins, its fields) as sections in the config, so a reinstall keeps them and --check covers them:

blog({
  skill: {
    sections: [
      { title: "Engine numbers", body: "Every number of an example comes from `npm run engine -- <inputs>`." },
      { title: "Chart block", body: "One `::chart{scenario=\"…\"}` block after the lead, with the frontmatter's `scenario`." },
    ],
  },
});

Install writes them to references/app.md (## <title> and the body, verbatim, never filled like the templates) and SKILL.md names them; with no sections the file is not written. A title is one line, unique, up to 80 characters; a body holds no # or ## heading outside fenced code (use ###). An app with long sections keeps them in a module of its own and imports them into the config.

--command sets how the skill runs the commands (default npx softure-blog; an app with a runBlogCli script passes e.g. --command "npm run blog --"). Commit the folder, so agents in a fresh clone have it, and run softure-blog skill install --check (with the same options) in CI, with no DATABASE_URL needed: it writes nothing and exits 1, naming the files, when the folder differs from what the config gives. Install overwrites only a folder whose SKILL.md it generated, so it never replaces a skill the app wrote itself. That folder belongs to the command: install removes a .md file in it that the config no longer gives (references/app.md once the sections are gone), logging removed <path>, and --check names such a file. With quality: false it refuses: the skill is built on the gate.

Rendering an article

import { getPublishedArticle, listArticles, renderArticle, toGlossary } from "@softure-ai/blog/server";

const article = await getPublishedArticle(ctx, slug);
const glossary = toGlossary(await listArticles(ctx, { kind: "term" }));
const body = renderArticle(article.bodyMarkdown, {
  glossary,
  selfSlug: article.kind === "term" ? article.slug : undefined,
  termHref: (term) => `/blog/glossary/${term}`, // the default
  siteHosts: ["example.com"], // subdomains included; other hosts are external
  images: { hosts: ["cdn.example.com"], dimensions: (src) => imageSizes[src] ?? null }, // see Images below
  toc: true, // or { maxLevel: 4 }; h2 and h3 by default
  messages: { ...blogMessages.en.render, ...myRenderTranslation }, // English by default
  blocks: [chartBlock],
  article: { currentAsOf: article.currentAsOf, fields: article.fields },
});
// body.html (null when a block returned a node), body.segments, body.headings, body.toc,
// body.linkedTerms, body.readingMinutes

findLinkedTerms(markdown, options) takes the same options and returns linkedTerms alone, without rendering: no block plugin's render runs, so an app that only needs the links should call it instead of renderArticle.

  • Allowlist by construction: raw HTML in the text is escaped, so the output holds only the elements Markdown produces. Links keep http(s), mailto, relative and # targets; any other scheme (javascript:, data:, entity-encoded or split by whitespace) stays text.
  • Images (![alt](src "title")) follow the image policy (images): the source is a site path (/images/x.png; never //host or a path relative to the page) or an https: URL on a host in images.hosts (subdomains included), the alt text is not empty, and images.dimensions(src) returns positive whole { width, height }. Such an image renders as <img class="blog-image"> with its width, height, loading="lazy" and decoding="async"; any other renders as its alt text, and without images every image does. src is the URL the page requests (percent-encoded: a space is %20). A throwing dimensions fails the render (a bug); the gate reports it as image-dimensions. checkArticleImage and findArticleImages give the same verdict and the images of a text.
  • External links (http(s) or // to a host outside siteHosts) get rel="noopener noreferrer", target="_blank", the class blog-external, a ↗ marker hidden from screen readers and a visually hidden "(opens in a new tab)". externalMarker: "text" keeps only the hidden words, "none" neither (the pages: blog({ externalLinkMarker })).
  • Headings get ids from their text (letters folded to ASCII, -2 for a repeat, section without letters); toc renders <nav class="blog-toc"> with nested lists.
  • Glossary: the first mention of each term form links to its definition; never inside headings, links, code or footnotes, never a term page to itself. The longest form wins, word bounds are Unicode-aware, case is as written (plus a capital first letter). A hand-written link to a term counts.
  • Footnotes ([^id]) become numbered references and a notes section with links back.

Block plugins. A top-level fence whose type an app registers is rendered by the app:

```chart wealth
scenario: early-retirement
```
const chartBlock: BlockPlugin = {
  type: "chart",
  requires: ["current_as_of", "scenario"], // frontmatter keys the block reads, for the quality gate
  render: ({ info, content, article }) => ({ kind: "html", html: renderChart(info, content, article) }),
  // or { kind: "node", node: <Chart … /> } for a React server component
};

Plugin output is the app's own code and is trusted as is: escape what goes into its HTML. A plugin that throws fails the render (a bug, not content). Without the plugin the same fence renders as a code block. findArticleBlocks(markdown, plugins) lists the blocks a text uses with their line, syntax, attributes and requires, without rendering. When any block returns a node, html is null: render segments in order (html segments as HTML, node segments as they are).

Directive plugins. A plugin with syntax: "directive" renders a top-level line ::name{…} instead of a fence, the way many Markdown blogs embed a chart or a tool:

Paragraph before.
::chart{type="wealth" scenario="w=35&d=300000" title="Your wealth"}
const chartDirective: BlockPlugin = {
  type: "chart",
  syntax: "directive",
  requires: ["current_as_of"],
  render: ({ attributes, article }) =>
    attributes === null
      ? { kind: "html", html: '<figure class="chart-error">…</figure>' }
      : { kind: "html", html: renderChart(attributes, article) },
  markdown: ({ attributes }) => chartAsTable(attributes), // optional, for Accept: text/markdown
};
  • The line stands alone (it may follow a paragraph line directly); the braces are optional; values are double-quoted and hold no "; each key appears once. attributes holds them, info the raw text inside the braces, content the whole line. Attributes that cannot be read reach the plugin as null (show an error frame) and the gate refuses them.
  • Only top-level lines count: a directive in a list, a quote, a fence or indented code stays text, and so does a name no directive plugin registers. One type may have a fence plugin and a directive plugin.
  • Register the same plugins in quality.blocks: the gate reports a directive's missing requires, and with any directive plugin registered block-directive reports a ::name line no plugin renders (a typo would show as a paragraph) or one whose attributes cannot be read.
  • parseDirectiveLine and parseDirectiveAttributes (@softure-ai/blog/server) are the parser.
  • validate(block) (optional) says why readable attributes are wrong (null when they fit); the gate reports its message as block-directive.

Tool blocks. An interactive tool (a calculator) in an article is a directive whose page shows a client island. defineToolBlock (@softure-ai/blog, also /server) builds that directive plugin from the app's schema and static HTML; the plugin returns plain data, so the config that registers it imports no React (the proxy and the command line load the config too). The page renders the tool with the app's client component, given by tool name in view.tools:

::savings-calculator{rate="5" years="20"}
// blog-tools.ts: imported by softure.config.ts (blog({ blocks, quality: { blocks } })); no React, no components
import { defineToolBlock } from "@softure-ai/blog";
import { z } from "zod";

export const savingsTool = defineToolBlock({
  name: "savings-calculator",
  // The attributes are strings: coerce numbers. The props travel to the browser, so keep them serializable.
  schema: z.object({ rate: z.coerce.number().min(0).max(20), years: z.coerce.number().int().positive() }),
  renderStatic: (props) => `<p>${String(props.years)} years at ${String(props.rate)}%: …</p>`, // escape what you insert
  markdown: (props) => `| Years | Rate |\n| --- | --- |\n| ${String(props.years)} | ${String(props.rate)}% |`, // optional
});
// savings-calculator-island.ts: the app's own "use client" module
"use client";
import { lazyToolIsland } from "@softure-ai/blog/ui";

// Loaded only when the tool is on the page, after hydration. An eager island is the component itself.
export const SavingsCalculatorIsland = lazyToolIsland(() => import("./savings-calculator").then((module) => module.SavingsCalculator));
// blog-islands.ts: a plain module (no "use client": a server component cannot read an object a client module exports)
import type { BlogToolIslands } from "@softure-ai/blog/ui";
import { SavingsCalculatorIsland } from "./savings-calculator-island";

export const BLOG_TOOLS: BlogToolIslands = { "savings-calculator": SavingsCalculatorIsland };

// app/blog/[slug]/page.tsx
export default function Page(props) { return <BlogArticlePage {...props} view={{ tools: BLOG_TOOLS }} />; }
  • The page's server HTML is <div class="blog-tool" data-blog-tool="savings-calculator" data-state="static"> with the static HTML: what bots and readers without JavaScript get. After hydration BlogToolIsland (the package's one client component) renders the island with the parsed props in its place (data-state="live"). The island is never rendered on the server, so it may use browser APIs; keep the static HTML close to its first look to avoid a layout shift. className replaces blog-tool. A tool with no island in view.tools keeps its static HTML.
  • mode: "append" keeps the static HTML (a chart that stays on the page) and mounts the island in an element right after it, empty on the server: <div … data-mode="append"><div data-blog-tool-part="static">…</div><div data-blog-tool-part="island"></div></div>. replace (the default) swaps the static HTML for the island.
  • lazyToolIsland(load) starts load() only when the island renders, after hydration, so an article without the tool loads none of its code. Until it resolves the mount point keeps the static HTML (replace) or an empty island element (append); a failed import reaches the nearest error boundary. Call it in a "use client" module (the loader must stay on the client) and build the view.tools map in a plain module.
  • Several tools behind one directive: defineToolBlocks({ name: "tool", tools: { calculator: { schema, renderStatic }, chart: { schema, renderStatic, mode: "append" } } }) renders ::tool{type="chart" years="10"}. type picks the tool (its key in view.tools too, and data-blog-tool-type on the mount point); the other attributes go to that tool's schema. mode, markdown and numbers are per tool; requires, renderInvalid and className are the directive's. A missing or unknown type is refused like a schema issue.
  • An app with its own page renders a tool node with renderToolNode(node, islands) (isBlogToolNode tells it apart from other node segments); ArticleBody does it with context.tools.
  • The Markdown answer carries the static HTML, or markdown(props) when given. RSS items carry no body.
  • The gate reports attributes the schema refuses as block-directive (the attributes of ::savings-calculator do not fit: rate: …), so register the tool in quality.blocks too. Such a line renders nothing on the page (renderInvalid(block) returns the app's HTML instead) and keeps its source in the Markdown answer.
  • requires and numbers(props) work as for any block plugin; on a shared directive a tool without numbers is not checked (numbers may return null for any block plugin: no check for that block).

Markdown for agents. createBlogMarkdown(config) (@softure-ai/blog/proxy) answers a GET or HEAD of a published article or term whose Accept names text/markdown with at least the weight of text/html (never */*: browsers and crawlers keep the page) with toArticleMarkdown(article): the title, description, the day the facts were checked, the summary, the stored body, sources and FAQ. Plugin blocks keep their source unless the plugin has markdown. The answer carries Vary: Accept and cache-control: private, so a shared cache never hands Markdown to a browser. Put it before the redirects:

const blogMarkdown = createBlogMarkdown(softureConfig);
const blogRedirects = createBlogRedirects(softureConfig);
export async function proxy(request: NextRequest) {
  return (await blogMarkdown(request)) ?? (await blogRedirects(request)) ?? NextResponse.next();
}

createBlogProxy(config, options) is both pieces in that order, with one getContext (and ttlMs, onError):

const blogProxy = createBlogProxy(softureConfig);
export async function proxy(request: NextRequest) {
  return (await blogProxy(request)) ?? NextResponse.next();
}

5. Migrations and tables

Schema blog, migration 0001_create_articles.sql:

| Table | Holds | | --- | --- | | blog.articles | one row per text: id, slug, kind, cluster, pillar, title, description, summary, body, status, current_as_of, published_at, updated_at, sources, FAQ, term forms, the app's fields, content hash, created_at | | blog.slug_history | each old slug with its article (the 301 target); removed with the article |

Constraints: id, slug, cluster and old slug kebab-case (at most 100 characters); kind and status closed lists; text lengths; a published text has a publication date; an update date needs one; a pillar has a cluster; a term has forms and an article has none; a unique slug; one pillar per cluster among texts not withdrawn (an exclusion constraint deferred to commit, so one run can move the pillar). "A slug is not in another article's history" stays in the code, under a row lock; the check reads the current slugs before the old ones, so a slug that another run is renaming away from is refused, naming that article, whether the rename has committed or not. A run that loses a race for a slug (another run committed it between the read and the write) is refused with blog.slug_taken, naming the article that took it, like any other taken slug.

6. Environment variables

| Variable | Required | Read by | | --- | --- | --- | | BLOG_REFRESH_SECRET | no | the refresh route (refreshBlogCache) and softure-blog publish: the shared secret, 32+ characters; without it a publish shows after revalidateSeconds |

The command reads the database URL from the app's config.

7. Switches

None.

8. Appearance

styles.css styles every blog-* class of the pages and of the rendered body (blog-external, blog-external-marker, blog-visually-hidden, blog-term, blog-toc, blog-footnote-ref, blog-footnotes, blog-footnote-back) with the --sft-* tokens of @softure-ai/ui, in the softure layer, so the app's own rules win; class slots and a layout (§4, "The package's views in the app's look") take the app's own. The OG card takes brand.colors, else ui's dark theme; its label line is brand.colors.muted, else the foreground.

An app's mark on the OG card, and another label under the title, come from the route built by createBlogArticleOgImage (BlogArticleOgImage is the one built with no options):

// app/blog/[slug]/opengraph-image.tsx
import { createBlogArticleOgImage } from "@softure-ai/blog/next";
export { generateBlogStaticParams as generateStaticParams } from "@softure-ai/blog/next";
export const size = { width: 1200, height: 630 };
export const contentType = "image/png";
export const revalidate = 300;
// The logo is drawn before the brand's name: flex layout and inline styles, images as data or https URLs.
export default createBlogArticleOgImage({ logo: <AppMark size={40} />, label: "The journal" });

An app's other OG cards read fonts the same way with loadOgFonts or createOgFontLoader({ root }) from @softure-ai/seo/server (no blog needed); the blog's own createOgFontLoader (/server or /next) is that loa