I wanted to create a simple starter (titled Squall) for the many projects I build that interact with Wordpress.
This is also my first attempt at Vite, a really amazing tool that speeds up workflow.
This little starter includes TailwindCSS and its ecosystem (headlessUI, heroicons, typography etc..) along with Vue 3 & Vue Router 4 to create a SPA using headless Wordpress.
npm i
npm run dev
Copy the blank /squall-wp-vite/ theme into your Wordpress themes folder. Be sure to activate the theme in order to start getting data from Wordpress.
The index.php is a blank file, but will redirect to any URL (ideally your static site).
Alternatively, you can use any theme you want, but you'll have to do some
Change the $baseURL in main.js to whatever endpoint you want to pull data from. This uses the provide/inject pattern to pass the baseURL value to Posts.vue and Post.vue.
Install the Advanced Custom Fields plugin and import the acf-import-test-fields.json file. This will create custom fields for Posts, which will be exposed in the API.
ACF 5.11 has a setting toggle within each field group that allows you to "Show in REST API." Once toggled, you can pull the "acf" field and it's attributes.
Note: Passing in the acf_format=standard attribute changes the format from "light" to "standard." This is beneficial if you want the correct output from an image attribute for example.
Big thanks to web2033 for creating the initial foundation of the starter.