fix: redirection middleware and meta format
This commit is contained in:
parent
5664afc4c1
commit
b456b89352
@ -24,7 +24,7 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
||||
if (!!blog) {
|
||||
// check for blog data
|
||||
title = `${!!blog.data?.meta?.title ? blog.data?.meta?.title : blog.data.title} - ${name}`;
|
||||
description = `${!!blog.data?.meta?.description ? blog.data?.meta?.description : blog.data.title} - ${name}`;
|
||||
description = `${!!blog.data?.meta?.description ? blog.data?.meta?.description : blog.data.title}`;
|
||||
imgUrl = blog.imgUrl;
|
||||
publishedAt = blog.data.createdAt;
|
||||
updatedAt = blog.data.updatedAt;
|
||||
@ -39,7 +39,7 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
||||
const page = await fetchPageBySlug({ slug });
|
||||
if (!!page) {
|
||||
title = `${!!page?.meta?.title ? page?.meta?.title : page.title} - ${name}`;
|
||||
description = `${!!page?.meta?.description ? page?.meta?.description : page.title} - ${name}`;
|
||||
description = `${!!page?.meta?.description ? page?.meta?.description : page.title}`;
|
||||
imgUrl = page.heroImg?.url;
|
||||
publishedAt = page.createdAt;
|
||||
updatedAt = page.updatedAt;
|
||||
|
@ -22,8 +22,8 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
||||
|
||||
// check for blog data
|
||||
if (!!team) {
|
||||
title = !!team.data.meta?.title ? team.data.meta?.title : `${team.data.name} - ${name}`;
|
||||
description = !!team.data.meta?.description ? team.data.meta?.description : description;
|
||||
title = `${!!team.data?.meta?.title ? team.data?.meta?.title : team.data.name} - ${name}`;
|
||||
description = !!team.data.meta?.description ? team.data.meta?.description : team.data.name;
|
||||
imgUrl = team.imgUrl;
|
||||
if (!!team?.data?.meta?.canonical_url) {
|
||||
canonicalUrl = team.data.meta.canonical_url;
|
||||
|
@ -21,7 +21,8 @@ export function middleware(request: NextRequest) {
|
||||
|
||||
// redirect for /blog/<slug>/ path
|
||||
const blogPathRegex = /^\/blog\/([^\/]+)(\/[^\/]*)*\/?$/;
|
||||
if (blogPathRegex.test(path)) {
|
||||
console.log("path", blogPathRegex.test(path) && !path.includes("/blog/?"));
|
||||
if (blogPathRegex.test(path) && !path.includes("/blog/?")) {
|
||||
const newBlogPath = path.replace(/^\/blog/, "") || "/";
|
||||
return NextResponse.redirect(`${mainUrl}${newBlogPath}`, 301);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user