Skip to content

Commit cb80a04

Browse files
committed
feat(insights): add opengraph images & improve metadata
1 parent ae90e5d commit cb80a04

File tree

9 files changed

+63
-16
lines changed

9 files changed

+63
-16
lines changed
805 KB
Loading

apps/insights/src/app/price-feeds/[slug]/layout.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
import type { Metadata } from "next";
2+
import { notFound } from "next/navigation";
3+
4+
import { Cluster, getFeeds } from "../../../services/pyth";
25

36
export { PriceFeedLayout as default } from "../../../components/PriceFeed/layout";
47

5-
export const metadata: Metadata = {
6-
title: "Price Feeds",
8+
type Props = {
9+
params: Promise<{
10+
slug: string;
11+
}>;
12+
};
13+
14+
export const generateMetadata = async ({
15+
params,
16+
}: Props): Promise<Metadata> => {
17+
const [{ slug }, feeds] = await Promise.all([
18+
params,
19+
getFeeds(Cluster.Pythnet),
20+
]);
21+
const symbol = decodeURIComponent(slug);
22+
const feed = feeds.find((item) => item.symbol === symbol);
23+
24+
return feed
25+
? {
26+
title: feed.product.display_symbol,
27+
description: `See live market quotes for ${feed.product.description}.`,
28+
}
29+
: notFound();
730
};
831

932
export const dynamic = "error";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
import type { Metadata } from "next";
2+
13
export { ZoomLayoutTransition as default } from "../../components/ZoomLayoutTransition";
4+
5+
export const metadata: Metadata = {
6+
title: {
7+
default: "Price Feeds",
8+
template: "%s | Price Feeds | Pyth Network Insights",
9+
},
10+
description: "Explore market data on the Pyth network.",
11+
};
Loading
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import type { Metadata } from "next";
2-
31
export { PriceFeeds as default } from "../../components/PriceFeeds";
42

5-
export const metadata: Metadata = {
6-
title: "Price Feeds",
7-
};
8-
93
export const dynamic = "error";
104
export const revalidate = 3600;

apps/insights/src/app/publishers/[cluster]/[key]/layout.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
import { lookup } from "@pythnetwork/known-publishers";
12
import type { Metadata } from "next";
23

34
export { PublishersLayout as default } from "../../../../components/Publisher/layout";
45

5-
export const metadata: Metadata = {
6-
title: "Publishers",
6+
type Props = {
7+
params: Promise<{
8+
key: string;
9+
}>;
10+
};
11+
12+
export const generateMetadata = async ({
13+
params,
14+
}: Props): Promise<Metadata> => {
15+
const { key } = await params;
16+
const knownPublisher = lookup(key);
17+
const publisher = knownPublisher?.name ?? key;
18+
19+
return {
20+
title: publisher,
21+
description: `Evaluate performance for data published by ${publisher}.`,
22+
};
723
};
824

925
export const dynamic = "error";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
import type { Metadata } from "next";
2+
13
export { ZoomLayoutTransition as default } from "../../components/ZoomLayoutTransition";
4+
5+
export const metadata: Metadata = {
6+
title: {
7+
default: "Publishers",
8+
template: "%s | Publishers | Pyth Network Insights",
9+
},
10+
description: "Explore publishers who contribute to the Pyth network.",
11+
};
Loading
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import type { Metadata } from "next";
2-
31
export { Publishers as default } from "../../components/Publishers";
42

5-
export const metadata: Metadata = {
6-
title: "Publishers",
7-
};
8-
93
export const dynamic = "error";
104
export const revalidate = 3600;

0 commit comments

Comments
 (0)