Apply getSourceFromFrontmatter fixes to scripts/docs-cli/lib/content-utils.js
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- cli
Research direction
Compare scripts/docs-cli/lib/content-utils.js with the fixed implementation in scripts/lib/content-utils.js and the referenced #7136 commit. Check how scripts/docs-cli/commands/edit.js consumes getSourceFromFrontmatter. Done means the docs-cli copy only reads the top frontmatter block, normalizes the listed shared paths consistently, and returns null for absolute paths or URLs.
Written by the indexing model from the issue text.
Description
Problem
There are two copies of getSourceFromFrontmatter in the repo:
scripts/lib/content-utils.js— fixed in #7136scripts/docs-cli/lib/content-utils.js— still has the original bugs
Both copies should behave the same way. The docs-cli copy is used by docs edit (via scripts/docs-cli/commands/edit.js) to find a shared source file when opening a consumer page. Its bugs are latent there but still real:
Bugs in the docs-cli copy
-
Regex matches outside the frontmatter block.
content.match(/^source:\s*(.+)$/m)matches^source:anywhere in the file, so asource:key inside a fenced YAML example (for example, Docker Compose docs) gets treated as the page's shared source.docs editwill then try to open the wrong file. -
Only normalizes paths starting with
/. Frontmatter of the formsource: shared/foo.md(without a leading slash) is returned verbatim asshared/foo.md, which is a relative path that doesn't resolve from the caller's cwd.docs editeither fails or opens something unexpected.
Fix
Port the fix from #7136 (commit 5241ff7a5) to the docs-cli copy:
- Restrict the regex to match only within the top-of-file frontmatter block (between
---delimiters). - Normalize
/shared/...,shared/..., andcontent/shared/...consistently. - Return
nullfor unexpected shapes (absolute filesystem paths, URLs) rather than returning a misleading path.
Longer term
The two copies are drift-prone. A follow-up refactor could consolidate on a single source of truth — either re-export from one location, or move the helper to a shared module both scripts import.
Context
Flagged during review of #7136, which fixed the CI-path copy but deferred this one to keep PR scope tight.
- Dominant language
- JavaScript
- Stars
- 82
- Forks
- 326
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 82
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from influxdata/docs-v2
-
agent-ready
Difficulty 1/5 Under an hour Newbie friendliness 92/100
influxdata/docs-v2#7768 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
influxdata/docs-v2#7763 ·
-
product:shared product:v3-monolith source:sync
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
influxdata/docs-v2#7762 ·
-
product:v3-monolith
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
influxdata/docs-v2#7721 · 1 comment ·
-
area:links
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
influxdata/docs-v2#7623 · 1 comment ·
All issues in influxdata/docs-v2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·
-
client-controller-update ta-bot-triage team-money-movement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MetaMask/metamask-mobile#36594 ·