You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe
Note
This feature request for v3
I currently repeat data transformation code in multiple places.
For example, on the home page, I fetch post data and transform it like so:
// Used in: index.vue, all-post.vueconst{data: posts}=awaituseAsyncData('blog',()=>queryCollection('blog').select('id','title','path','description','tags','createdAt','updatedAt').order('createdAt','DESC').limit(2).all(),{transform(data){returndata.map((post)=>({
...post,// some other transformations for tags, and other values etccreatedAt: newDate(post.createdAt).toLocaleDateString(),}))},})
I do the same transformation on the "All posts" page and possibly other pages. This repetition can make it harder to maintain, and have consistent data across the pages where one might use it.
Describe the solution you'd like
I would like to configure data transformations directly in the content.config.ts file, if possible. This would centralize the transformation logic, making future updates in one file only
Describe alternatives you've considered
An alternative is to keep the transformation logic in each place where data is fetched, what I currently do.
Additional context
I saw a reference to a defineContentPlugin, with a transform property in an example file in the docs. However, I couldn't find any implementation of it in the source code.
Does this exist? If yes, I suppose we can perform transformations in there too.
Is your feature request related to a problem? Please describe
Note
This feature request for v3
I currently repeat data transformation code in multiple places.
For example, on the home page, I fetch post data and transform it like so:
I do the same transformation on the "All posts" page and possibly other pages. This repetition can make it harder to maintain, and have consistent data across the pages where one might use it.
Describe the solution you'd like
I would like to configure data transformations directly in the
content.config.ts
file, if possible. This would centralize the transformation logic, making future updates in one file onlyDescribe alternatives you've considered
An alternative is to keep the transformation logic in each place where data is fetched, what I currently do.
Additional context
I saw a reference to a
defineContentPlugin
, with atransform
property in an example file in the docs. However, I couldn't find any implementation of it in the source code.Does this exist? If yes, I suppose we can perform transformations in there too.
Thanks 💚,
cc @larbish
The text was updated successfully, but these errors were encountered: