feat(collection): "server only"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 746
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 3
Description
It would be nice with "server only" collections, this would expand the usage area of nuxt content from data that will be public, to having a super basic lookup for things that would be considered "sensitive" outside the environment it is running in / db context.
Describe the solution you'd like
e.g: a way to simply include or exclude (include by default maybe?) in either client or server environment.
export default defineContentConfig({
collections: defineCollection({
server: boolean,
client: boolean
})
})
Describe alternatives you've considered
An alternative could be a nuxt hook to filter collections nuxt:content:[client|server]: (collections[]) => collections[]
A simple example use-case would be for a simple site where you define some forms with a contact person with yml/md content, but you do not want to include the email field in the public bundle, so you end up coding in variable replacement for some fields in the content/ folder.
This would allow you to have a "persons" or whatever collection that is secret, and you can simply reference that path in your form instead.
Would be happy to be pointed in the direction to how this could be achieved without the change in nuxt-content too, but as of now it would require either the config or hook option afaik.
What would be some considerations to come up with a solution for this to work properly without breaking support?
Would it be as simple as not bundling sqldump + not typing the collection in certain exports?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to defineContentConfig/defineCollection in the TypeScript configuration and proposes a nuxt:content:[client|server] hook; begin by tracing how collections are exposed in client and server contexts. Done means a decided inclusion or exclusion behavior that keeps server-only collection data out of the public bundle without breaking collection exports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs, typescript
- Domain
- backend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100