Skip to content
joinery / docs

Content: readiness for a second WordPress app

Closed

docs/audits/2026-10-09-content.md ยท read at 3b67d7f

Open
0
Fixed
8
Won't fix
6

๐Ÿ”Ž Content: readiness for a second WordPress app

Context

A static read of packages/content, covering every non-spec file under src/. It also covers the one consumer, apps/huella-legal/layers/articles, where the package's shape shows up as app code. The question is whether the package works as a plug-and-play WordPress reader for the next app rather than for Huella only. 0031 settled the topology (one cached server useContent(event), no public route), and this audit takes it as given: the findings are about the domain model and the cache contract.

A finding marked Confirmed was reproduced by feeding a hand-built WordPress post to toEntry from a scratch spec (B1, Q2), or by grepping the tree (D1). Likely means reasoned from the code and not reproduced. Line numbers are from the working tree at commit, which differs only by deleted comments in useContent.ts.

Several findings are rows in the package README's deferred table. They are filed here because "more WordPress apps soon" is the trigger those rows were waiting for.

Bugs

IDWhereWhat goes wrongFixStatus
B1WordpressHelpers.ts:45-59 toEntry, toTerm, toAuthorConfirmed. A post titled Ley “Orgánica” & c by J & M comes out of toEntry with both strings still entity-escaped. title, Term.name, Author.name and bio are typed string but hold WP-rendered HTML, so every app either decodes them or prints &Decode to plain text in the WordPress mapper, so string means text. Huella's toText calls on these fields (D2) then gofixed #405: toPlainText in the WordPress provider
B2config.ts:3-7, useContent.ts:16-48 readList, readItemLikely. One post is cached twice: inside every list page (1 h window) and as an item (6 h window). After an edit, /publicaciones/ and the related band show the new title within the hour, while the article page serves the old one for up to 6 hOne window for both families, or let the purge in Q6 clear both on a post changewont-fix โ€” huella refreshes by rebuilding, not by purging Nitro's cache (#236), so the two windows never meet a reader

Duplication

IDCopiesConsolidate intoStatus
D1Confirmed. The format === "blocks" branch for a format no provider produces (Q4): article.ts:18, articleSummary.ts:64, articleSummary.ts:77, testing/wordpress.ts:93Nowhere: narrowing RichText (Q4) deletes all fourfixed #405: RichText is HTML only
D2WordPress entity decoding, in the app: articleSummary.ts:71 toText, applied to title, name and bio. Every future WordPress app needs the same functionWordpressHelpers.ts, as part of B1fixed #405: huella reads the decoded fields as they come

Quality

IDWhereIssueFixStatus
Q1content.ts:1-9 ENTRY_RESOURCES, TERM_RESOURCESThe resources are two closed unions holding WordPress's defaults. An app with a custom post type (events, products) can't read it without editing the shared package, and query.ts rejects its taxonomy with a 404. The package is generic over vendors, of which there is one, and hard-coded over each site's schema, which is what the next app will changeDeclare resources in module options ({ events: { kind: "entry", path: "event" } }), keep today's four as the default, and infer the resource type from configwont-fix โ€” no app reads more than WordPress's four defaults; the package README's deferred row says where to open the unions
Q2WordpressConfigs.ts:8-11 TAXONOMIES, WordpressHelpers.ts:62 toEmbeddedTermConfirmed. A post embedding a term from the custom taxonomy jurisdiccion comes out with that term gone from Entry.terms, and nothing logs itBuild the taxonomy map from the same config as Q1wont-fix โ€” goes with Q1, since Huella embeds no custom taxonomy
Q3content.ts:54-66 EntryThere is no slot for ACF or post meta. Huella already routes around it: articleSummary.ts:36 toFormat derives an article's format from magic tag slugs (trabajos-de-fin-de-grado, jurisprudencia-*)fields?: Record<string, unknown> filled from acf / meta when the site exposes them, typed by each app at its mapperfixed db5bf75 (#343)
Q4content.ts:19-21 RichTextmarkdown and blocks exist for vendors that don't exist, and the cost is paid by every consumer (D1){ format: "html", value: string } until a second vendor ships, and widen it thenfixed #405
Q5config.ts:3-7The cache windows are constants. A news-like app and an evergreen one can't tune them without forking the packageModule options, with the current values as defaultsfixed 2b58e9e (#304)
Q6useContent.ts:50-64 useContentThere is no purge, and only the package knows the key format, so an app can't write one either. A correction to a legal article takes up to 6 h to show (#236)A secret-guarded purge handler or useContent(event).invalidate(resource, slug?) for a WP webhook, clearing the item key and the content-list groupwont-fix โ€” Nitro's cache is per instance and huella's pages are prerendered, so a rebuild is the refresh (#236)
Q7useContent.ts:50-64 useContentEvery read is cached and anonymous, so there is no way to preview a draft. That's the first thing an editor on a second WP site will ask forAn uncached, authenticated read (application password from env), enabled per request by the appwont-fix โ€” no editor has asked, and a preview needs a runtime route and a credential next to a prerendered site; a deferred row in the package README
Q8WordpressProvider.ts:12-23 listEntriesLikely. A list fetches and caches full content.rendered for every item (about 53 KB a post on the 0027 corpus), which is mostly unused by a listing. Huella reads the body there only for readingMinutesA _fields projection on lists, plus an optional wordCount on Entry computed in the providerwont-fix โ€” #405 adds wordCount, and the provider needs the body on lists to count it, so lists keep fetching it
Q9useContent.ts:16-62One cached function serves both entries and terms, so its return is Page<Entry> | Page<Term>, and the four accessors cast it back with asOne cached function per kind, or a generic one, so the casts gofixed #405: one cached reader per kind and shape
Q10pages/articles/index.vue:18-23WordPress answers a page past the end with a 400, which passes through as if the query were malformed. Each app has to learn that WP quirk and turn it into a 404The provider maps rest_post_invalid_page_number to NotFoundErrorfixed #405: PageNotFoundError

Order

  1. Q1, Q2 and Q3 first, together. They decide whether a second WordPress app can plug in without editing the package, and they share one config shape.
  2. B1 with D2. Decoding moves into the provider and the app's copy is deleted in the same change.
  3. Q4, which closes D1 for free.
  4. Q6, which also settles B2 if the purge clears both key families. Q5 belongs in the same change, since both touch the module options.
  5. Q7โ€“Q10 are independent and can go in any order.