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

attempt to improve og #377

Merged
merged 2 commits into from
Nov 11, 2024
Merged
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
34 changes: 19 additions & 15 deletions apps/playground/src/components/site/metatags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,53 @@ export default function Metatags({
keywords =
"developer, tools, cardano, blockchain, sdk, plutus, crypto, web3, metaverse, gaming, ecommerce, nfts, apis, aiken";
}

let _title = title;
if (title === undefined) {
title = "Cardano Web3 TypeScript SDK & off-chain Framework";
_title = "Mesh JS - Cardano Web3 TypeScript SDK & Off-Chain Framework";
} else {
title = title + " - Mesh JS";
}

title = title + " - Mesh JS";

return (
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="utf-8" />

<title>{title}</title>
<title>{title ? title : _title}</title>
<meta name="description" content={description} />
<meta name="keywords" content={keywords} />

<meta property="og:title" content={title} />
<meta property="og:site_name" content={title} />
<meta property="og:title" content={_title} />
<meta property="og:site_name" content={_title} />
<meta property="og:type" content="website" />
<meta property="og:description" content={description} />
{image ? (
{image && (
<meta property="og:image" content={`https://meshjs.dev${image}`} />
) : (
)}
{title && image === undefined && (
<meta
property="og:image"
content={`https://meshjs.dev/api/og?title=${title}`}
/>
)}
<meta property="og:image:alt" content={title} />
<meta property="og:image:alt" content={_title} />

<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@meshsdk" />
<meta name="twitter:title" content={title} />
<meta name="twitter:title" content={_title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:creator" content="@meshsdk" />
{image ? (
<meta name="twitter:image" content={`https://meshjs.dev${image}`} />
) : (
{image && (
<meta property="twitter:image" content={`https://meshjs.dev${image}`} />
)}
{title && image === undefined && (
<meta
name="twitter:image"
property="twitter:image"
content={`https://meshjs.dev/api/og?title=${title}`}
/>
)}
<meta name="twitter:image:alt" content={title} />
<meta name="twitter:image:alt" content={_title} />

<link
rel="apple-touch-icon"
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/pages/api/og.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function handler(request: NextRequest) {
const hasTitle = searchParams.has("title");
const title = hasTitle
? searchParams.get("title")?.slice(0, 100)
: "Mesh JS - Cardano Web3 TypeScript SDK & off-chain Framework";
: "Mesh JS - Cardano Web3 TypeScript SDK & Off-Chain Framework";

return new ImageResponse(
(
Expand Down