UNPKG

@pinegrow/headless-wordpress

Version:

Pinegrow Headless Wordpress Plugin

174 lines (140 loc) 6.2 kB
<!-- [![@pinegrow/headless-wordpress](https://vuetify.nuxtjs.org/social-card.png)](https://vuetify.nuxtjs.org) --> # Pinegrow Headless Wordpress Plugin [![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![License][license-src]][license-href] [Headless Wordpress](https://developer.wordpress.org/rest-api/) plugin for [Pinegrow](https://pinegrow.com) ⚡️ Pinegrow Headless Wordpress Plugin provides customized visual controls, automatic data fetching from Wordpress REST API and other rich visual features customized for your Wordpress experience. Note: - This plugin is generally used in conjunction with the [Pinegrow Vite Plugin](https://www.npmjs.com/package/@pinegrow/vite-plugin) or with the meta-framework specific Pinegrow modules for Nuxt, Quasar, Iles and Astro. - To use Wordpress in Pinegrow apps, you require an active Wordpress Addon subscription. - [&nbsp;Learn more about Vue Designer](https://vuedesigner.com) ## Features - 🎨&nbsp; Visually live-design your Vite-powered Wordpress apps (Vue, Nuxt, Quasar, Iles, Astro, etc) - ⚙️&nbsp; Smartly integrates into your Vite workflow in dev-mode only - ✨&nbsp; Clean code 😃, No lock-in - You are in control of your projects and development workflow ❤️ ## Quick Setup 1. Install: Add `@pinegrow/headless-wordpress` to your project ```bash # Using npm npm install -D @pinegrow/headless-wordpress # Using pnpm pnpm add -D @pinegrow/headless-wordpress ``` 2. Configure: Add `wordpress` along with an optional `dataPath` as options to `liveDesigner` in your config. ```js //vite.config.[js,ts] export default defineConfig({ plugins: [ liveDesigner({ // For options, refer to https://www.npmjs.com/package/@pinegrow/vite-plugin //... wordpress: { /* PinegrowWordpressModuleOptions (for more details, refer to Options section below) */ /* Please ensure that you update the filenames and paths to accurately match those used in your project. */ // dataPath: false, // Set to false to turn off addition of data fetching composable(s) to the project. To customize the path, set to an absolute or relative path, default is 'data/pg-wordpress/query.ts'. }, }), //... ], //... }) ``` ```js //nuxt.config.ts export default defineNuxtConfig({ modules: [ '@pinegrow/nuxt-module', //... ], pinegrow: { liveDesigner: { // For options, refer to https://www.npmjs.com/package/@pinegrow/vite-plugin //... wordpress: { /* PinegrowWordpressModuleOptions (for more details, refer to Options section below) */ /* Please ensure that you update the filenames and paths to accurately match those used in your project. */ // dataPath: false, // Set to false to turn off addition of data fetching composable(s) to the project. To customize the path, set to an absolute or relative path, default is 'data/pg-wordpress/query.ts'. }, }, }, //... }) ``` ```js //iles.config.ts import type { LiveDesignerOptions } from '@pinegrow/vite-plugin' export default defineConfig({ modules: [ [ '@pinegrow/iles-module', { liveDesigner: { // For options, refer to https://www.npmjs.com/package/@pinegrow/vite-plugin //... wordpress: { /* PinegrowWordpressModuleOptions (for more details, refer to Options section below) */ /* Please ensure that you update the filenames and paths to accurately match those used in your project. */ // dataPath: false, // Set to false to turn off addition of data fetching composable(s) to the project. To customize the path, set to an absolute or relative path, default is 'data/pg-wordpress/query.ts'. }, } as LiveDesignerOptions, }, ], //... ], //... }) ``` ```js //astro.config.[mjs] import { defineConfig } from 'astro/config' import vue from '@astrojs/vue' import Pinegrow from '@pinegrow/astro-module' export default defineConfig({ integrations: [ vue(), Pinegrow({ liveDesigner: { // For options, refer to https://www.npmjs.com/package/@pinegrow/vite-plugin //... wordpress: { /* PinegrowWordpressModuleOptions (for more details, refer to Options section below) */ /* Please ensure that you update the filenames and paths to accurately match those used in your project. */ // dataPath: false, // Set to false to turn off addition of data fetching composable(s) to the project. To customize the path, set to an absolute or relative path, default is 'data/pg-wordpress/query.ts'. }, }, }), //... ], //... }) ``` 3. Now, open your project in your Pinegrow app (currently only Vue Designer). ✨ 4. Data Fetching - Pinegrow Headless Wordpress addon adds data fetching composable(s) at the location specified by the `dataPath` option (default: **data/pg-wordpress/query.ts**). ## Options ```ts interface PinegrowWordpressModuleOptions { /** * Absolute or relative path. * @default 'data/pg-wordpress/query.ts' * Set to false to turn off addition of data fetching composable(s) to the project */ dataPath?: string | boolean } interface PinegrowWordpressModule { /** * Pinegrow Headless Wordpress Plugin Options, added within liveDesigner in vite/nuxt/quasar/iles/astro config files */ wordpress: PinegrowWordpressModuleOptions } ``` ## License [MIT License](./LICENSE) Copyright (c) Pinegrow <!-- Badges --> [npm-version-src]: https://img.shields.io/npm/v/@pinegrow/headless-wordpress/latest.svg?style=flat&colorA=18181B&colorB=28CF8D [npm-version-href]: https://npmjs.com/package/@pinegrow/headless-wordpress [npm-downloads-src]: https://img.shields.io/npm/dm/@pinegrow/headless-wordpress.svg?style=flat&colorA=18181B&colorB=28CF8D [npm-downloads-href]: https://npmjs.com/package/@pinegrow/headless-wordpress [license-src]: https://img.shields.io/npm/l/@pinegrow/headless-wordpress.svg?style=flat&colorA=18181B&colorB=28CF8D [license-href]: https://npmjs.com/package/@pinegrow/headless-wordpress