Skip to content

docs: source guides from a content-collection instead of copying them in - #5752

Open
dimitrieh wants to merge 2 commits into
mainfrom
docs/content-collections-instead-of-sync
Open

dimitrieh wants to merge 2 commits into
mainfrom
docs/content-collections-instead-of-sync

Conversation

@dimitrieh

@dimitrieh dimitrieh commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

A reviewer asked on #5495 (comment) why the docs pipeline uses a custom sync script instead of @nuxt/content's own collection primitives. This checks that against the installed version (3.15.2) and applies it where it genuinely helps.

The guides overlay (nuxt/content-guides/) is now a second source on the docs collection, read directly from disk instead of being copied into nuxt/content/docs first. The frontmatter it used to inject during that copy now happens in the existing content:file:beforeParse hook.

Source Change
Guides (nuxt/content-guides/) Native second collection source, no copy step
FlowFuse/flowfuse docs (docs-sync.mjs) Unchanged
Core nodes (core-nodes-sync.mjs) Unchanged

The other two sources stay as they are:

  • docs-sync.mjs needs the full git history of each file it clones (for the "updated" date). @nuxt/content's own git source only does a shallow clone, which would date every page the same.
  • core-nodes-sync.mjs generates pages from an HTTP fetch, not files on disk, so there is nothing to point a collection source at.

Also renamed the guides' README.md section-index files to index.md, since @nuxt/content only recognizes the latter.

What this does not solve: two of the three sync scripts are unchanged. scripts/sync_docs.mjs (used outside a Nuxt build) no longer copies guide pages into nuxt/content/docs, only their non-markdown assets.

Related Issue(s)

#5495 (comment)

Checklist

  • I have read the contribution guidelines
  • I have considered the performance impact of these changes
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
  • For blog PRs, an Art Request has been created (instructions)

@dimitrieh

Copy link
Copy Markdown
Contributor Author

has a lot of changes as this stacks on top of other PRs. If those get merged, this one can follow and it will have less changes. Until then this stays a draft PR

@netlify

netlify Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for flowfuse-website ready!

Name Link
🔨 Latest commit ddb9c47
🔍 Latest deploy log https://app.netlify.com/projects/flowfuse-website/deploys/6ab6d4419ea4800008cf07fb
😎 Deploy Preview https://deploy-preview-5752--flowfuse-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 42 (🟢 up 11 from production)
Accessibility: 95 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@dimitrieh
dimitrieh changed the base branch from main to docs/node-red-library-into-docs September 8, 2026 08:47
@dimitrieh
dimitrieh force-pushed the docs/node-red-library-into-docs branch from 02d2826 to 35d1a80 Compare September 8, 2026 09:04
@dimitrieh
dimitrieh force-pushed the docs/content-collections-instead-of-sync branch 10 times, most recently from b17b8c5 to 68a3cb7 Compare September 8, 2026 11:41
Base automatically changed from docs/node-red-library-into-docs to main September 8, 2026 15:22
@dimitrieh
dimitrieh marked this pull request as ready for review September 8, 2026 15:23
@dimitrieh

Copy link
Copy Markdown
Contributor Author

@ZJvandeWeg can you have a look here? This essentially fixes your request at #5495 (comment)

@dimitrieh
dimitrieh force-pushed the docs/content-collections-instead-of-sync branch from 51dbb2e to 2063535 Compare September 15, 2026 11:38
A reviewer on #5495 asked why docs-sync/guides-sync materialize files into
nuxt/content/docs by hand instead of using @nuxt/content's own collection
primitives. Checked against the installed @nuxt/content (3.15.2, satisfies the
^3.13.0 this repo pins): a collection's `source` can be an array, each entry
with its own `cwd`, and each is globbed and parsed independently at build
time. That is enough for the guides authored in nuxt/content-guides/, since
they are already MDC and already local: the `docs` collection now reads them
straight from that directory as a second source (prefixed onto `docs/` so
they land at the same paths), and the `content:file:beforeParse` hook that
already existed for the blog collection now also stamps guide pages with
their editUrl/updated frontmatter, in place of a copy step that used to write
it into a duplicated file.

guides-sync.mjs is what is left after that: copying the guides' non-markdown
assets to public/docs (a content-collection source cannot do that), and a
proactive collision check against FlowFuse/flowfuse's pages (a real collision
now fails anyway, since the `docs` collection's `id` is a primary key, but as
a SQL error rather than a message naming the file). The section-index
README.md convention the guides borrowed from GitHub is renamed to index.md
throughout, since @nuxt/content only special-cases the latter and this tree
is ours to rename.

docs-sync.mjs (the FlowFuse/flowfuse clone) is unchanged: its full-history
clone can't become @nuxt/content's own git source, which only supports a
shallow clone and would flatten every page's `updated` date to the sync
commit - the reason the clone is not shallow already, predating this change.
core-nodes-sync.mjs is unchanged for the same reason it was never a
candidate: its input is an HTTP fetch, not files on disk, so it still writes
into nuxt/content/docs like a build artifact, because it is one.

Verified the source/prefix mechanics against @nuxt/content's own module code
(resolveSource, defineLocalSource, the collection build loop) and with a
standalone experiment reproducing the exact id/path computation for both
sources - not just theoretically, but with real @nuxt/content code executed
against toy directories, confirming the guides source resolves to the same
/docs/... paths the old copy step produced. nuxt/lib/guides-sync.test.mjs is
rewritten for the slimmed-down API.
@dimitrieh
dimitrieh force-pushed the docs/content-collections-instead-of-sync branch from 2063535 to fbd5d63 Compare September 25, 2026 19:56
@dimitrieh

Copy link
Copy Markdown
Contributor Author

FYI: the failing build here isn't caused by this PR. Tracked in https://github.com/FlowFuse/engineering/issues/460. It's resolved now, re-running the checks.

Dropping the copy step took the guides out of the only path remark-docs-links
recognised. It keys off a `/docs/` segment in the file's path on disk, which held while
guides-sync materialized them into nuxt/content/docs, and stops holding now they are
read straight out of nuxt/content-guides/. The plugin returned early on every guide
page, so their relative image URLs reached the browser unresolved and the browser
resolved them against the page's own URL: ./images/x.png on
/docs/node-red/database/influxdb/ asked for
/docs/node-red/database/influxdb/images/x.png and 404'd. The asset was copied to the
right place throughout; only the URL was wrong. Three hundred-odd references across
33 pages, and nothing failed: the link checker sees the built HTML, where these are
valid relative URLs, and the images themselves are not fetched.

The path mapping moves to nuxt/lib so node --test can reach it, and it now understands
both of the collection's sources. The test asserts over the real tree that every guide
using a relative asset URL is one this can resolve, so the two cannot drift apart
again without failing.
@dimitrieh
dimitrieh force-pushed the docs/content-collections-instead-of-sync branch from fbd5d63 to ddb9c47 Compare September 25, 2026 20:06
@dimitrieh

Copy link
Copy Markdown
Contributor Author

This branch was successfully deployed

1 active (outdated) deployment
Preview — 51dbb2e4 Deployed Sep 8, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant