-
Notifications
You must be signed in to change notification settings - Fork 155
Closed
Description
I followed this very well done tutorial for faust+Nuxt https://wpengine.com/builders/headless-wordpress-post-previews-in-nuxt-3/
But it gives no real clues to setup previews for multiple content types.
After looking at the faustjs docs I saw some hooks that can help you get the typename using Next but none for Nuxt as the doc doesn't seem to exist yet.
Is there a way to retrieve the typename in Nuxt ?
I thought about storing the value we get from the middleware when wordpress redirects us to a path like : http://localhost:3000/?p=225&preview=true&previewPathname=%2F%3Fp%3D225&typeName=Post
But it doesn't seem to work as it appears the middleware is never called when I click on the preview button in wordpress admin
export default defineNuxtRouteMiddleware(async (to, from) => {
if (to.query.preview === 'true') {
const appStore = useAppStore()
const config = useRuntimeConfig();
const previewId = to.query.p;
const typeName = to.query.typeName;
console.log('query middleware : ' , to.query) // never triggers
console.log('typename middleware : ' , typeName) // never triggers
appStore.setPreviewType(typeName)
return navigateTo(`${config.public.wordpressUrl}/generate?redirect_uri=${config.public.frontendSiteUrl}/preview?preview_id=${previewId}`, {external: true})
}
})
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Closed