-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: Slug for root index.md
file generates wrong preview URL
#806
Comments
@theinfinit I included a fix in the latest beta, would you be able to verify it? |
Oh, that's great, thank you. Works like a charm! Paths, both in the root and nested, are correct. In the root it is displayed with a dot Cheers 👋 |
@theinfinit, what do you mean with the root? The |
Yes exactly. Sorry, I wasn't clear enough. The I did more testing on the matter. Case 1Configuration without trailing slash in the "frontMatter.content.pageFolders": [
{
"title": "Root",
"path": "[[workspace]]/src/content/docs/",
"previewPath": "{{pathToken.relPath}}",
"excludeSubdir": true,
"defaultLocale": "en",
},
] Resulting preview paths (everything is working here): $ tree content
src
└── content
└── docs
└── index.md // http://localhost:4321/.
└── test.md // http://localhost:4321/test
└── nested
└── index.md // http://localhost:4321/nested Case 2Configuration with trailing slash in the "frontMatter.content.pageFolders": [
{
"title": "Root",
"path": "[[workspace]]/src/content/docs/",
"previewPath": "{{pathToken.relPath}}/", // <- Added the trailing slash at the end
"excludeSubdir": true,
"defaultLocale": "en",
},
] Resulting preview paths: $ tree content
src
└── content
└── docs
└── index.md // http://localhost:4321/docs -> expected http://localhost:4321/
└── test.md // http://localhost:4321/test -> expected http://localhost:4321/test/
└── nested
└── index.md // http://localhost:4321/nested/nested -> expected http://localhost:4321/nested/ Case 3The behavior without "frontMatter.content.pageFolders": [
{
"title": "Blog",
"path": "[[workspace]]/src/content/docs/blog/",
"previewPath": "/blog",
}
] // Working as expected
$ tree content
src
└── content
└── docs
└── blog
└── index.md // http://localhost:4321/blog
└── my-post.md // http://localhost:4321/blog/my-post And with trailing slash: "frontMatter.content.pageFolders": [
{
"title": "Blog",
"path": "[[workspace]]/src/content/docs/blog/",
"previewPath": "/blog/", // <- Added the trailing slash at the end
}
] $ tree content
src
└── content
└── docs
└── blog
└── index.md // http://localhost:4321/blog/blog -> expected http://localhost:4321/blog/
└── my-post.md // http://localhost:4321/blog/my-post -> expected http://localhost:4321/blog/my-post/ Why I tried to add trailing slash? In one of my Astro projects I have To take that into account, I have added the trailing slash to the Hope it helps 👋 |
@theinfinit, the You can add the Thinking of it, it would be a good option to enhance the settings to have a |
Ah, thank you for explanation. After adding the Mentioning
But I somehow expected that
Yes, that might be good idea. Especially for cases when certain static site generators doesn't support Or, as an alternative idea, something like this might be quite intuitive too: Currently, I found a workaround like this, to define nested "frontMatter.content.i18n": [
{ "title": "English", "locale": "en", "path": "." },
{ "title": "Deutsch", "locale": "de", "path": "de" },
{ "title": "Español", "locale": "es", "path": "es" },
],
"frontMatter.content.pageFolders": [
{
"title": "Root",
"path": "[[workspace]]/src/content/docs/",
"previewPath": "{{pathToken.relPath}}/",
"excludeSubdir": true,
"defaultLocale": "en",
},
{
"title": "Blog",
"path": "[[workspace]]/src/content/docs/blog/",
"previewPath": "/blog/",
"defaultLocale": "en",
"locales": [
{ "title": "English", "locale": "en" },
{ "title": "Deutsch", "locale": "de", "path": "../../de/blog/guides/" },
{ "title": "Español", "locale": "es", "path": "../../es/blog/guides/" },
]
},
], Or maybe, I'm doing it wrong? I haven't found case like this in the documentation. |
Good feedback.
The preview path and the slug are intentionally separated, as the slug can depend on other properties and can be defined with the
|
Ah, I see. Then, all I can ask for is the improvement of the "Site Preview" documentation. Pointing to the slug related configuration for the "trailing slash" case, and the "Slug" guide in general, should avoid the confusion.
That's fantastic! I'm happy to hear that 😆 |
I've been testing it a bit more, and adding the In the upcoming beta, you can use the following: Globally"frontMatter.preview.trailingSlash": true Page folder level"frontMatter.content.pageFolders": [
{
"title": "Root",
"path": "[[workspace]]/src/content/docs/blog",
"previewPath": "/blog",
"trailingSlash": true
}
] Content type level"frontMatter.taxonomy.contentTypes": [
{
"name": "simple",
"pageBundle": false,
"previewPath": null,
"trailingSlash": true,
"fields": []
}
] To document
|
I just tested the latest beta For the record,
"frontMatter.content.pageFolders": [
{
"title": "Root",
"path": "[[workspace]]/src/content/docs/",
"previewPath": "{{pathToken.relPath}}/",
"trailingSlash": true
},
], For me, the issue is resolved. Thank you! |
Hi Elio,
looks like the issue is still there. I have installed latest Front Matter CMS
v10.1.0
.If I can help out with some additional context, feel free to ask.
Have a nice day 👋
Originally posted by @theinfinit in #603 (comment)
The text was updated successfully, but these errors were encountered: