Implement catch-all route to redirect unmatched paths to the homepage; enhance meta tags in email handler and mail detail components for better SEO compliance by formatting and ensuring noindex directives are consistently applied.

This commit is contained in:
akazwz
2025-06-07 10:29:43 +08:00
parent 271e1173d1
commit fc0c8792ee
4 changed files with 50 additions and 11 deletions

View File

@@ -20,4 +20,6 @@ export default [
route("/sitemap.xml", "routes/sitemap[.]xml.tsx"),
route("/robots.txt", "routes/robots[.]txt.tsx"),
route("/site.webmanifest", "routes/site[.]webmanifest.tsx"),
// 捕获所有未匹配的路径,自动跳转到首页
route("*", "routes/$.ts"),
] satisfies RouteConfig;

6
app/routes/$.ts Normal file
View File

@@ -0,0 +1,6 @@
import { redirect } from "react-router";
export async function loader() {
// 404页面自动跳转到首页
return redirect("/");
}

View File

@@ -119,12 +119,22 @@ export function meta() {
{ title: "开发环境邮件处理器 - Smail" },
{
name: "description",
content: "开发环境专用的邮件处理路由,用于模拟 Cloudflare Workers 的 email handler 功能。",
content:
"开发环境专用的邮件处理路由,用于模拟 Cloudflare Workers 的 email handler 功能。",
},
// 开发页面不应该被搜索引擎索引
{ name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{
name: "robots",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "googlebot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "bingbot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
];
}

View File

@@ -163,9 +163,18 @@ export function meta({ data }: Route.MetaArgs) {
content: "查看您在Smail临时邮箱中收到的邮件详情。",
},
// 即使是404页面也要阻止索引
{ name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{
name: "robots",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "googlebot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "bingbot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
];
}
@@ -180,11 +189,23 @@ export function meta({ data }: Route.MetaArgs) {
content: `查看来自${email.fromAddress}的邮件"${email.subject || "无主题"}"。接收时间:${new Date(email.receivedAt).toLocaleDateString("zh-CN")}`,
},
// 阻止搜索引擎索引邮件内容页面
{ name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{ name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" },
{
name: "robots",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "googlebot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
{
name: "bingbot",
content: "noindex, nofollow, noarchive, nosnippet, noimageindex",
},
// 阻止缓存
{ "http-equiv": "cache-control", content: "no-cache, no-store, must-revalidate" },
{
"http-equiv": "cache-control",
content: "no-cache, no-store, must-revalidate",
},
{ "http-equiv": "pragma", content: "no-cache" },
{ "http-equiv": "expires", content: "0" },
];