22title : Page Provider and CMS Binding
33---
44
5- A page provider is a handler function that returns a [ page] ( page.md ) .
5+ A page provider is a middleware function that returns a [ page] ( page.md ) .
66
77All CMS would be implemented as a page provider.
88
@@ -15,12 +15,15 @@ You can create a provider plugin with a module:
1515 * with as default, a mandatory React Element
1616 * and optionally, a [ frontmatter] ( frontmatter.md ) and a ` toc `
1717
18- ``` javascript
18+ ``` tsx
1919// ./src/cms/my-provider.js
20- export async function handler ( props ) {
21- return async ( request ) => {
20+ import { ContextProps } from " @combostrap/interact/types " ;
21+ import { MiddlewareHandler } from " ./interactMiddleware " ;
2222
23- const pathname = new URL (request .url ).pathname
23+ export async function handler(props ): Promise <MiddlewareHandler > {
24+ return async (context : ContextProps ) => {
25+
26+ const pathname = context .url .pathname
2427
2528 // check if you handle the request
2629 if (! pathname .startsWith (" /my-provider" )) {
@@ -49,7 +52,7 @@ export async function handler(props) {
4952
5053* You can take a look to the ` localPagesMiddleware.tsx ` file, it's a CMS plugin that returns
5154 local [ Markdown file as page] ( md-page.md ) .
52- * The [ remote markdown example] ( https://github.com/combostrap/interact/blob/main/apps/site/cms/remote-markdown.tsx ) page
55+ * The [ remote Markdown example] ( https://github.com/combostrap/interact/blob/main/apps/site/cms/remote-markdown.tsx ) page
5356 provider that returns Markdown page from GitHub.
5457
5558## Registration
0 commit comments