-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,62 @@ | ||
import { getBaseUrl } from '@/base-url'; | ||
import type { Metadata } from 'next'; | ||
import type { Icons } from 'next/dist/lib/metadata/types/metadata-types'; | ||
import { betaImagesRoot } from '../constants'; | ||
import type { IconDescriptor } from 'next/dist/lib/metadata/types/metadata-types'; | ||
|
||
const siteName = 'Walletbeat'; | ||
const siteDescription = | ||
'Walletbeat is an Ethereum wallet rating site. It aims to provide a trustworthy, up-to-date source of information about the state of the Ethereum wallet ecosystem'; | ||
const defaultKeywords = ['walletbeat', 'ethereum', 'wallet', 'wallets', 'wallet beat', 'evm']; | ||
const defaultIcons: Icons = { | ||
icon: [ | ||
{ | ||
url: `${betaImagesRoot}/favicon.ico`, | ||
sizes: '16x16', | ||
}, | ||
{ | ||
url: `${betaImagesRoot}/icon.jpg`, | ||
}, | ||
], | ||
const defaultFavicon: IconDescriptor = { | ||
url: '/images/favicon.ico', | ||
sizes: '16x16', | ||
}; | ||
const defaultMainIcon: IconDescriptor = { | ||
url: '/images/icon.jpg', | ||
}; | ||
const locale = 'en-US'; | ||
|
||
export function generateBasicMetadata({ | ||
title, | ||
route, | ||
description = undefined, | ||
icons = undefined, | ||
mainIcon = undefined, | ||
favIcon = undefined, | ||
keywordsBefore = undefined, | ||
keywordsAfter = undefined, | ||
}: { | ||
title: string; | ||
route: string; | ||
icons?: Metadata['icons']; | ||
mainIcon?: IconDescriptor; | ||
favIcon?: string; | ||
description?: string; | ||
keywordsBefore?: string[]; | ||
keywordsAfter?: string[]; | ||
}): Metadata { | ||
let favIconDescriptor = defaultFavicon; | ||
if (favIcon !== undefined) { | ||
favIconDescriptor = { ...defaultFavicon, url: favIcon }; | ||
} | ||
const mainIconDescriptor = mainIcon ?? defaultMainIcon; | ||
const urlRoot = getBaseUrl(); | ||
return { | ||
title, | ||
applicationName: siteName, | ||
description: description ?? siteDescription, | ||
keywords: (keywordsBefore ?? []).concat(defaultKeywords).concat(keywordsAfter ?? []), | ||
icons: icons ?? defaultIcons, | ||
icons: [favIconDescriptor, mainIconDescriptor], | ||
openGraph: { | ||
type: 'website', | ||
determiner: '', | ||
url: `${urlRoot}${route}`, | ||
title, | ||
description: description ?? siteDescription, | ||
siteName, | ||
locale, | ||
images: { | ||
url: `${urlRoot}${mainIconDescriptor.url}`, | ||
secureUrl: `${urlRoot}${mainIconDescriptor.url}`, | ||
alt: title, | ||
}, | ||
}, | ||
}; | ||
} |