getWordPressProps
getWordPressProps
is a function that should be returned within Next.js’ getStaticProps
or getServerSideProps
to properly setup the Faust Template Hierarchy system.
Usage
To properly configure getWordPressProps
, create pages/[...wordpressNode].js
with the following content:
// In pages/[...wordpressNode].js
import { getWordPressProps, WordPressTemplate } from '@faustwp/core';
export default function Page(props) {
return <WordPressTemplate {...props} />;
}
export function getStaticProps(ctx) {
return getWordPressProps({ ctx });
}
export async function getStaticPaths() {
return {
paths: [],
fallback: 'blocking',
};
}
Code language: JavaScript (javascript)
NOTE
This above example uses getStaticProps
, but you can also use getServerSideProps
as they are both supported.
Configuration
Below is the getWordPressProps
config object defined as a TypeScript type:
type GetWordPressPropsConfig<Props = Record<string, unknown>> = {
/**
* The Next.js getServerSideProps or getStaticProps context. This is required.
*/
ctx: GetServerSidePropsContext | GetStaticPropsContext;
/**
* Any props you would like returned to the Faust templates
*/
props?: Props;
/**
* The Next.js revalidate value. By default, Faust sets a smart default of 900 seconds (15 minutes)
*/
revalidate?: number | boolean;
};
Code language: PHP (php)