Last active
August 31, 2020 14:10
-
-
Save imkarmadev/0426594490413248a69f452b9ea303e0 to your computer and use it in GitHub Desktop.
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
{ | |
"Main": { | |
"uid": { | |
"type": "UID", | |
"config": { | |
"label": "Page Name", | |
"placeholder": "Page name to fetch document" | |
} | |
}, | |
"document_title": { | |
"type": "Text", | |
"config": { | |
"label": "document_title", | |
"placeholder": "Redesign :: Index page", | |
"useAsTitle": true | |
} | |
}, | |
"domain": { | |
"type": "Select", | |
"config": { | |
"options": [ | |
"solutions", | |
"perspectives", | |
"campaigns", | |
"press" | |
], | |
"default_value": "solutions", | |
"label": "domain" | |
} | |
}, | |
"subRouteLevel1": { | |
"type": "Text", | |
"config": { | |
"label": "sub route level 1", | |
"placeholder": "sub route level 1" | |
} | |
}, | |
"subRouteLevel2": { | |
"type": "Text", | |
"config": { | |
"label": "sub route level 2", | |
"placeholder": "sub route level 2" | |
} | |
}, | |
"background": { | |
"type": "Image", | |
"config": { | |
"constraint": { | |
"width": 1920 | |
}, | |
"thumbnails": [], | |
"label": "background" | |
} | |
}, | |
"marquee": { | |
"type": "Text", | |
"config": { | |
"label": "marquee", | |
"placeholder": "marquee text" | |
} | |
} | |
} | |
} |
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
export const getDynamicDocument = async <T>( | |
root: string, | |
pid?: string, | |
target?: string | |
): Promise<SearchResponseType<T>> => { | |
const API = await Prismic.getApi(BASE_URL) | |
const predicates = [] | |
predicates.push(Prismic.Predicates.any('my.primarytest.domain', [root])) | |
if (pid) { | |
predicates.push(Prismic.Predicates.at('my.primarytest.subRouteLevel1', pid)) | |
} | |
if (target) { | |
predicates.push(Prismic.Predicates.at('my.primarytest.subRouteLevel2', target)) | |
} else { | |
predicates.push(Prismic.Predicates.missing('my.primarytest.subRouteLevel2')) | |
} | |
return await API.query(predicates, { pageSize: 100 }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment