Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update docs OG images titles #2767

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/app/docs/[...slug]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { notFound } from 'next/navigation';
import Post from 'components/pages/doc/post';
import { VERCEL_URL, MAX_TITLE_LENGTH } from 'constants/docs';
import LINKS from 'constants/links';
import { DEFAULT_IMAGE_PATH } from 'constants/seo-data';
import {
DOCS_DIR_PATH,
getAllPosts,
Expand Down Expand Up @@ -52,7 +51,9 @@ export async function generateMetadata({ params }) {
if (!isChangelog && !post) return notFound();

const title = post?.data?.title || 'Changelog';
const encodedTitle = Buffer.from(title).toString('base64');
const shortenedTitle =
title.length < MAX_TITLE_LENGTH ? title : `${title.slice(0, MAX_TITLE_LENGTH)}...`;
const encodedTitle = Buffer.from(shortenedTitle).toString('base64');

const sidebar = getSidebar();
const flatSidebar = await getFlatSidebar(sidebar);
Expand All @@ -63,10 +64,7 @@ export async function generateMetadata({ params }) {
return getMetadata({
title: `${title} - Neon Docs`,
description: isChangelog ? 'The latest product updates from Neon' : post.excerpt,
imagePath:
title.length < MAX_TITLE_LENGTH
? `${VERCEL_URL}/docs/og?title=${encodedTitle}&category=${encodedCategory}`
: DEFAULT_IMAGE_PATH,
imagePath: `${VERCEL_URL}/docs/og?title=${encodedTitle}&category=${encodedCategory}`,
pathname: `${LINKS.docs}/${currentSlug}`,
rssPathname: isChangelog ? `${LINKS.changelog}/rss.xml` : null,
type: 'article',
Expand Down
2 changes: 1 addition & 1 deletion src/constants/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const VERCEL_URL =
: process.env.NEXT_PUBLIC_DEFAULT_SITE_URL;

// @NOTE: the maximum length of the title to look fine on the og image
const MAX_TITLE_LENGTH = 52;
const MAX_TITLE_LENGTH = 60;

const HOME_MENU_ITEM = { title: 'Home', slug: 'introduction' };

Expand Down