-
Notifications
You must be signed in to change notification settings - Fork 50
Multiple content types path configuration not working as expected #113
Comments
Hi, you should use '/projects/:slug' as projects permalink, and '/posts/:slug' as posts permalink to achieve the behavior you want. Basically i changed the behavior a few weeks ago, so you could eventually get '/name-of-post' posts url along with '/projects/name-of-project' projects urls for example, thus removing the automatic prefixing of permalinks when having multiple content types. |
That's what I figured was the problem -- since they both have same permalink, the one that is registered first overrides the other. @raae Nuxtent overrides page paths so even though you nested the pages correctly, it's the permalink that ends up defining the route's behavior... Try putting -- Also, this is why I recommended having automatic prefixing of content routes based on their page paths as the default behavior. I think it's what most people would expect. If you define an index route then you'd expect a root level path, but why would you nest a page, e.g. The question is: should it be expected that a page found under Similarly, should a page under |
So my use case is that I would like to organize the content in different folders and also have them accessible as separate collections through getAll(). But I want both to resolve to But that might not be possible? |
Yes this should be possible with the current implementation. Does putting the permalinks as |
Yes, it works. But the permalink are then /posts/post1 and /projects/project1. Not /post1 and /project1. And the path values feel a little weird, see image. My config is now:
|
I encountered the same issue - I content: [
['writings', {
permalink: ':year/:slug',
page: '/_writings',
generate: [
'get', 'getAll'
]
}],
['projects', {
permalink: 'projects/:slug',
isPost: false,
page: '/_projects',
generate: [
'get', 'getAll'
]
}]
], Note that in pages I directly use |
If you could point me in the right direction (ie. relevant code) I could give it a try. |
Yeah sorry I'm just to busy to look into it this week, but I come here to quickly answer questions :) If you want to give it a go, the relevant code is at : https://github.com/nuxt-community/nuxtent-module/blob/master/lib/content/build.js#L32 If you have questions feel free to also join our dev slack channel and ask them there |
@raae I know this has been open for a while, but I think you might be confusing two things:
So, in the screenshot above, you have a content entry with:
This is actually rather handy, because And if you wonder, *why can't I just get Just keep in mind that to get stuff from the content api, you fetch: For me, this works as expected and is not a bug. Thoughts?
|
I really don't get those multiple content yes working. I probably tried over 3 hours with different configurations. Take this simple single content type configuration: module.exports = {
api: {
baseURL: process.env.NODE_ENV === 'production'
? 'http:/mywebsite.com'
: 'http://localhost:3000',
browserBaseURL: process.env.NODE_ENV === 'production'
? 'http://mywebsite.com'
: 'http://localhost:3000'
},
content: {
page: '/_page',
permalink: ':slug',
isPost: false,
generate: [ // for static build
'get'
],
}
} I have several md files in then Good so far. Now I'm changing this to a content type: module.exports = {
api: {
baseURL: process.env.NODE_ENV === 'production'
? 'http://mywebsite.com'
: 'http://localhost:3000',
browserBaseURL: process.env.NODE_ENV === 'production'
? 'http://mywebsite.com'
: 'http://localhost:3000'
},
content: [
['pages', {
page: '/pages/_page',
permalink: 'pages/:slug',
isPost: false,
generate: [ // for static build
'get'
]
},
]
} Moving the files to the correct paths and try to generate or run, I always run in 404s or other errors. |
You use Try with There's an example using this here but it's from the nuxtdown fork so you won't be able to just copy-paste it. But the permalink stuff should be the same though. |
Not sure what you mean with that. In my understanding, my configuration should match content stored in This would mean. What do I misunderstand? |
It's the subfolders that are a problem. What you describe above works fine if you have all your markdown in 1 folder, but not if you have subfolders. So:
Your permalinks only include the slug, so the 2pages will end up with the same permalinks. You need to add in the 'sectiin' which is essentially the subdir. The example I linked to above linked this. Either that, it it's me who misunderstands your issue 😉 |
I feel like you misunderstand me. I don't have any subfolders in the
If this is something that is fixed in nuxtdown, fine. But from the readme of nuxtdown, it will only be a temporary repository that is eventually going to be merged back to nuxtent. I would rather love to know how this works in nuxtent and find out where the problem is and directly fix it in nuxtent if a fix is needed. |
@renestalder It is a documentation problem and maybe a bug on nuxtent. Nuxtent modifies the route of the component and if configured incorrectly can lead into a really confusing problem. For now a workaround could be providing a fake page route As i'm looking for bugs I'm using the development branch inside my current projects as a submodule with this config nuxt.config.js import nuxtent from './modules/nuxtent/lib/module'
export default {
modules: [
'./modules/nuxtent/lib/module',
],
} |
@cesasol Thanks a lot for your input. I then gonna try the development branch. Already saw that there are fixes not available on the released version but wasn't sure if it is safe to try. Let me know if you need contributors. I really would like to keep this project alive and If I can help instead of developing something from scratch for my Netlify CMS coupled websites I'll do that. |
@cesasol With your submodule solution, doesn't Nuxt complain about |
Yes it does, I'm alredy using nuxt-edge on production and so far so good. But for importing the submodule you have to build it ( As for contributing, there are tree ways in wich you can help, first would be input, as we advance on the development for this module sometimes we wonder beteween solution A and B, those discussions are held on gitter, second would be testing and submitting all issues that you encounter, and for the latest would be documentation, right now I'm starting by documenting and rewriting code in a more legible way (smaller files and documented vars/functions). |
Another thing, where I work we decide to contribute with this project for the same reason as you, not having to develop a cms for static sites from scratch. |
I must have misunderstood something as I cannot get two content types to work together.
I am trying to create both projects and posts with permalinks
:slug
using the configuration below. I would like the projects to use the pageprojects/_slug
and the postsposts\_slug
. However both useposts\_slug
giving me a 404 on /project1 asproject1
does not exist in the posts collection.Any help would be much appriciated.
Full example can be found at https://github.com/raae/nuxtent-test.
The text was updated successfully, but these errors were encountered: