All Projects → madeleineostoja → Wordprismic

madeleineostoja / Wordprismic

Utility to import existing Wordpress blogs into the Prismic.io content platform

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Wordprismic

Nextjs Wordpress Starter
WebDevStudios Next.js WordPress Starter
Stars: ✭ 104 (+316%)
Mutual labels:  wordpress-api, wordpress
Live Composer Page Builder
Free page builder plugin for WordPress http://livecomposerplugin.com
Stars: ✭ 143 (+472%)
Mutual labels:  wordpress-api, wordpress
Frontpress
⚡️ A full front-end AngularJS template for WordPress Rest API.
Stars: ✭ 109 (+336%)
Mutual labels:  wordpress-api, wordpress
Headless Wp
A demo repo for Headless WordPress
Stars: ✭ 89 (+256%)
Mutual labels:  wordpress-api, wordpress
Wp Api React
This boilerplate will help you use React JS with Wordpress REST API.
Stars: ✭ 255 (+920%)
Mutual labels:  wordpress-api, wordpress
Ember Wordpress
The bridge between Ember.js and Wordpress
Stars: ✭ 94 (+276%)
Mutual labels:  wordpress-api, wordpress
Google Docs Add On
Publish to WordPress from Google Docs
Stars: ✭ 140 (+460%)
Mutual labels:  wordpress-api, wordpress
Restsplain
WordPress REST API documentation generator
Stars: ✭ 126 (+404%)
Mutual labels:  wordpress-api, wordpress
Create React Wptheme
Create modern, React-enabled WordPress themes with a single command.
Stars: ✭ 252 (+908%)
Mutual labels:  wordpress-api, wordpress
Kasia
🎩 A React Redux toolset for the WordPress API
Stars: ✭ 219 (+776%)
Mutual labels:  wordpress-api, wordpress
Better Rest Endpoints
A WordPress plugin that serves up slimmer WP Rest API endpoints.
Stars: ✭ 56 (+124%)
Mutual labels:  wordpress-api, wordpress
Tony
An Elegant WordPress Theme Based on ✌️Vue.js | 基于 Vue.js 的简洁一般强大的 WordPress 单栏博客主题
Stars: ✭ 462 (+1748%)
Mutual labels:  wordpress-api, wordpress
Hybrid
[I don't have time to work on this anymore. Use at your own risk] Build WordPress based PWA, iOS, Android & Windows phones apps in minutes!
Stars: ✭ 1,026 (+4004%)
Mutual labels:  wordpress-api, wordpress
Wordpresssharp
A C# client to to interact with the WordPress XML-RPC API
Stars: ✭ 97 (+288%)
Mutual labels:  wordpress-api, wordpress
Ultimate Fields
The plugin for custom fields in WordPress
Stars: ✭ 39 (+56%)
Mutual labels:  wordpress-api, wordpress
Flutter wordpress
Flutter WordPress API
Stars: ✭ 155 (+520%)
Mutual labels:  wordpress-api, wordpress
Wp Api Angular
Angular (>=2) services for WordPress WP-API(v2) or WP >= 4.7 (natively supports WP-API)
Stars: ✭ 266 (+964%)
Mutual labels:  wordpress-api, wordpress
Intervention
WordPress plugin to configure wp-admin and application state using a single config file.
Stars: ✭ 481 (+1824%)
Mutual labels:  wordpress-api, wordpress
Woocommerce Loadimpact
Scenarios for `loadimpact.com`, written against Liquid Web's WooCommerce sample data.
Stars: ✭ 17 (-32%)
Mutual labels:  wordpress
Ddev
DDEV-Local: a local PHP development environment system
Stars: ✭ 915 (+3560%)
Mutual labels:  wordpress

Wordprismic

npm

Wordprismic is a small and fully configurable Node utility for importing existing Wordpress blogs into the Prismic.io content platform.

Requirements

Make sure you meet the following requirements before using the importer:

  • Wordpress's REST API enabled (included and auto-enabled in core from WP 4.4+)
  • Both Node 7.6+ and Ruby installed
  • Any Wordpress plugins that add or change content models (eg: Advanced Custom Fields, YOAST, etc) hooked up to the REST API, via plugins or otherwise

Configuration

Create a JavaScript configuration file with the following properties

Property Description
wordpress.url The full URL of your wordpress blog
prismic.repo The name of your Prismic repository
prismic.locale The locale of language locale of your imported documents in Prismic (see Settings -> Translations & locales)
prismic.categoriesType (optional) The content type of post categories in prismic, if available
optimizeMediaRequests (optional) Whether to attempt to only fetch required media assets. Shortens import time, but can cause 503 errors on some Wordpress servers.
schema A function to transform Wordpress data to your Prismic content model, see documentation below
module.exports = {
  wordpress: {
    url: 'https://myblog.com'
  },
  prismic: {
    repo: 'myNewBlog',
    locale: 'en-au',
    categoriesType: 'category'
  },
  optimizeMediaRequests: false,
  schema: async function(post, html) {
    return {
      type: 'post',
      uid: post.slug,
      category: {
        id: post.categories[0].prismic.id,
        mask: 'category'
      },
      author: post.author.name,
      title: html.decode(post.title.rendered),
      featured_image: {
        origin: {
          url: post.featured_media.guid.rendered
        },
        alt: post.featured_media.alt_text
      },
      excerpt: await html.parse(post.excerpt.rendered),
      content: await html.parse(post.content.rendered)
    };
  }
};

Defining your schema

The config schema describes how your Wordpress posts map to your Prismic content model. It's written as a function that is given two paramaters:

  1. The imported post from Wordpress
  2. Helper functions html.parse(), which creates Prismic RichText objects out of HTML strings, and html.decode(), which decodes HTML strings with entities

See the Wordpress Posts API Reference for all properties available on the post object provided. However, the following properties on post have been changed by Wordprismic:

  • author is the full user object, rather than just the ID
  • featured_media is the media object object of the asset, rather than just the ID
  • Each item in categories has been populated with a matching Prismic category if it's available (from prismicCategories type in config) as follows: { wordpress: [category], prismic: [document] }

The html.parse() function is asynchronous, so make sure you await it and flag your schema as async.

Importing

You can now run the importer directly from NPM, with the following arguments

Argument Description
--config (-c) Path to your config file
--dest (-d) Location to save zip archive for imorting, defaults to current directory
npx wordprismic -c ./path/to/config.js

Or if you'd prefer, install the module globally first

npm i -g wordprismic

wordprismic -c ./path/to/config.js

Your new Prismic posts will be saved to in a folder called wordprismic-import. Compress the contents (not the folder itself) to a .zip archive, then import it to Prismic.


© MIT Tomorrow

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].