Skip to content

Commit

Permalink
adjust title for dapps category pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed May 27, 2024
1 parent 2e01b4d commit 88ec522
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/metadata/templates/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TEMPLATE_MAP: Record<Route['pathname'], string> = {
'/tokens': 'Tokens list - %network_name% explorer',
'/token/[hash]': '%network_name% token details',
'/token/[hash]/instance/[id]': '%network_name% NFT instance',
'/apps': '%network_name% DApps - Explore top apps',
'/apps': '%network_name% %seo_category% - %seo_details%',
'/apps/[id]': '%network_name% marketplace app',
'/stats': '%network_name% stats - %network_name% network insights',
'/api-docs': '%network_name% API docs - %network_name% developer tools',
Expand Down
1 change: 1 addition & 0 deletions lib/metadata/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type ApiData<Pathname extends Route['pathname']> =
Pathname extends '/token/[hash]' ? TokenInfo :
Pathname extends '/token/[hash]/instance/[id]' ? { symbol: string } :
Pathname extends '/apps/[id]' ? { app_name: string } :
Pathname extends '/apps' ? { seo_category: string; seo_details: string } :
never
) | null;

Expand Down
26 changes: 22 additions & 4 deletions pages/apps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import type { NextPage } from 'next';
import type { GetServerSideProps } from 'next';
import dynamic from 'next/dynamic';
import React from 'react';

import type { NextPageWithLayout } from 'nextjs/types';

import type { Route } from 'nextjs-routes';
import * as gSSP from 'nextjs/getServerSideProps';
import type { Props } from 'nextjs/getServerSideProps';
import PageNextJs from 'nextjs/PageNextJs';

const Marketplace = dynamic(() => import('ui/pages/Marketplace'), { ssr: false });

const Page: NextPage = () => (
<PageNextJs pathname="/apps">
const pathname: Route['pathname'] = '/apps';

const Page: NextPageWithLayout<Props<typeof pathname>> = (props: Props<typeof pathname>) => (
<PageNextJs pathname={ pathname } query={ props.query } apiData={ props.apiData }>
<Marketplace/>
</PageNextJs>
);

export default Page;

export { marketplace as getServerSideProps } from 'nextjs/getServerSideProps';
export const getServerSideProps: GetServerSideProps<Props<typeof pathname>> = async(ctx) => {
const baseResponse = await gSSP.marketplace<typeof pathname>(ctx);

if ('props' in baseResponse) {
(await baseResponse.props).apiData = {
seo_category: typeof ctx.query.category === 'string' ? ctx.query.category : 'DApps',
seo_details: ctx.query.category ? 'Decentralized trading apps' : 'Explore top apps',
};
}

return baseResponse;
};

0 comments on commit 88ec522

Please sign in to comment.