For 1st question:
You do not get the document type on hitting url, rather you can use the type in the respective _uid.vue. For example in "_subpageparent/_uid.vue"
, you already know that the possible type would be of "subpage" for wildcard value in "_subpageparent"
, so you have id and type both values in "_subpageparent/_uid.vue"
.
Here is how you can get the param-id of "_subpageparent"
in "
"/_subpageparent" /_uid.vue"
:
You get the id mapped with folder name like , on hitting URL "/subpageparent1/uid1"
, you get all the ids in params map in "_subpageparent/_uid.vue"
, like:
{ subpageparent: 'subpageparent1', uid: 'uid1' }
you can validate the id with request to type by querying the api with different custom types available in $prismic.api.types
map.
For second question, you asked:
- Define content with UID like
"mysite1--contact-us"
and"mysite2--contact-us"
in prismic. - Define router in nuxt for
"/:site/:uid"
or"/:site/contact-us"
(if you want to fix the uid). - Define hierarchy like
"/_site/_uid/_uid.vue"
, in"_uid.vue"
, you can get all params related to the route. for example: if the url is"/mysite1/contact-us"
, then in params in"_uid.vue"
file, you will have params map like:
{ site: 'mysite1', uid: 'contact-us' }
You can acess those values and make some string operations to get the desired uid pattern like applying "--"
between both params values and it will be "mysite1--contact-us"
, let's call it as concatenated_uid
4. Query the api "$prismic.api.getByUID( document.type, concatenated_uid )"
and check the response.
I hope this answers your question and let me know if you have any doubt.