GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(pages): allow `titleTemplate` in middleware `headDefaults` by karthickeyan-dev · Pull Request #797 · voidzero-dev/void

Conversation

@karthickeyan-dev

@karthickeyan-dev karthickeyan-dev commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Closes #796

Summary

titleTemplate could only be set once, for the whole site, in void.config.ts. headDefaults was typed HeadDescriptor, which has no titleTemplate, and resolveHead() read the template only from the config. So one section of a site couldn't have its own title suffix.

  • packages/void/src/runtime/handler.ts: headDefaults is now typed HeadConfig, so c.set('headDefaults', { titleTemplate }) type-checks.
  • packages/void/src/pages/head.ts: resolveHead() uses the middleware's titleTemplate and falls back to the config's. The resolved head still doesn't include titleTemplate.
  • packages/void/src/pages/protocol.ts: the three headDefaults reads cast to HeadConfig.
  • docs/guide/pages-routing/head.md: an example under Middleware defaults, and the title row in the precedence table.
// middleware/admin.ts
import { defineMiddleware } from 'void';

export default defineMiddleware(async (c, next) => {
  if (c.req.path.startsWith('/admin')) {
    c.set('headDefaults', { ...c.get('headDefaults'), titleTemplate: '%s | Admin' });
  }
  await next();
});

A page returning { title: "Users" } under /admin now renders <title>Users | Admin</title>. Sites that don't set titleTemplate in middleware see no change.

Tests

  • pages-head.test.ts: the middleware template wins over the config's, applies when the config has none, falls back to the config's when middleware doesn't set one, and isn't emitted in the resolved head.
  • routing-runtime.test.ts: a defineMiddleware on /admin/* sets the template, and createPageGetHandler returns Users | Admin under /admin and Users | My Site elsewhere.

4 of the new cases fail without the fix. Without the fix, the runtime test also fails to type-check (TS2769 on c.set).

Verification

  • vp run check: 33/33 pass
  • vp test run: 792 files pass, 1 skipped (16,676 tests pass, 37 skipped)

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@karthickeyan-dev @claude
Allow titleTemplate in middleware headDefaults, closes voidzero-d…
15d5e38
…ev#796.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow titleTemplate in middleware's headDefaults

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@karthickeyan-dev
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.