Compare commits
No commits in common. "89c40f6a98d1f3d1fa46da8f1ac1f6767f12a7df" and "2d6b9d13996f577a837ec9540b808db11b2f4102" have entirely different histories.
89c40f6a98
...
2d6b9d1399
1
env
1
env
@ -14,4 +14,3 @@ S3_SECRET_ACCESS_KEY=9b4e412850582aab32ffdadbe23bb7ea972b39aaf79c34da0c19d3fcafe
|
|||||||
S3_REGION=ap-southeast-1
|
S3_REGION=ap-southeast-1
|
||||||
S3_ENDPOINT=https://jswmbraeandqttpcdfmj.supabase.co/storage/v1/s3
|
S3_ENDPOINT=https://jswmbraeandqttpcdfmj.supabase.co/storage/v1/s3
|
||||||
NEXT_PUBLIC_PAYLOAD_URL=http://localhost:3000
|
NEXT_PUBLIC_PAYLOAD_URL=http://localhost:3000
|
||||||
SITE_URL=http://localhost:3000
|
|
||||||
|
@ -15,7 +15,6 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
|||||||
let publishedAt = "";
|
let publishedAt = "";
|
||||||
let updatedAt = "";
|
let updatedAt = "";
|
||||||
let imgUrl = "";
|
let imgUrl = "";
|
||||||
let createdByName = "";
|
|
||||||
|
|
||||||
const slug = (await params).slug;
|
const slug = (await params).slug;
|
||||||
const blog = await fetchBlogDetail(slug);
|
const blog = await fetchBlogDetail(slug);
|
||||||
@ -27,9 +26,6 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
|||||||
imgUrl = blog.imgUrl;
|
imgUrl = blog.imgUrl;
|
||||||
publishedAt = blog.data.createdAt;
|
publishedAt = blog.data.createdAt;
|
||||||
updatedAt = blog.data.updatedAt;
|
updatedAt = blog.data.updatedAt;
|
||||||
if (!!blog?.data?.createdBy && typeof blog.data.createdBy !== "number") {
|
|
||||||
createdByName = blog.data.createdBy?.name ?? "";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// check for page data when blog is not found
|
// check for page data when blog is not found
|
||||||
const page = await fetchPageBySlug({ slug });
|
const page = await fetchPageBySlug({ slug });
|
||||||
@ -39,35 +35,22 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
|
|||||||
imgUrl = page.heroImg?.url;
|
imgUrl = page.heroImg?.url;
|
||||||
publishedAt = page.createdAt;
|
publishedAt = page.createdAt;
|
||||||
updatedAt = page.updatedAt;
|
updatedAt = page.updatedAt;
|
||||||
|
|
||||||
if (!!page?.createdBy && typeof page.createdBy !== "number") {
|
|
||||||
createdByName = page?.createdBy?.name ?? "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultMetadata.title = title;
|
defaultMetadata.title = title;
|
||||||
defaultMetadata.description = description;
|
defaultMetadata.description = description;
|
||||||
if (!!defaultMetadata.openGraph) {
|
if (!!defaultMetadata.openGraph) {
|
||||||
|
defaultMetadata.openGraph.title = title;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
defaultMetadata.openGraph.type = "article";
|
defaultMetadata.openGraph.type = "article";
|
||||||
defaultMetadata.openGraph.title = title;
|
|
||||||
defaultMetadata.openGraph.description = description;
|
defaultMetadata.openGraph.description = description;
|
||||||
defaultMetadata.openGraph.images = !!imgUrl ? [imgUrl] : undefined;
|
defaultMetadata.openGraph.title = title;
|
||||||
|
defaultMetadata.openGraph.images = !!imgUrl ? { url: imgUrl } : undefined;
|
||||||
}
|
}
|
||||||
defaultMetadata.twitter = {
|
|
||||||
card: "summary_large_image",
|
|
||||||
title: title,
|
|
||||||
description: description,
|
|
||||||
images: !!imgUrl ? [imgUrl] : undefined,
|
|
||||||
};
|
|
||||||
defaultMetadata.other = {
|
defaultMetadata.other = {
|
||||||
"article:published_time": publishedAt,
|
"article:published_time": publishedAt,
|
||||||
"article:modified_time": updatedAt,
|
"article:modified_time": updatedAt,
|
||||||
"twitter:label1": "Written by",
|
|
||||||
"twitter:data1": !!createdByName ? createdByName : "Admin",
|
|
||||||
"twitter:label2": "Est. reading time",
|
|
||||||
"twitter:data2": "3 minutes",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return defaultMetadata;
|
return defaultMetadata;
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import type { MetadataRoute } from "next";
|
|
||||||
|
|
||||||
export default function robots(): MetadataRoute.Robots {
|
|
||||||
const siteUrl = process.env.SITE_URL || "http://localhost:3000";
|
|
||||||
|
|
||||||
return {
|
|
||||||
rules: {
|
|
||||||
userAgent: "*",
|
|
||||||
allow: "/",
|
|
||||||
},
|
|
||||||
sitemap: `${siteUrl}/sitemap.xml`,
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
import type { MetadataRoute } from "next";
|
|
||||||
|
|
||||||
export default function sitemap(): MetadataRoute.Sitemap {
|
|
||||||
const siteUrl = process.env.SITE_URL || "http://localhost:3000";
|
|
||||||
|
|
||||||
// Define your static routes
|
|
||||||
const routes: string[] = ["", "/blog"];
|
|
||||||
|
|
||||||
// Create sitemap entries for static routes
|
|
||||||
const staticRoutesSitemap = routes.map((route) => ({
|
|
||||||
url: `${siteUrl}${route}`,
|
|
||||||
lastModified: new Date(),
|
|
||||||
changeFrequency: "weekly" as const,
|
|
||||||
priority: route === "" ? 1 : 0.8,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return [...staticRoutesSitemap];
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user