Skip to content

feat(core): add WordPress-style body classes - #2689

Merged
josephfusco merged 7 commits into
canaryfrom
feat/2682-body-classes
Oct 22, 2026
Merged

josephfusco merged 7 commits into
canaryfrom
feat/2682-body-classes

Conversation

@josephfusco

Copy link
Copy Markdown
Member

Fixes #2682

It's opt-in with <WordPressTemplate bodyClass />, so existing CSS can't change, and I checked it in the getting-started example in Chrome against WordPress 7.0: a post gets single single-post postid-5, a category archive category category-news category-2, the front page home blog, a preview with the toolbar admin-bar logged-in single single-post postid-5, and classes swap cleanly on client-side navigation.

@josephfusco josephfusco added [Area] Core Issues for the @faustwp/core package [Type] Enhancement A suggestion for improvement of an existing feature labels Oct 21, 2026
@josephfusco
josephfusco requested a balanced review from Copilot October 21, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Preview class generation and toolbar opt-in behavior need correction to avoid unintended styling.

3 open issues
What changed in this PR

Adds WordPress-style body classes to Faust pages to support CSS ported from WordPress themes.

Changes:

  • Adds class generation, a lifecycle hook, and opt-in template integration.
  • Reuses the hook in the toolbar and enables classes in the getting-started example.
  • Adds tests and API documentation.
File Description
packages/​faustwp-core/​tests/​utils/​getBodyClasses.test.ts Tests class generation.
packages/​faustwp-core/​tests/​hooks/​useBodyClass.test.ts Tests class lifecycle.
packages/​faustwp-core/​tests/​components/​WordPressTemplate.test.tsx Tests opt-in behavior.
packages/​faustwp-core/​src/​utils/​getBodyClasses.ts Derives classes from seed nodes.
packages/​faustwp-core/​src/​index.ts Exports the new APIs.
packages/​faustwp-core/​src/​hooks/​useBodyClass.tsx Adds and cleans up body classes.
packages/​faustwp-core/​src/​components/​WordPressTemplate.tsx Adds the bodyClass option.
packages/​faustwp-core/​src/​components/​Toolbar/​Toolbar.tsx Uses the hook for toolbar classes.
examples/​next/​faustwp-getting-started/​pages/​preview.js Enables preview body classes.
examples/​next/​faustwp-getting-started/​pages/​index.js Enables homepage body classes.
examples/​next/​faustwp-getting-started/​pages/​[...wordpressNode].js Enables routed page body classes.
docs/​reference/​use-body-class/​index.md Documents usage and supported classes.
docs/​nav.json Links the new reference page.

Review effort: Balanced

@josephfusco
josephfusco marked this pull request as ready for review October 22, 2026 14:58
@josephfusco
josephfusco requested review from a team and colinmurphy as code owners October 22, 2026 14:58
@josephfusco
josephfusco merged commit 8e87663 into canary Oct 22, 2026
18 checks passed
@josephfusco
josephfusco deleted the feat/2682-body-classes branch October 22, 2026 15:12
@github-actions github-actions Bot mentioned this pull request Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Core Issues for the @faustwp/core package [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add WordPress-style body classes to Faust pages

2 participants