Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way of Generating/Using a custom index page? #43

Closed
jodiedoubleday opened this issue Aug 14, 2020 · 5 comments
Closed

Is there a way of Generating/Using a custom index page? #43

jodiedoubleday opened this issue Aug 14, 2020 · 5 comments

Comments

@jodiedoubleday
Copy link

I have 1 custom type in Prismic I want to use for all page types.

If I set the UID in Prismic to be index, localhost:9000/index works fine but localhost:9000/ (I actually get a flash of the page I want, then a white screen).

I've tried

{
  type: 'Page',
  match: '/',
  previewPath: '/:uid/',
  filter: data => data.node._meta.uid.includes('index'),
  component: require.resolve('./src/templates/page.jsx'),
}

which doesn't work. Has anyone got any suggestions on how to get this?

@struckm
Copy link

struckm commented Aug 14, 2020

Can you provide your linkResolver code.

@mrseanbaines
Copy link

I don't think you can use variables like :uid in the previewPath property. Maybe try this?

{
  type: 'Page',
  match: '/:uid/',
  filter: data => data.node._meta.uid.includes('index'),
  component: require.resolve('./src/templates/page.jsx'),
}

@jodiedoubleday
Copy link
Author

jodiedoubleday commented Aug 15, 2020

@struckm

exports.linkResolver = function linkResolver(doc) {
  if (doc.type === 'blogpost') return '/blog/' + doc.uid;
  if (doc.uid === 'index') return '/';
  return '/' + doc.uid;
}

@jodiedoubleday
Copy link
Author

@mrseanbaines
I've removed the preview path but I think have the same issue.
I have a Prismic type Page with UID of Index, which just results in a white screen on the root '/' but /index/ works fine.
I need this Prismic generated page to replace pages/index.js

@jodiedoubleday
Copy link
Author

I think I have found the issue, generally using, I was using previewPath in a different part of the plugin which was set to '/' which was causing duplicate routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants