feat(seo): add widescreen social previews
This commit is contained in:
@@ -43,6 +43,7 @@ export async function generateMetadata({
|
|||||||
description: post.excerpt,
|
description: post.excerpt,
|
||||||
url,
|
url,
|
||||||
type: "article",
|
type: "article",
|
||||||
|
siteName: "Poyraz Avsever",
|
||||||
locale: locale === "en" ? "en_US" : "tr_TR",
|
locale: locale === "en" ? "en_US" : "tr_TR",
|
||||||
alternateLocale:
|
alternateLocale:
|
||||||
translations.length > 1
|
translations.length > 1
|
||||||
@@ -64,6 +65,7 @@ export async function generateMetadata({
|
|||||||
title: post.title,
|
title: post.title,
|
||||||
description: post.excerpt,
|
description: post.excerpt,
|
||||||
images: [post.coverImage],
|
images: [post.coverImage],
|
||||||
|
creator: "@poyrazavsever",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,17 @@ import {
|
|||||||
getAnimationSourceBySlug,
|
getAnimationSourceBySlug,
|
||||||
listAnimationSources,
|
listAnimationSources,
|
||||||
} from "@/data/animation-sources";
|
} from "@/data/animation-sources";
|
||||||
|
import {
|
||||||
const SITE_URL =
|
createAlternates,
|
||||||
process.env.NEXT_PUBLIC_SITE_URL || "https://poyrazavsever.com";
|
getAbsoluteUrl,
|
||||||
|
getLocalizedUrl,
|
||||||
|
type SiteLocale,
|
||||||
|
} from "@/lib/seo";
|
||||||
|
|
||||||
type AnimationSourceDetailPageProps = {
|
type AnimationSourceDetailPageProps = {
|
||||||
params: Promise<{ locale: string; slug: string }>;
|
params: Promise<{ locale: string; slug: string }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getLocalizedPath(locale: string, slug: string) {
|
|
||||||
const localePrefix = locale === "tr" ? "" : `/${locale}`;
|
|
||||||
return `${localePrefix}/animation-sources/${slug}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const sources = await listAnimationSources();
|
const sources = await listAnimationSources();
|
||||||
return sources.map((source) => ({
|
return sources.map((source) => ({
|
||||||
@@ -39,22 +37,15 @@ export async function generateMetadata({
|
|||||||
return { title: locale === "en" ? "Source not found" : "Kaynak bulunamadı" };
|
return { title: locale === "en" ? "Source not found" : "Kaynak bulunamadı" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${SITE_URL}${getLocalizedPath(locale, source.slug)}`;
|
const siteLocale = locale as SiteLocale;
|
||||||
const socialImageUrl = new URL(source.coverImage, SITE_URL).toString();
|
const path = `/animation-sources/${source.slug}`;
|
||||||
const turkishUrl = `${SITE_URL}${getLocalizedPath("tr", source.slug)}`;
|
const url = getLocalizedUrl(siteLocale, path);
|
||||||
const englishUrl = `${SITE_URL}${getLocalizedPath("en", source.slug)}`;
|
const socialImageUrl = getAbsoluteUrl(source.coverImage);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: source.title,
|
title: source.title,
|
||||||
description: source.excerpt,
|
description: source.excerpt,
|
||||||
alternates: {
|
alternates: createAlternates(siteLocale, { tr: path, en: path }),
|
||||||
canonical: url,
|
|
||||||
languages: {
|
|
||||||
"tr-TR": turkishUrl,
|
|
||||||
"en-US": englishUrl,
|
|
||||||
"x-default": turkishUrl,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: source.title,
|
title: source.title,
|
||||||
description: source.excerpt,
|
description: source.excerpt,
|
||||||
@@ -68,7 +59,7 @@ export async function generateMetadata({
|
|||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: socialImageUrl,
|
url: socialImageUrl,
|
||||||
type: "image/gif",
|
type: "image/webp",
|
||||||
width: 480,
|
width: 480,
|
||||||
height: 480,
|
height: 480,
|
||||||
alt: source.title,
|
alt: source.title,
|
||||||
@@ -98,7 +89,10 @@ export default async function AnimationSourceDetailPage({
|
|||||||
|
|
||||||
if (!source) notFound();
|
if (!source) notFound();
|
||||||
|
|
||||||
const url = `${SITE_URL}${getLocalizedPath(locale, source.slug)}`;
|
const url = getLocalizedUrl(
|
||||||
|
locale as SiteLocale,
|
||||||
|
`/animation-sources/${source.slug}`,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ import type { Metadata } from "next";
|
|||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { AnimationSourcesContent } from "@/components/animation-sources-content";
|
import { AnimationSourcesContent } from "@/components/animation-sources-content";
|
||||||
import { listAnimationSources } from "@/data/animation-sources";
|
import { listAnimationSources } from "@/data/animation-sources";
|
||||||
|
import {
|
||||||
const SITE_URL =
|
createAlternates,
|
||||||
process.env.NEXT_PUBLIC_SITE_URL || "https://poyrazavsever.com";
|
getAbsoluteUrl,
|
||||||
|
getLocalizedUrl,
|
||||||
|
type SiteLocale,
|
||||||
|
} from "@/lib/seo";
|
||||||
|
|
||||||
type AnimationSourcesPageProps = {
|
type AnimationSourcesPageProps = {
|
||||||
params: Promise<{ locale: string }>;
|
params: Promise<{ locale: string }>;
|
||||||
@@ -14,27 +17,18 @@ export async function generateMetadata({
|
|||||||
params,
|
params,
|
||||||
}: AnimationSourcesPageProps): Promise<Metadata> {
|
}: AnimationSourcesPageProps): Promise<Metadata> {
|
||||||
const { locale } = await params;
|
const { locale } = await params;
|
||||||
const [t, sources] = await Promise.all([
|
const t = await getTranslations({ locale, namespace: "AnimationSources" });
|
||||||
getTranslations({ locale, namespace: "AnimationSources" }),
|
const siteLocale = locale as SiteLocale;
|
||||||
listAnimationSources(locale),
|
const url = getLocalizedUrl(siteLocale, "/animation-sources");
|
||||||
]);
|
const socialImageUrl = getAbsoluteUrl("/og.png");
|
||||||
const localizedPath = locale === "en" ? "/en/animation-sources" : "/animation-sources";
|
|
||||||
const url = `${SITE_URL}${localizedPath}`;
|
|
||||||
const socialImagePath = sources[0]?.coverImage ?? "/logo/logo.webp";
|
|
||||||
const socialImageUrl = new URL(socialImagePath, SITE_URL).toString();
|
|
||||||
const isGif = socialImagePath.toLowerCase().endsWith(".gif");
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: t("title"),
|
title: t("title"),
|
||||||
description: t("description"),
|
description: t("description"),
|
||||||
alternates: {
|
alternates: createAlternates(siteLocale, {
|
||||||
canonical: url,
|
tr: "/animation-sources",
|
||||||
languages: {
|
en: "/animation-sources",
|
||||||
"tr-TR": `${SITE_URL}/animation-sources`,
|
}),
|
||||||
"en-US": `${SITE_URL}/en/animation-sources`,
|
|
||||||
"x-default": `${SITE_URL}/animation-sources`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: t("title"),
|
title: t("title"),
|
||||||
description: t("description"),
|
description: t("description"),
|
||||||
@@ -45,9 +39,9 @@ export async function generateMetadata({
|
|||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: socialImageUrl,
|
url: socialImageUrl,
|
||||||
type: isGif ? "image/gif" : "image/png",
|
type: "image/png",
|
||||||
width: isGif ? 480 : 1200,
|
width: 1200,
|
||||||
height: isGif ? 480 : 1200,
|
height: 630,
|
||||||
alt: t("title"),
|
alt: t("title"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export async function generateMetadata({ params }: BlogDetailPageProps): Promise
|
|||||||
description: post.excerpt,
|
description: post.excerpt,
|
||||||
url,
|
url,
|
||||||
type: "article",
|
type: "article",
|
||||||
|
siteName: "Poyraz Avsever",
|
||||||
locale: locale === "en" ? "en_US" : "tr_TR",
|
locale: locale === "en" ? "en_US" : "tr_TR",
|
||||||
alternateLocale:
|
alternateLocale:
|
||||||
translations.length > 1
|
translations.length > 1
|
||||||
@@ -64,6 +65,7 @@ export async function generateMetadata({ params }: BlogDetailPageProps): Promise
|
|||||||
title: post.title,
|
title: post.title,
|
||||||
description: post.excerpt,
|
description: post.excerpt,
|
||||||
images: [post.coverImage],
|
images: [post.coverImage],
|
||||||
|
creator: "@poyrazavsever",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -77,8 +79,7 @@ export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isNewsletterCategory(post.category)) {
|
if (isNewsletterCategory(post.category)) {
|
||||||
const localePrefix = locale === "tr" ? "" : `/${locale}`;
|
permanentRedirect(`/${locale}/agenda/${post.slug}`);
|
||||||
permanentRedirect(`${localePrefix}/agenda/${post.slug}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+15
-4
@@ -41,6 +41,17 @@ export async function generateMetadata({
|
|||||||
authors: [{ name: "Poyraz Avsever" }],
|
authors: [{ name: "Poyraz Avsever" }],
|
||||||
creator: "Poyraz Avsever",
|
creator: "Poyraz Avsever",
|
||||||
publisher: "Poyraz Avsever",
|
publisher: "Poyraz Avsever",
|
||||||
|
robots: {
|
||||||
|
index: true,
|
||||||
|
follow: true,
|
||||||
|
googleBot: {
|
||||||
|
index: true,
|
||||||
|
follow: true,
|
||||||
|
"max-image-preview": "large",
|
||||||
|
"max-snippet": -1,
|
||||||
|
"max-video-preview": -1,
|
||||||
|
},
|
||||||
|
},
|
||||||
openGraph: {
|
openGraph: {
|
||||||
type: "website",
|
type: "website",
|
||||||
locale: locale === "tr" ? "tr_TR" : "en_US",
|
locale: locale === "tr" ? "tr_TR" : "en_US",
|
||||||
@@ -49,10 +60,10 @@ export async function generateMetadata({
|
|||||||
description: description,
|
description: description,
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: "/logo/logo.webp",
|
url: "/og.png",
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 1200,
|
height: 630,
|
||||||
alt: "Poyraz Avsever Logo",
|
alt: t("socialImageAlt"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -60,7 +71,7 @@ export async function generateMetadata({
|
|||||||
card: "summary_large_image",
|
card: "summary_large_image",
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
images: ["/logo/logo.webp"],
|
images: ["/og.png"],
|
||||||
creator: "@poyrazavsever",
|
creator: "@poyrazavsever",
|
||||||
},
|
},
|
||||||
keywords: [
|
keywords: [
|
||||||
|
|||||||
+13
-3
@@ -28,9 +28,9 @@ function normalizePath(path: string) {
|
|||||||
|
|
||||||
export function getLocalizedPath(locale: SiteLocale, path: string) {
|
export function getLocalizedPath(locale: SiteLocale, path: string) {
|
||||||
const normalizedPath = normalizePath(path);
|
const normalizedPath = normalizePath(path);
|
||||||
|
return normalizedPath === "/"
|
||||||
if (locale === "tr") return normalizedPath;
|
? `/${locale}`
|
||||||
return normalizedPath === "/" ? "/en" : `/en${normalizedPath}`;
|
: `/${locale}${normalizedPath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAbsoluteUrl(path: string) {
|
export function getAbsoluteUrl(path: string) {
|
||||||
@@ -88,17 +88,27 @@ export function createPageMetadata({
|
|||||||
alternates: createAlternates(locale, { tr: path, en: path }),
|
alternates: createAlternates(locale, { tr: path, en: path }),
|
||||||
openGraph: {
|
openGraph: {
|
||||||
type: "website",
|
type: "website",
|
||||||
|
siteName: "Poyraz Avsever",
|
||||||
locale: locale === "tr" ? "tr_TR" : "en_US",
|
locale: locale === "tr" ? "tr_TR" : "en_US",
|
||||||
alternateLocale: locale === "tr" ? ["en_US"] : ["tr_TR"],
|
alternateLocale: locale === "tr" ? ["en_US"] : ["tr_TR"],
|
||||||
url,
|
url,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
images: [
|
||||||
|
{
|
||||||
|
url: "/og.png",
|
||||||
|
width: 1200,
|
||||||
|
height: 630,
|
||||||
|
alt: "Poyraz Avsever",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
twitter: {
|
twitter: {
|
||||||
card: "summary_large_image",
|
card: "summary_large_image",
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
creator: "@poyrazavsever",
|
creator: "@poyrazavsever",
|
||||||
|
images: ["/og.png"],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -171,7 +171,8 @@
|
|||||||
"Metadata": {
|
"Metadata": {
|
||||||
"title": "Poyraz Avsever | Portfolio",
|
"title": "Poyraz Avsever | Portfolio",
|
||||||
"titleTemplate": "%s | Poyraz Avsever",
|
"titleTemplate": "%s | Poyraz Avsever",
|
||||||
"description": "Poyraz Avsever's personal portfolio website sharing projects, software content, and technical works."
|
"description": "Poyraz Avsever's personal portfolio website sharing projects, software content, and technical works.",
|
||||||
|
"socialImageAlt": "Poyraz Avsever portfolio social preview"
|
||||||
},
|
},
|
||||||
"SearchCommand": {
|
"SearchCommand": {
|
||||||
"placeholder": "Search pages and links...",
|
"placeholder": "Search pages and links...",
|
||||||
|
|||||||
+2
-1
@@ -171,7 +171,8 @@
|
|||||||
"Metadata": {
|
"Metadata": {
|
||||||
"title": "Poyraz Avsever | Portfolyo",
|
"title": "Poyraz Avsever | Portfolyo",
|
||||||
"titleTemplate": "%s | Poyraz Avsever",
|
"titleTemplate": "%s | Poyraz Avsever",
|
||||||
"description": "Poyraz Avsever'in projelerini, yazılım içeriklerini ve teknik çalışmalarını paylaştığı kişisel portfolyo sitesi."
|
"description": "Poyraz Avsever'in projelerini, yazılım içeriklerini ve teknik çalışmalarını paylaştığı kişisel portfolyo sitesi.",
|
||||||
|
"socialImageAlt": "Poyraz Avsever portfolyo paylaşım görseli"
|
||||||
},
|
},
|
||||||
"SearchCommand": {
|
"SearchCommand": {
|
||||||
"placeholder": "Sayfa ve bağlantılarda ara...",
|
"placeholder": "Sayfa ve bağlantılarda ara...",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 992 KiB |
Reference in New Issue
Block a user