Basically, I want to have /page/
be my /
route home page for a site without also setting it at all in the WordPress back end.
The reason being, I want to use a multisite Frontity project to create multiple Frontity themes on different subdomains, each taking content from a custom post type, e.g.:
const settings = [
{
"name": "microsite-1",
"match": ['https://microsite-1.domain.com'],
"state": {
"frontity": {
"url": 'https://microsite-1.domain.com',
...
}
},
"packages": [
...,
{
"name": "@frontity/wp-source",
"state": {
"source": {
api: "http://wpadmin.domain.com/wp-json",
homepage: "/microsite/microsite-1/",
postTypes: [
{
type: "microsite",
endpoint: "microsite",
archive: '/microsites'
}
]
}
}
},
...
]
}, {
"name": "microsite-2",
"match": ['https://microsite-2.domain.com'],
"state": {
"frontity": {
"url": 'https://microsite-2.domain.com',
...
}
},
"packages": [
...,
{
"name": "@frontity/wp-source",
"state": {
"source": {
api: "http://wpadmin.domain.com/wp-json",
homepage: "/microsite/microsite-2/",
postTypes: [
{
type: "microsite",
endpoint: "microsite",
archive: '/microsites'
}
]
}
}
},
...
]
} // etc.
]
export default settings;
The problem is, when I set it like that, I get the following error:
ServerError: You have tried to access content at route: / but it does not exist
at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:38:146)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at eval (webpack-internal:///./node_modules/@frontity/wp-source/src/actions.ts:25:1) {
status: 404,
statusText: 'You have tried to access content at route: / but it does not exist'
}
TypeError: Cannot read property 'undefined' of undefined
at Root (webpack-internal:///./packages/microsites-theme/src/components/index.js:7:105)
at runAsReaction (webpack-internal:///./node_modules/@frontity/connect/src/reactionRunner.js:16:45)
at reaction (webpack-internal:///./node_modules/@frontity/connect/src/observer.js:7:131)
at eval (webpack-internal:///./node_modules/@frontity/connect/src/connect.js:21:16)
at processChild (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:397:2319)
at resolve (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:396:122)
at ReactDOMServerRenderer.render (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:433:1199)
at ReactDOMServerRenderer.read (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:433:55)
at renderToString (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:470:116)
at eval (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:68:243)
When I set the WordPress backend “home page” to any page and go to the “/” route, I get that page, and if I navigate to the microsite’s permalink e.g., “/microsites/microsite-1/”, I get that custom post type.
What I want is to be able to set the homepage
property for each site in frontity.settings.js
to a custom post type and when I navigate to https://localhost:3000/?frontity_name=microsite-1
, I’ll get the custom post returned.
Should I just set homepage
to /
and then set the custom post’s ID in the state to pass it to the component? What would be the most logical way to do this? Thanks!