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 天內回覆