fix(conditions): is-folder-index is false on tag pages (tags/index)

This commit is contained in:
saberzero1 committed 2026-11-26 22:40:07 +01:00
1 parent bc0e3937c3
commit b2241c313e
4 files changed
+24 -10

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Layout conditions: `is-folder-index` is false on tag pages. The all-tags page (`tags/index`) matched it, so components meant for folder pages showed there; nothing under `tags/` counts as a folder index now.
+9 -9
View File
@@ -132,15 +132,15 @@ plugins:
Available conditions:
| Condition | Effect |
| ----------------- | ---------------------------------------------------------------------------- |
| `is-index` | Only shown on the root index page (the home page) |
| `not-index` | Hidden on the root index page, shown everywhere else |
| `is-folder-index` | Only shown on folder index pages (`folder/index.md` or a generated one) |
| `has-tags` | Only shown on pages that have tags in frontmatter |
| `has-backlinks` | Only shown on pages that another (listed) page links to |
| `has-toc` | Only shown on pages with a table of contents (needs `table-of-contents`) |
| `not-<condition>` | Negates any condition, built-in or registered: `not-has-tags`, `not-has-toc` |
| Condition | Effect |
| ----------------- | -------------------------------------------------------------------------------------------------------------------- |
| `is-index` | Only shown on the root index page (the home page) |
| `not-index` | Hidden on the root index page, shown everywhere else |
| `is-folder-index` | Only shown on folder index pages (`folder/index.md` or a generated one), not on tag pages (`tags/` and `tags/<tag>`) |
| `has-tags` | Only shown on pages that have tags in frontmatter |
| `has-backlinks` | Only shown on pages that another (listed) page links to |
| `has-toc` | Only shown on pages with a table of contents (needs `table-of-contents`) |
| `not-<condition>` | Negates any condition, built-in or registered: `not-has-tags`, `not-has-toc` |
Plugins can register additional conditions. An unknown condition name prints a warning at build time and the component is always shown.
+7
View File
@@ -76,6 +76,13 @@ describe("index conditions (#2465)", () => {
assert.strictEqual(run("is-folder-index", "folder/indexes"), false)
assert.strictEqual(run("is-folder-index", undefined), false)
})
test("is-folder-index is false on tag pages (the all-tags page is tags/index)", () => {
assert.strictEqual(run("is-folder-index", "tags/index"), false)
assert.strictEqual(run("is-folder-index", "tags/a/index"), false)
assert.strictEqual(run("is-folder-index", "tags/a"), false)
assert.strictEqual(run("is-folder-index", "my-tags/index"), true)
})
})
describe("not-<condition> negation", () => {
+3 -1
View File
@@ -7,9 +7,11 @@ const builtinConditions: Record<string, ConditionPredicate> = {
"is-index": (props) => props.fileData.slug === "index",
"not-index": (props) => props.fileData.slug !== "index",
// A folder's index page: `folder/index.md` or a generated folder page, not the root index.
// Tag pages aren't folders: `tags/` belongs to them (the all-tags page `tags/index`, and
// `tags/<tag>` pages), so nothing under it is a folder index.
"is-folder-index": (props) => {
const slug = props.fileData.slug
return typeof slug === "string" && slug.endsWith("/index")
return typeof slug === "string" && slug.endsWith("/index") && !slug.startsWith("tags/")
},
"has-tags": (props) => {
const tags = props.fileData.frontmatter?.tags