-
Notifications
You must be signed in to change notification settings - Fork 0
Fix dependabot alerts & add canonical metadata to pages #18
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,39 +10,49 @@ import * as types from '@/typedefs/blockchain'; | |||||||||
| import { Skeleton } from '@heroui/skeleton'; | ||||||||||
| import { cache, Suspense } from 'react'; | ||||||||||
|
|
||||||||||
| const errorMetadata = { | ||||||||||
| title: 'Error', | ||||||||||
| openGraph: { | ||||||||||
| title: 'Error', | ||||||||||
| }, | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| export async function generateMetadata({ params }) { | ||||||||||
| const { licenseType, licenseId } = await params; | ||||||||||
|
|
||||||||||
| if (!licenseType || !['ND', 'MND', 'GND'].includes(licenseType)) { | ||||||||||
| return errorMetadata; | ||||||||||
| } | ||||||||||
| export async function generateMetadata({ params }) { | ||||||||||
|
||||||||||
| export async function generateMetadata({ params }) { | |
| export async function generateMetadata({ | |
| params, | |
| }: { params: Promise<{ licenseType: string; licenseId: string }> }) { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,16 +11,9 @@ import * as types from '@/typedefs/blockchain'; | |||||
| import { RiCloseLine } from 'react-icons/ri'; | ||||||
| import { isAddress } from 'viem'; | ||||||
|
|
||||||
| const errorMetadata = { | ||||||
| title: 'Error', | ||||||
| openGraph: { | ||||||
| title: 'Error', | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| const resolveNodeEthAddress = (nodeAddress?: string): types.EthAddress | null => { | ||||||
| if (!nodeAddress) { | ||||||
| return null; | ||||||
| const resolveNodeEthAddress = (nodeAddress?: string): types.EthAddress | null => { | ||||||
| if (!nodeAddress) { | ||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| if (nodeAddress.startsWith('0xai_')) { | ||||||
|
|
@@ -39,31 +32,48 @@ const resolveNodeEthAddress = (nodeAddress?: string): types.EthAddress | null => | |||||
| return nodeAddress; | ||||||
| }; | ||||||
|
|
||||||
| export async function generateMetadata({ params }) { | ||||||
| const { nodeAddr } = await params; | ||||||
| const resolvedNodeEthAddr = resolveNodeEthAddress(nodeAddr); | ||||||
|
|
||||||
| if (!resolvedNodeEthAddr) { | ||||||
| console.log(`[Node Page] Invalid node address: ${nodeAddr}`); | ||||||
| return errorMetadata; | ||||||
| } | ||||||
|
|
||||||
| let nodeResponse: types.OraclesAvailabilityResult & types.OraclesDefaultResult; | ||||||
|
|
||||||
| try { | ||||||
| ({ nodeResponse } = await fetchLicenseDetailsAndNodeAvailability(resolvedNodeEthAddr, config.environment)); | ||||||
| } catch (error) { | ||||||
| console.error(error); | ||||||
| return errorMetadata; | ||||||
| } | ||||||
|
|
||||||
| return { | ||||||
| title: `Node • ${nodeResponse.node_alias}`, | ||||||
| openGraph: { | ||||||
| title: `Node • ${nodeResponse.node_alias}`, | ||||||
| }, | ||||||
| }; | ||||||
| } | ||||||
| export async function generateMetadata({ params }) { | ||||||
|
||||||
| export async function generateMetadata({ params }) { | |
| export async function generateMetadata({ params }: { params: Promise<{ nodeAddr: string }> }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The params parameter is missing type annotations. According to Next.js best practices, this should be typed. Consider adding a type annotation like
{ params: Promise<{ ownerEthAddr: string }> }to improve type safety and catch potential errors at compile time.