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
I've been trying to setup a Footnote custom mark component, as written here. There's a sample repo using Next, but I had an issue getting the same result for Astro.
Basic idea is adding a custom component with tailwind classes:
Thought about this a bit more, found a workaround that could work without changes to Keystatic:
By adding Astro middleware for keystatics routes, we can prepend the styles to the Astro island with Keystatic UI, by importing tailwind css content and injecting it into Astro styles. There might be a better way, but this works!
It's especially helpful for custom content components:
// keystatic.config.tsx
...
content: fields.markdoc({label: "Body",components: {Badge: inline({label: "Footnote",schema: {foo: fields.number({label: "My Foo"}),},NodeView: ({ value })=>(<Badgevariant="secondary">Foo: #{value.foo}</Badge>
),})
Attaching the middleware code:
?url in style path is needed for vite to build for production, otherwise it produces src/middleware.ts (2:7): "default" is not exported by "src/styles/globals.css", imported by "src/middleware.ts".
Hi!
I've been trying to setup a Footnote custom
mark
component, as written here. There's a sample repo using Next, but I had an issue getting the same result for Astro.Basic idea is adding a custom component with tailwind classes:
But when the text is marked in UI, styles aren't applied, because Keystatic Astro component has no idea about the styles file.
How I think this can be fixed
(some steps can be automated by keystatic integration, others might need user input)
"keystatic.config.tsx"
to tailwind content config, so the custom component styles are picked up into global cssAs a result, tailwind CSS styles are loaded and applied to custom components in the editor UI.
If this approach makes sense — I'll gladly open a PR. Thanks!
The text was updated successfully, but these errors were encountered: