Hey @cobra,
The problem you are finding is that once you are not using categoryBase
at all, the url of your categories are matching the pattern "/(.*)?/:slug"
, which is assigned to the postType
handler.
You could try to create a new handler, at the index.js
of your theme, with the same pattern but a higher priority where you try the function of the category handler and if it returns an error try the postType. This means it will make a REST API call to check if that slug
exists as a category and if not, make the REST API calls for postType. It should be something similar to this:
import Theme from "./components";
import image from "@frontity/html2react/processors/image";
const newHandler = {
name: "categoryOrPostType",
priority: 19,
pattern: "/(.*)?/:slug",
func: async ({ route, params, state, libraries }) => {
// 1. try with category.
try {
const category = libraries.source.handlers.find(
handler => handler.name == "category"
);
await category.func({ route, params, state, libraries });
} catch (e) {
// It's not a category
const postType = libraries.source.handlers.find(
handler => handler.name == "post type"
);
await postType.func({ route, params, state, libraries });
}
}
};
const marsTheme = {
name: "@frontity/mars-theme",
roots: { ... },
state: { ... },
actions: { ... },
libraries: {
source: {
handlers: [newHandler]
},
...
}
};
export default marsTheme;
Please, let us know if you finally make it work or if there’s anything else where we can help.