-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into DEV-2106-docs-redirect-startup
- Loading branch information
Showing
19 changed files
with
370 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"nextjs-website": major | ||
--- | ||
|
||
Add release note page to product section |
152 changes: 152 additions & 0 deletions
152
apps/nextjs-website/src/app/[productSlug]/[...releaseNoteSubPathSlugs]/page.tsx
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import ProductLayout, { | ||
ProductLayoutProps, | ||
} from '@/components/organisms/ProductLayout/ProductLayout'; | ||
import { Product } from '@/lib/types/product'; | ||
import { SEO } from '@/lib/types/seo'; | ||
import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers'; | ||
import { | ||
convertSeoToStructuredDataArticle, | ||
productToBreadcrumb, | ||
} from '@/helpers/structuredData.helpers'; | ||
import { getGitBookSubPaths, getReleaseNote } from '@/lib/api'; | ||
import { | ||
getCachedUrlReplaceMapProps, | ||
getReleaseNotesProps, | ||
} from '@/lib/cmsApi'; | ||
import { | ||
BreadcrumbItem, | ||
gitBookPageToBreadcrumbs, | ||
productPageToBreadcrumbs, | ||
} from '@/helpers/breadcrumbs.helpers'; | ||
import GitBookTemplate from '@/components/templates/GitBookTemplate/GitBookTemplate'; | ||
import React from 'react'; | ||
import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; | ||
import { Metadata } from 'next'; | ||
import { | ||
makeMetadata, | ||
makeMetadataFromStrapi, | ||
} from '@/helpers/metadata.helpers'; | ||
import { BreadcrumbSegment } from '@/lib/types/path'; | ||
import { baseUrl } from '@/config'; | ||
|
||
type ReleaseNotePageStaticParams = { | ||
productSlug: string; | ||
releaseNoteSubPathSlugs: string[]; | ||
}; | ||
|
||
export async function generateStaticParams() { | ||
return (await getReleaseNotesProps()).map((releaseNoteProps) => { | ||
return { | ||
productSlug: releaseNoteProps.product.slug, | ||
releaseNoteSubPathSlugs: [ | ||
'release-note', | ||
...getGitBookSubPaths(releaseNoteProps.page.path), | ||
], | ||
}; | ||
}); | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: { | ||
params: ReleaseNotePageStaticParams; | ||
}): Promise<Metadata> { | ||
const { | ||
page: { path, title }, | ||
seo, | ||
} = await getReleaseNote( | ||
params?.productSlug, | ||
params?.releaseNoteSubPathSlugs | ||
); | ||
|
||
if (seo) { | ||
return makeMetadataFromStrapi(seo); | ||
} | ||
|
||
return makeMetadata({ | ||
title, | ||
url: path, | ||
}); | ||
} | ||
|
||
export type ReleaseNotePageProps = { | ||
readonly bannerLinks?: BannerLinkProps[]; | ||
readonly dirName: string; | ||
readonly landingFile: string; | ||
readonly path: string; | ||
readonly product: Product; | ||
readonly seo?: SEO; | ||
readonly title: string; | ||
} & ProductLayoutProps; | ||
|
||
const ReleaseNotePage = async ({ | ||
params, | ||
}: { | ||
params: ReleaseNotePageStaticParams; | ||
}) => { | ||
const { bannerLinks, page, path, product, seo, source, title, bodyConfig } = | ||
await getReleaseNote(params.productSlug, params.releaseNoteSubPathSlugs); | ||
|
||
const urlReplaceMap = await getCachedUrlReplaceMapProps(); | ||
|
||
const props = { | ||
...page, | ||
pathPrefix: source.pathPrefix, | ||
bodyConfig: { | ||
...bodyConfig, | ||
isPageIndex: page.isIndex, | ||
pagePath: page.path, | ||
assetsPrefix: source.assetsPrefix, | ||
urlReplaces: urlReplaceMap, | ||
}, | ||
}; | ||
|
||
const breadcrumbs: readonly BreadcrumbSegment[] = gitBookPageToBreadcrumbs( | ||
bodyConfig.pagePath, | ||
bodyConfig.gitBookPagesWithTitle | ||
); | ||
|
||
const breadcrumbsItems: BreadcrumbItem[] = breadcrumbs.map((breadcrumb) => ({ | ||
name: breadcrumb.name, | ||
item: [baseUrl, breadcrumb.path].join(''), | ||
})); | ||
|
||
const structuredData = generateStructuredDataScripts({ | ||
breadcrumbsItems: [ | ||
productToBreadcrumb(product), | ||
{ | ||
name: title, | ||
item: `${baseUrl}/${product.slug}/release-note`, | ||
}, | ||
...breadcrumbsItems, | ||
], | ||
seo: seo, | ||
things: [convertSeoToStructuredDataArticle(seo)], | ||
}); | ||
|
||
return ( | ||
<ProductLayout | ||
product={product} | ||
path={path} | ||
bannerLinks={bannerLinks} | ||
structuredData={structuredData} | ||
> | ||
<GitBookTemplate | ||
menuName={title} | ||
breadcrumbs={[ | ||
...productPageToBreadcrumbs(product, [ | ||
{ | ||
name: title, | ||
path: `/${product.slug}/release-note`, | ||
}, | ||
...breadcrumbs, | ||
]), | ||
]} | ||
hasInPageMenu={false} | ||
{...props} | ||
/> | ||
</ProductLayout> | ||
); | ||
}; | ||
|
||
export default ReleaseNotePage; |
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
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
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
Oops, something went wrong.