Let `_not-found` and `_error` set their title, and apply `titleTemplate` to the default one
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- full-stack
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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>.
- Ngôn ngữ chính
- TypeScript
- Star
- 684
- Fork
- 83
- Merge trung bình
- 15 giờ 22 phút
- Pull request đã merge (30 ngày)
- 219
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/void
-
`void platform install --app-access public` fails when Cloudflare reports Access is disabledĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/void#835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
voidzero-dev/void#834 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
voidzero-dev/void#833 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
voidzero-dev/void#832 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/void#808 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/void
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
open-webui/tether#52 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AykutSarac/jsoncrack.com#616 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
melgarafael/DeskcommCRM#4679 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement size:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày