Let `_not-found` and `_error` set their title, and apply `titleTemplate` to the default one
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- full-stack
Research direction
Start with renderPageFailure() and resolveHead(), where the fallback title is added after the head is resolved, so the template is never applied to it. Check how _not-found and _error are rendered, and whether the second proposal (a head export for error pages) is needed or whether applying the template is enough. Done means a 404 page's <title> reads Not Found | My App when titleTemplate is set, and the existing tests still pass. Confirm the design direction with a maintainer before adding a new export.
Written by the indexing model from the issue text.
Description
Version
void 1.9.0
Problem
With head: { titleTemplate: '%s | My App' } in void.config.ts, every page's tab gets the app name, except the error pages:
| Path | Status | <title> |
|---|---|---|
/ |
200 | Home | My App |
/about |
200 | About | My App |
/no-such-page |
404 | Not Found |
renderPageFailure() resolves the head with no page title, so resolveHead() never applies the template. It then adds its own title after that step:
title: head?.title ?? (status === 404 ? 'Not Found' : 'Internal Server Error')
_not-found and _error can't change this either. They can't have a .server.ts, so they have no head, and a headDefaults.title set in middleware would reach every page that sets no title of its own, not just the error pages. So the error pages can't say "Page not found" to match their heading, and they're the only tabs without the app name.
Proposal
-
Apply the template to the default title, by passing it through
resolveHead()as the page title:Not Found | My App. That's a small change, and it makes these pages match every other page without any code in the app. -
Let error pages set their title. For example, a
headexport from_not-foundand_error, taking theerrorthey render:// pages/_not-found.tsx export const head = { title: 'Page not found' };// pages/_error.tsx export const head = (error: PageError) => ({ title: error.status === 404 ? 'Page not found' : 'Something went wrong', });
Prior art
- Next.js:
not-found.tsxcan exportmetadata, and the root layout'stitle.templateapplies to it. - Nuxt:
error.vuecallsuseHead(), and the app'stitleTemplateapplies. - SvelteKit:
+error.sveltesets its title with<svelte:head>.
- Dominant language
- TypeScript
- Stars
- 684
- Forks
- 83
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 219
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from voidzero-dev/void
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
voidzero-dev/void#835 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
voidzero-dev/void#834 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
voidzero-dev/void#833 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
voidzero-dev/void#832 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
voidzero-dev/void#808 · 1 comment ·
Maintainers usually reply within 1 day
All issues in voidzero-dev/void
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
open-webui/tether#52 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AykutSarac/jsoncrack.com#616 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
melgarafael/DeskcommCRM#4679 ·
Maintainers usually reply within 1 day
-
enhancement size:medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day