Repository navigation
Fix listing contents files resolved against the working directory - #15045
Merged
Merged
Conversation
A file named in a listing's `contents` next to a folder (or the default glob) was added by a loop that resolved it against the process cwd. A YAML file such as `[posts, items.yml]` was dropped when the site was rendered from any directory other than the listing page's, a same-named file in the cwd was listed instead, and a `.qmd` named next to its own folder was listed twice. Resolve each entry against the listing document's directory first, as the lone-entry branch and the documented behavior do, and keep a real absolute path as a fallback. Skip `!` exclusions, the listing document itself, and files `filterPaths` already included.
`safeExistsSync(p) && Deno.statSync(p).isFile` is repeated across src/ and, unlike `safeExistsSync`, lets `statSync` throw. Name it once next to `safeExistsSync` and use it in the listing contents loop. The other call sites are left as they are. Inline the verifiers in the listing contents test so it reads top to bottom.
It wraps `Deno.statSync`, so it sits with the other safe wrappers over raw Deno APIs in the runtime abstraction layer instead of core/path.ts.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A file named next to a folder in a listing's
contents, likecontents: [posts, archived-items.yaml]from the "YAML Listing Content" docs, is dropped when the site is rendered from a directory other than the listing page's. If a file with the same name exists in the working directory, that one is listed instead. A.qmdnamed next to its own folder is listed twice.It works by accident in the usual layout, a listing page at the project root rendered from the root. With the page in a subdirectory, which is what CI and
quarto renderfrom the root do, the YAML items silently disappear.Root cause
When
contentsmixes a folder (or the default glob) with a file,filterPathsonly matches project input documents. A follow-up loop infilterListingFilesthen adds entries that name an existing non-input file such as YAML. That loop checked existence and joined the path againstDeno.cwd(), andisAbsoluteread an anchored/items.ymlas the filesystem root. It also never checked for filesfilterPathshad already included. A lonecontents: items.ymlgoes throughresolvePathGlobs(dirname(source))and was already correct.The loop has resolved against the cwd since it was added in 4ad0f00. #15032 fixed the same class of problem for the listing feed image.
Fix
Each entry is resolved against the listing document's directory first, as the lone-entry form and the docs do. A real absolute path still works as a fallback.
!exclusions, the listing document itself and files already included are skipped.An anchored
/items.ymlnext to a folder now means the listing directory, like the lone form, instead of the filesystem root.!exclusions are not applied to files this loop adds. That was already the case and is unchanged here.Fixes #15044
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.