After Some changes to the code, I have added pattern for homepage as “/home/” and in frontity.settings.js set the homepage to “/home/”. Now the problem is i cant access homepage at / but it works fine at /home and the blog is also fetching normally.
I believe, Non-Wordpress pages when set to homepage doesn’t work.
What the homepage setting does is to handle the homepage ("/") as if it were the route of the WP page you set as value.
For example, if you set homepage value to be "/dashboard/", then if you access "/" you will see the “dashboard” page. But it only works with WordPress pages, i.e. you need to have a page created in your WordPress site with that link.
For your case, as your homepage doesn’t exist in your WP site I would remove the homepage setting and use only the custom handler with the pattern equals to "/".
Try doing that, and let me know if it works for you!
Sorry, you were doing it right! You need to set homepage as /home/ and then create a handler with /home/ as pattern. If not, you are overwriting the handler that is responsible for requesting the post archive.
I think the problem you had before was the handler should be added to libraries.source.handler during the init action (triggered by Frontity), and not during beforeSSR or beforeCSR action, so in your index.js you need to do something like
const init = ({ libraries }) => {
// Define the home handler
const homeHandler = {
name: "Home",
pattern: "/home/",
func: ({ state }) => {
state.source.data["/"].isHome = true;
}
};
// Add the home handler to the array of handlers
libraries.source.handlers.push(homeHandler);
};
@David Thanks, seems like things are partly fixed with the above config but now the contents of my Custom homepage are coming along with the posts in Blog page.
Oops, It seems like a bug. The post archive handler is setting isHome property to true even though the post archive page is not the homepage. See postArchive.ts.
That might be causing that when you access /blog/ both the post archive and the homepage are rendered.
I’ve opened an issue in GitHub. It’s easy to fix, I’ll let you know when it’s resolved.