-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove server-sitemap.xml and simplify exclude list in next-s…
…itemap config" This reverts commit 359c1b5.
- Loading branch information
1 parent
8825251
commit 6d06771
Showing
3 changed files
with
84 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import { getServerSideSitemap } from 'next-sitemap' | ||
import { GetServerSideProps, GetServerSidePropsContext } from 'next' | ||
import { allDocsFields, allTutorialsFields } from 'lib/sitemap' | ||
|
||
export const getServerSideProps: GetServerSideProps = async ( | ||
ctx: GetServerSidePropsContext | ||
) => { | ||
try { | ||
// returns an array of docs content sitemap fields per slug | ||
const docsFields = await allDocsFields() | ||
// returns an array of tutorials content sitemap fields per slug | ||
const tutorialsFields = await allTutorialsFields() | ||
|
||
return getServerSideSitemap(ctx, [...docsFields, ...tutorialsFields]) | ||
} catch (error) { | ||
throw new Error('Error generating server-sitemap.xml', error) | ||
} | ||
} | ||
|
||
// Default export to prevent next.js errors | ||
export default function Sitemap() { | ||
return null | ||
} |