Dynamic Pages JS API

Dynamic Pages allow you to generate multiple pages from internal or external content collections, dramatically speeding up the process of creating and updating multiple pages at once.

We provide a simple JS API to retrieve Dynamic Page information

📘

Works with Native Store

This JS API can also be used to query store pages

Usage

You'll want to make sure that when running the javascript, the page is dynamic. Within Duda, it's easy to install code or a widget on a page that is not dynamic, so make sure first that it is. In the example below we check for the current page being a dynamic page and then fetch the data after confirming.

try {
  let collectionRowData;
  // get dynamic page API
  const dynPage = dmAPI.dynamicPageApi();

  // check if it's a dynamic page
  if(dynPage.isDynamicPage()) {
    //get the data
    collectionRowData = await dynPage.pageData();
  } else {
		//not dynamic page
  }
} catch(e) {
 	console.error(`Error getting dynamic page  api ${e}`) 
}