keystatic icon indicating copy to clipboard operation
keystatic copied to clipboard

Feature: keystaticToAstroCollections

Open florian-lefebvre opened this issue 1 year ago β€’ 6 comments

As mentioned in https://youtu.be/6l2YWCyPsWk, it would be great to have a keystaticToAstroCollection utility exported by @keystatic/astro to translate the Keystatic config to the Astro collections config.

Example usage:

// src/content/config.ts
import keystaticConfig from "../../keystatic.config"
import { keystaticToAstroCollection } from "@keystatic/astro"

const keystaticCollections = keystaticToAstroCollection(keystaticConfig)

export const collections = {
	...keystaticCollections
}

I made some experiments at the type level but collections and singletons specific types are lost once past to the config

florian-lefebvre avatar Jun 16 '23 15:06 florian-lefebvre

πŸ’― yes this

I was looking further into astro content collections (and zod specifically) and actually think we could go both ways:

As an easy way to start with Keystatic, you can introspect the content collection types and (for the most part) convert them into keystatic collections. It would miss some features like field descriptions and labels but it'd be neat for people already using content collections and things like validation rules could mostly come across.

Then, if you're using keystatic schema (or if you migrate from zod types to keystatic to get more UI customisation) it would make sense to go the other way as well, generate content collection types from keystatic. Zod types are useful for validation / etc as well, so I don't think it would actually be limited to astro, although a high level API that exports the content collections definition like you suggest would be very neat.

Adding this to the roadmap πŸ—ΊοΈ

JedWatson avatar Jun 26 '23 07:06 JedWatson

Awesome! Is the roadmap public?

florian-lefebvre avatar Jun 26 '23 08:06 florian-lefebvre

me, on slack, five minutes ago:

... feels like maybe I should write up a readme on all the stuff we've discussed / planned / ideas, but not thought through fully or implemented yet

without wanting to get too much into "making promises that could change as we learn more" I'm really keen to write something up, yeah, especially to get feedback on design / priorities of things etc. before we actually implement them

will either post something to the docs site, or a discussion, soon and let you know 🀞

JedWatson avatar Jun 26 '23 10:06 JedWatson

in the meantime by the way @florian-lefebvre I know we've been a bit slow to reply to the issues you've opened in the last week, but it's great getting feedback and questions, please do keep it coming and we will get through the backlog πŸ™Œ

thanks!

JedWatson avatar Jun 26 '23 10:06 JedWatson

I will keep creating issues as I have feedbacks πŸ‘ Regarding the roadmap, I think you could use a simple GitHub project so that you avoid duplication and allow the community to contribute/discuss

florian-lefebvre avatar Jun 26 '23 11:06 florian-lefebvre

Came across this today -> https://github.com/gxjansen/Astro-CC2KS. Haven't tried it out, but looks promising.

smokeyfro avatar Sep 10 '24 13:09 smokeyfro