Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

fix: unpublish preview for Multi-language #150

Merged
merged 11 commits into from
Apr 27, 2020

Conversation

Duaner
Copy link
Contributor

@Duaner Duaner commented Mar 2, 2020

Problem
When building the preview page for a specific Custom type, a lang is set statically in the context and not properly replaced by the one passed through the URL Path or QueryString.

Fixes #86

Description

We now use only queryString for unpublished documents since we had conflict in the router. In development, if you were using the DefaultLang option and tried to preview an unpublish doc, the 404 was always showing. We bypassed that by using queryString for all unpublished docs. If the doc is already published we redirect to a pretty URL.

Added a new utils to get QueryString as JSON

Bug fixes

  • fix previews in multi-lang project

Breaking changes

  • path is no longer used in gatsby-config.js; you should use match to define your pages path ; and you can use previewPath if you want to change the default route for unpublished document preview page

I also updated to the newest toolbar that should Fix #126

@MadsMadsDk
Copy link

Looking forward to this one getting merged.

@Duaner
Copy link
Contributor Author

Duaner commented Mar 16, 2020

I just realized that there is still a problem there. When you use default lang, the URL for the preview page is properly set but doesn't load properly the preview component but the 404 page.

I will see what i can do for this next week.

@MadsMadsDk
Copy link

@Duaner Did you make any progress on this? :)

@jdwillemse
Copy link
Contributor

@veloce a Prettier check fails on your last commit

@ruslansavenok
Copy link

For anyone who needs a fix before this gets merged, just hardcode urls for each langauge in pages: [] instead of using :lang?:

{
  type: 'Blog_post',
  match: '/it/blog/:uid',
  path: '/it/blog-preview',
  component: require.resolve('./src/templates/blog_post.js'),
  langs: ['it-it'],
},
{
  type: 'Blog_post',
  match: '/blog/:uid',
  path: '/blog-preview',
  component: require.resolve('./src/templates/blog_post.js'),
  langs: ['en-us'],
},

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants