-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add endpoint to retrieve details of all pages in collection This commit adds a new endpoint, GET /sites/:siteName/collections/:collectionName/pages, which retrieves the page details (including what type of page it is, third nav or not) of all pages in a collection. This is primarily helpful for retrieving information about third nav sections in any given collection. * feat: add util functions for route functions This commit adds a route-utils.js file, which contains useful util functions for common CMS operations, such as reading from a collection page, or simple page, or creating a file in the _data folder. * fix: import required dependencies Co-authored-by: Jie Hao Kwa <[email protected]>
- Loading branch information
Showing
3 changed files
with
111 additions
and
0 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,37 @@ | ||
// Import classes | ||
const { | ||
File, | ||
PageType, | ||
CollectionPageType, | ||
DataType, | ||
} = require('../classes/File') | ||
|
||
const readPageUtilFunc = async (accessToken, siteName, pageName) => { | ||
const IsomerFile = new File(accessToken, siteName) | ||
const pageType = new PageType() | ||
IsomerFile.setFileType(pageType) | ||
const fileContents = await IsomerFile.read(pageName) | ||
return fileContents | ||
} | ||
|
||
const readCollectionPageUtilFunc = async (accessToken, siteName, collectionName, pageName) => { | ||
const IsomerFile = new File(accessToken, siteName) | ||
const collectionPageType = new CollectionPageType(collectionName) | ||
IsomerFile.setFileType(collectionPageType) | ||
const fileContents = await IsomerFile.read(pageName) | ||
return fileContents | ||
} | ||
|
||
const createDataFileUtilFunc = async (accessToken, siteName, filePath, content) => { | ||
const IsomerFile = new File(accessToken, siteName) | ||
const dataType = new DataType() | ||
IsomerFile.setFileType(dataType) | ||
await IsomerFile.create(filePath, content) | ||
return | ||
} | ||
|
||
module.exports = { | ||
readPageUtilFunc, | ||
readCollectionPageUtilFunc, | ||
createDataFileUtilFunc, | ||
} |