Skip to content

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

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

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

The build stops copying the guides into nuxt/content/docs. @nuxt/content reads them in place from nuxt/content-guides/ as a second source of the docs collection, as asked in #5495 (comment). The file you edit is now the file that renders. Section indexes are renamed from README.md to index.md, which @nuxt/content requires.

The renamed pages will show the merge date as "Updated" until their next edit.

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 bbb674f
🔍 Latest deploy log https://app.netlify.com/projects/flowfuse-website/deploys/6ac4f5fe26b3450008d9fde1
😎 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: 48 (🟢 up 14 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
@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.

@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

@dimitrieh
dimitrieh force-pushed the docs/content-collections-instead-of-sync branch from ddb9c47 to 5967a80 Compare October 5, 2026 16:40
@dimitrieh
dimitrieh marked this pull request as draft October 6, 2026 12:45
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.
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 5967a80 to bbb674f Compare October 6, 2026 13:22
@dimitrieh
dimitrieh marked this pull request as ready for review October 6, 2026 13:22
@dimitrieh
dimitrieh requested a review from Yndira-E October 6, 2026 15:17
@dimitrieh dimitrieh closed this Oct 12, 2026
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