-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#26: CTY-specific view, using base:folder as demonstration
- Loading branch information
Showing
12 changed files
with
99 additions
and
49 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
16 changes: 7 additions & 9 deletions
16
hmdb/src/main/resources/lib/headless/contentapi/contentmeta.es6
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
const { branchInvalidError400, idOrPathInvalidError400 } = require("./errors"); | ||
const { executeResult } = require("./execute"); | ||
const {branchInvalidError400, idOrPathInvalidError400} = require("./errors"); | ||
const {executeResult} = require("./execute"); | ||
|
||
const { META_QUERY } = require('../guillotine/queries/_meta'); | ||
const {META_QUERY} = require('../guillotine/queries/_meta'); | ||
|
||
// siteId (manatory): the valid UUID for the root site | ||
// branch (manatory): branch to fetch from, master or draft | ||
// idOrPath (mandatory if no override query is used): used in the _meta query. Can be a valid content UUID, or a (full) content path, eg. /mysite/persons/someone. | ||
exports.getContentMeta = (siteId, branch, idOrPath) => { | ||
|
||
return branchInvalidError400(branch) || | ||
idOrPathInvalidError400(idOrPath) || | ||
executeResult(siteId, branch, META_QUERY, { idOrPath }); | ||
}; | ||
exports.getContentMeta = (siteId, branch, idOrPath) => | ||
branchInvalidError400(branch) || | ||
idOrPathInvalidError400(idOrPath) || | ||
executeResult(siteId, branch, META_QUERY, {idOrPath}); |
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,11 @@ | ||
import DefaultPage from "./templates/default"; | ||
|
||
import FolderPage from "./templates/folder"; | ||
|
||
// Content types mapped to full guillotine query strings. | ||
// If type is not found here, falls back to the default template in templates/item.tsx | ||
const contentTypeSpecificTemplate = { | ||
'base:folder': FolderPage | ||
}; | ||
|
||
export const getTemplate = (contentType) => contentTypeSpecificTemplate[contentType] || DefaultPage; |
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,17 @@ | ||
import React from "react" | ||
|
||
type Props = { | ||
displayName: string, | ||
} | ||
|
||
const DefaultPage = (props: Props) => { | ||
return ( | ||
<> | ||
<p>Item:</p> | ||
<h2>{props.displayName}</h2> | ||
<pre>{JSON.stringify(props, null, 2)}</pre> | ||
</> | ||
) | ||
} | ||
|
||
export default DefaultPage; |
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,32 @@ | ||
import React from "react" | ||
import Link from "next/link"; | ||
|
||
type ChildContent = { | ||
displayName: string, | ||
_path: string, | ||
_id: string | ||
}; | ||
|
||
type Props = { | ||
displayName: string, | ||
children: ChildContent[], | ||
}; | ||
|
||
const FolderPage = ( props: Props) => { | ||
return ( | ||
<> | ||
<p>Folder:</p> | ||
<h2>{props.displayName}</h2> | ||
<ul> | ||
{props.children.map(child => ( | ||
<li key={child._id}> | ||
<Link href={child._path.substring(1)}><a>{child.displayName}</a></Link> | ||
</li>) | ||
)} | ||
</ul> | ||
<pre>{JSON.stringify(props, null, 2)}</pre> | ||
</> | ||
) | ||
}; | ||
|
||
export default FolderPage |
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
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