Options
All
  • Public
  • Public/Protected
  • All
Menu

next-static-pages

Index

References

nsp

Renames and exports default

Type aliases

GrayMatterResult

GrayMatterResult<T>: Omit<GrayMatterFile<string>, "data"> & { data: T }

Gray matter parsed result.

Type parameters

  • T = Record<string, any>

Mode

Mode: "render" | "resolved"

NSPComponent

NSPComponent<P>: FC<P>

Next Static Pages functional component.

Type parameters

StaticProps

StaticProps<M>: M extends "render" ? IRenderedProps : IResolvedProps

Type alias determining return type based on user defined Mode.

Type parameters

Functions

default

  • default<M>(initOptions?: IOptions<M>): { getStaticPaths: <P>(props: GetStaticPathsContext) => Promise<GetStaticPathsResult<P>>; getStaticProps: <P, Q>(props: GetStaticPropsContext<Q>) => Promise<GetStaticPropsResult<P>> }
  • Creates simple Api for use with NextJS async static methods.

    example
    import { FC } from 'react';
    import nsp, { IRenderedProps } from 'next-static-pages';
    const {getStaticPaths, getStaticProps} = nsp();
    
    const MyComponent: FC<IRenderedProps> = ({ content }) => {
     return <div dangerouslySetInnerHTML={{ __html: content }} />;
    };
    
    export { getStaticPaths, getStaticProps };
    export default MyComponent;
    

    Type parameters

    Parameters

    • initOptions: IOptions<M> = ...

      initialization options.

    Returns { getStaticPaths: <P>(props: GetStaticPathsContext) => Promise<GetStaticPathsResult<P>>; getStaticProps: <P, Q>(props: GetStaticPropsContext<Q>) => Promise<GetStaticPropsResult<P>> }

    Api for use with async static methods in NextJS

    • getStaticPaths: <P>(props: GetStaticPathsContext) => Promise<GetStaticPathsResult<P>>
        • <P>(props: GetStaticPathsContext): Promise<GetStaticPathsResult<P>>
        • Loads static paths and returns for use in "getStaticProps".

          Type parameters

          • P: ParsedUrlQuery<P> = ParsedUrlQuery

          Parameters

          • props: GetStaticPathsContext

            get static paths properties including locales, default localse.

          Returns Promise<GetStaticPathsResult<P>>

          Static paths array with slug param.

    • getStaticProps: <P, Q>(props: GetStaticPropsContext<Q>) => Promise<GetStaticPropsResult<P>>
        • <P, Q>(props: GetStaticPropsContext<Q>): Promise<GetStaticPropsResult<P>>
        • Consumes static paths params, renders metadata and content returning as props to be passed to Component.

          Type parameters

          Parameters

          • props: GetStaticPropsContext<Q>

            static props including route params by slug key.

          Returns Promise<GetStaticPropsResult<P>>

          Static props to be passed to your component.

Generated using TypeDoc