Let `_not-found` and `_error` set their title, and apply `titleTemplate` to the default one
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
- 领域
- full-stack
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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>.
- 主要语言
- TypeScript
- 星标
- 684
- 派生
- 83
- 平均合并
- 15 小时 22 分钟
- 30 天内合并 PR
- 219
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
voidzero-dev/void#835 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
voidzero-dev/void#834 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
voidzero-dev/void#833 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 32/100
voidzero-dev/void#832 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
voidzero-dev/void#808 · 1 条评论 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
open-webui/tether#52 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
AykutSarac/jsoncrack.com#616 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
melgarafael/DeskcommCRM#4679 ·
维护者通常 1 天内回复
-
enhancement size:medium
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复