A page's `body-classes` replaces the layout classes on `<body>` instead of adding to them

未关闭
#1,218 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@cscheid 已经在做这个了。

开始于 2026年11月16日。

  • #1232 来自 @cscheid —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
backend

调研方向

Start with the body-classes handling in crates/quarto-core/src/template.rs, especially the comments at lines 201 and 1232 cited in the issue. Compare the rendered body classes from the provided q2 repro with the expected Quarto 1 output, then run the repro after the change. Done when page classes are added to computed layout classes while the plain page output remains correct.

由索引模型根据 Issue 内容生成。

描述

This issue was written by Claude while adding q2 support to Great Docs. The output shown comes from running each repro.

Bug description

When a page sets body-classes, q2 writes only those classes on <body>. The classes q2 computes
for the layout, such as nav-fixed, fullcontent and quarto-light, are dropped. Quarto 1 adds the
page's classes to the computed ones.

This looks intended: crates/quarto-core/src/template.rs:201 says a body-classes "supplied by the
author or a filter is kept wholesale and suppresses the compose below", and so does the comment at
:1232. But the theme's CSS and JavaScript select on those classes: nav-fixed for the fixed
navbar, fullcontent and the other layout classes for the page grid, and quarto-light for the
color scheme. So a page that adds one class of its own loses that styling.

Great Docs sets body-classes on its API and CLI reference pages (doc-reference,
doc-api-page and others), on blog index pages and on the tags index. Its CSS uses them to style
those pages. Under q2 each of those pages loses its layout classes. As a workaround, Great Docs' filter moves body-classes
into a <meta> tag, and a post-render script adds them to the classes q2 wrote.

Steps to reproduce
mkdir body-classes && cd body-classes
printf 'project:\n  type: website\nwebsite:\n  navbar:\n    left: [index.qmd, plain.qmd]\n' > _quarto.yml
printf -- '---\ntitle: Home\ntoc: false\nbody-classes: my-page\n---\n\nHome.\n' > index.qmd
printf -- '---\ntitle: Plain\ntoc: false\n---\n\nPlain.\n' > plain.qmd
q2 render
grep -o '<body[^>]*>' _site/index.html _site/plain.html
Actual behavior
_site/index.html:<body class="my-page">
_site/plain.html:<body class="fullcontent nav-fixed quarto-light">
Expected behavior

As in Quarto 1.9.37:

_site/index.html:<body class="nav-fixed my-page fullcontent quarto-light">
_site/plain.html:<body class="nav-fixed fullcontent quarto-light">

Add the page's body-classes to the computed classes. If replacing them should still be possible,
an explicit opt-in such as !prefer would serve, rather than making replacement the default.

主要语言
Rust
星标
302
派生
22
平均合并
5 小时 2 分钟
30 天内合并 PR
213

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quarto-dev/q2 的其他 Issue

查看 quarto-dev/q2 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。