mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* add canonical link tag * change title templates * adjust title for dapps category pages * change h1 titles * Revert "adjust title for dapps category pages" This reverts commit 88ec5228ff839f6559db9bb29922e23334819911. * fix unit test
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import type { ApiData, Metadata } from './types';
|
|
import type { RouteParams } from 'nextjs/types';
|
|
|
|
import type { Route } from 'nextjs-routes';
|
|
|
|
import config from 'configs/app';
|
|
import getNetworkTitle from 'lib/networks/getNetworkTitle';
|
|
|
|
import compileValue from './compileValue';
|
|
import getCanonicalUrl from './getCanonicalUrl';
|
|
import getPageOgType from './getPageOgType';
|
|
import * as templates from './templates';
|
|
|
|
export default function generate<Pathname extends Route['pathname']>(route: RouteParams<Pathname>, apiData: ApiData<Pathname> = null): Metadata {
|
|
const params = {
|
|
...route.query,
|
|
...apiData,
|
|
network_name: config.chain.name,
|
|
network_title: getNetworkTitle(),
|
|
};
|
|
|
|
const title = compileValue(templates.title.make(route.pathname, Boolean(apiData)), params);
|
|
const description = compileValue(templates.description.make(route.pathname), params);
|
|
|
|
const pageOgType = getPageOgType(route.pathname);
|
|
|
|
return {
|
|
title: title,
|
|
description,
|
|
opengraph: {
|
|
title: title,
|
|
description: pageOgType !== 'Regular page' ? config.meta.og.description : '',
|
|
imageUrl: pageOgType !== 'Regular page' ? config.meta.og.imageUrl : '',
|
|
},
|
|
canonical: getCanonicalUrl(route.pathname),
|
|
};
|
|
}
|