Skip to content
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

V3: Accept kebabCased keys in defineContentConfig() #3099

Open
stijns96 opened this issue Feb 6, 2025 · 1 comment
Open

V3: Accept kebabCased keys in defineContentConfig() #3099

stijns96 opened this issue Feb 6, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@stijns96
Copy link
Contributor

stijns96 commented Feb 6, 2025

I want to add kebabCased keys to my defineContentConfig() to math the route.path value.

Current

import { defineContentConfig, defineCollection } from "@nuxt/content";

export default defineContentConfig({
  collections: {
    gettingStarted: defineCollection({
      type: "page",
      source: "1.guide/1.getting-started/**/*.md",
    }),
  },
});

Expected

import { defineContentConfig, defineCollection } from "@nuxt/content";

export default defineContentConfig({
  collections: {
    "getting-started": defineCollection({
      type: "page",
      source: "1.guide/1.getting-started/**/*.md",
    }),
  },
});

By supporting this, I can make my queryCollection() a bit more flexible by adding a route.path or a part of it.

@stijns96 stijns96 added the enhancement New feature or request label Feb 6, 2025
@stijns96 stijns96 changed the title Accept kebabCased keys in defineContentConfig() V3: Accept kebabCased keys in defineContentConfig() Feb 6, 2025
@farnabaz
Copy link
Member

farnabaz commented Feb 6, 2025

Collection names are used to create tables in the database and types in typescript. - and other non-alphabetic characters are not valid chars in these two situations. If you want to get the collection name from the URL, you can use _ instead of -.

_ is valid in the table name, typescript/javascript variables, and also in URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants