Enhancement: Allow specifying the index file name #398

Closed
opened 2026-10-05 02:44:56 +02:00 by adam · 2 comments
Owner

In SvelteKit each page is defined by a +page.svelte file. E.g.:
src/routes/blog/[slug]/+page.svelte or src/routes/blog/[slug]/+page[.md / .mdx / .svx] since we're using MDsveX.

When creating content with the FrontMatter extension the default file is named index.md. This requires the SvelteKit end user having to rename the file to +page.md so that SvelteKit can direct the route to the specified markdown file.


Assuming we have the following set on fronmatter.json

{
"frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": true,
      "fileType": "svx",
      …
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "blog",
      "path": "[[workspace]]/src/routes/blog",
      "filePrefix": ""
    }
  ]
}

One idea could be to be able to associate a default file name string (which defaults to index) for each content type. Like so:

"frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": true,
      "fileType": "svx",
      "defaultFileName": "+page",      <---
      …
    }
  ]

Another idea could be to associate the default file name with a specific folder:

  "frontMatter.content.pageFolders": [
    {
      "title": "blog",
      "path": "[[workspace]]/src/routes/blog",
      "filePrefix": "",
      "defaultFileName": "+page"      <---
    }
  ]
}
In SvelteKit each page is defined by a `+page.svelte` file. E.g.: `src/routes/blog/[slug]/+page.svelte` or `src/routes/blog/[slug]/+page[.md / .mdx / .svx]` since we're using MDsveX. When creating content with the FrontMatter extension the default file is named `index.md`. This requires the SvelteKit end user having to rename the file to `+page.md` so that SvelteKit can direct the route to the specified markdown file. --- Assuming we have the following set on `fronmatter.json` ```json { "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": true, "fileType": "svx", … } ], "frontMatter.content.pageFolders": [ { "title": "blog", "path": "[[workspace]]/src/routes/blog", "filePrefix": "" } ] } ``` One idea could be to be able to associate a default file name string (which defaults to index) for each content type. Like so: ```json "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": true, "fileType": "svx", "defaultFileName": "+page", <--- … } ] ``` Another idea could be to associate the default file name with a specific folder: ```json "frontMatter.content.pageFolders": [ { "title": "blog", "path": "[[workspace]]/src/routes/blog", "filePrefix": "", "defaultFileName": "+page" <--- } ] } ``` <!-- github-sync-id:1571558977 -->
adam closed this issue 2026-10-05 02:44:57 +02:00
Author
Owner

Thank you @furkanb, makes a lot of sense to add this support.

Question: should the defaultFileName property you propose, include the file extension?

Thank you @furkanb, makes a lot of sense to add this support. Question: should the `defaultFileName` property you propose, include the file extension? <!-- github-comment-id:1418244063 -->
Author
Owner

@estruyf If the default file name will be defined within the content type (frontMatter.taxonomy.contentTypes) I think it would be redundant to include the file extension since there's already a fileType property. So I would suggest defining the default file name property within the content type, this way the user could have the option to change either the file name or the file type.

@estruyf If the default file name will be defined within the content type (`frontMatter.taxonomy.contentTypes`) I think it would be redundant to include the file extension since there's already a `fileType` property. So I would suggest defining the default file name property within the content type, this way the user could have the option to change either the file name or the file type. <!-- github-comment-id:1418248596 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#398