astrolicious / astro-theme-provider

Author themes for Astro like a normal project and export your work as an integration for others to use
https://astro-theme-provider.netlify.app/
The Unlicense
22 stars 3 forks source link

Add support for actions API #121

Open BryceRussell opened 1 month ago

BryceRussell commented 1 month ago

Add support for the new experimental actions API from Astro

Things to consider:

BryceRussell commented 1 month ago

Blocked until support for injecting actions is added: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md#integration-actions

Current recommendation is to export an action from the theme package for users to configure themselves

// package/actions.ts
import { defineAction, z } from 'astro:actions';

export const someActions = () => {
    like: defineAction({
        // ...
    })
}
// project/src/actions/index.ts
import { defineAction, z } from 'astro:actions';
import { someActions } from 'my-theme/actions';

export const server = {
  ...someActions()
};