Skip to content

Commit aa7f0f8

Browse files
Merge pull request #27 from SOGeKING-NUL/main
Add Open Graph metadata support and assets
2 parents 355da2b + 1fb2210 commit aa7f0f8

4 files changed

Lines changed: 102 additions & 3 deletions

File tree

app/layout.tsx

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type React from "react"
22
import type { Metadata } from "next"
33
import { Inter, Playfair_Display } from "next/font/google"
44
import "./globals.css"
5+
import { getBaseUrl, getAbsoluteUrl, getOgImageUrl } from "@/lib/metadata"
56

67
const inter = Inter({ subsets: ["latin"] })
78
const playfair = Playfair_Display({
@@ -10,12 +11,63 @@ const playfair = Playfair_Display({
1011
display: "swap",
1112
})
1213

14+
const baseUrl = getBaseUrl()
15+
const siteUrl = getAbsoluteUrl("")
16+
const ogImage = getOgImageUrl("/stability-nexus-og.png")
17+
1318
export const metadata: Metadata = {
14-
title: "Stable Viewpoints",
19+
title: {
20+
default: "Stable Viewpoints",
21+
template: "%s | Stable Viewpoints",
22+
},
1523
description: "An independent and decentralized publication focused on stability.",
24+
keywords: ["stablecoins", "blockchain", "cryptocurrency", "DeFi", "economic stability", "monetary systems", "AI governance"],
25+
authors: [{ name: "Stable Viewpoints" }],
26+
creator: "Stable Viewpoints",
27+
publisher: "Stable Viewpoints",
28+
metadataBase: new URL(baseUrl),
29+
alternates: {
30+
canonical: siteUrl,
31+
},
32+
openGraph: {
33+
type: "website",
34+
locale: "en_US",
35+
url: siteUrl,
36+
siteName: "Stable Viewpoints",
37+
title: "Stable Viewpoints - Independent Articles about Stability",
38+
description: "An independent and decentralized publication focused on stability. Explore thoughtful perspectives on blockchain, cryptocurrencies, AI, DeFi, and economic stability.",
39+
images: [
40+
{
41+
url: ogImage,
42+
width: 1200,
43+
height: 630,
44+
alt: "Stable Viewpoints - Independent Articles about Stability",
45+
},
46+
],
47+
},
48+
twitter: {
49+
card: "summary_large_image",
50+
title: "Stable Viewpoints - Independent Articles about Stability",
51+
description: "An independent and decentralized publication focused on stability.",
52+
images: [ogImage],
53+
creator: "@StabilityNexus",
54+
site: "@StabilityNexus",
55+
},
1656
icons: {
17-
icon: '/images/favicon.ico'
18-
}
57+
icon: '/images/favicon.ico',
58+
apple: '/images/favicon.ico',
59+
},
60+
robots: {
61+
index: true,
62+
follow: true,
63+
googleBot: {
64+
index: true,
65+
follow: true,
66+
"max-video-preview": -1,
67+
"max-image-preview": "large",
68+
"max-snippet": -1,
69+
},
70+
},
1971
}
2072

2173
export default function RootLayout({

lib/metadata.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
export function getBaseUrl(): string {
3+
4+
if (process.env.NODE_ENV === 'production') {
5+
return 'https://viewpoints.stability.nexus'
6+
}
7+
return 'http://localhost:3000'
8+
}
9+
10+
/**
11+
* Get absolute URL for a path
12+
*/
13+
export function getAbsoluteUrl(path: string): string {
14+
const baseUrl = getBaseUrl()
15+
16+
// Ensure path starts with /
17+
const normalizedPath = path.startsWith('/') ? path : `/${path}`
18+
return `${baseUrl}${normalizedPath}`
19+
}
20+
21+
/**
22+
* Get absolute image URL for Open Graph
23+
*/
24+
export function getOgImageUrl(imagePath: string): string {
25+
26+
// If already absolute URL, return as is
27+
if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
28+
return imagePath
29+
}
30+
31+
return getAbsoluteUrl(imagePath)
32+
}
33+

0 commit comments

Comments
 (0)