Skip to content

feat: add pageTitleFormatter config#2695

Open
sy-records wants to merge 4 commits intodocsifyjs:developfrom
sy-records:feat/pageTitleFormatter
Open

feat: add pageTitleFormatter config#2695
sy-records wants to merge 4 commits intodocsifyjs:developfrom
sy-records:feat/pageTitleFormatter

Conversation

@sy-records
Copy link
Member

Summary

If a pageTitleFormatter is provided, let the user format the name
(no automatic HTML stripping). Otherwise, default to stripping
HTML tags from the configured name.

Related issue, if any:

Close #2610

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

  • Yes
  • No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vercel
Copy link

vercel bot commented Mar 16, 2026

@sy-records is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docsify-preview Ready Ready Preview, Comment Mar 16, 2026 10:20am

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Docsify configuration option to customize how the configured site name contributes to the browser tab title (document.title) during render, allowing users to override the default “strip HTML tags from name” behavior.

Changes:

  • Introduces pageTitleFormatter config option (default null).
  • Updates render event logic to use pageTitleFormatter(name) when provided, otherwise keep existing HTML-stripping behavior.
  • Documents the new option in the configuration reference.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/core/event/index.js Uses optional pageTitleFormatter when composing document.title during onRender().
src/core/config.js Adds pageTitleFormatter to default config with JSDoc typing.
docs/configuration.md Documents pageTitleFormatter option and provides an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new configuration option to customize how the Docsify site name contributes to the browser document title during render, while preserving the existing default behavior when the option is not set.

Changes:

  • Introduces pageTitleFormatter config option (default null) to optionally format the site name for document.title.
  • Updates the render event handler to use pageTitleFormatter(name) when provided; otherwise keeps HTML-tag stripping fallback.
  • Documents the new configuration option in docs/configuration.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/core/event/index.js Uses optional pageTitleFormatter to compute the site-name portion of the page title on render.
src/core/config.js Adds pageTitleFormatter to the default config object (typed, default null).
docs/configuration.md Documents pageTitleFormatter with usage example and default behavior notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new configuration hook to customize how the Docsify site name is incorporated into the browser document title, primarily to support HTML-containing names without automatic stripping.

Changes:

  • Add pageTitleFormatter to the default config schema.
  • Update title composition in onRender() to optionally delegate site-name formatting to pageTitleFormatter.
  • Document the new configuration option in docs/configuration.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/core/event/index.js Uses optional pageTitleFormatter when composing document.title from name and current section.
src/core/config.js Adds pageTitleFormatter to the default config shape/type annotations.
docs/configuration.md Documents pageTitleFormatter option and provides an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alternative Page Title Generator [v5-rc]

2 participants