Coder Social home page Coder Social logo

yashha / wp-nuxt Goto Github PK

View Code? Open in Web Editor NEW
219.0 4.0 18.0 3.88 MB

NOT MAINTAINED The module adds WP-API to your nuxt application.

Home Page: https://wp-nuxt.netlify.com/

License: MIT License

JavaScript 96.08% Vue 3.92%
wp-api wp-nuxt nuxt wordpress ssr rest-api frontend javascript

wp-nuxt's Issues

Create more than one WPAPI instance (with different endpoints)

Hey there,

I am using wp-nuxt to integrate a wordpress multisite-network (mutliple languages). So far it works great, however I am having a hard time figuring out whether or not it is possible to define multiple endpoints in the nuxt.config.js, like in the following example.

This is the standard way defining one WPAPI instance which can be referenced using this.$wp in vuex:
nuxt.config.js

...
  modules: [
    "wp-nuxt",
  ],
wp: {
    endpoint: "http://cmshost/wp-json/",
}
...

Now, I want to have a second (or more) WPAPI instance(s) providing a different endpoint. In my case the endpoint would vary by locale:

nuxt.config.js

...
  modules: [
    "wp-nuxt",
  ],
wp: {
    endpoint: ["http://cmshost/wp-json/", "http://cmshost/wp-json/de"],
}
...

Is this possible using wp-nuxt or do I need to change using node-wpapi directly and do the nuxt integration myself?

Thanks in advance,
Valentin

Feature: Auto Discover & Custom Routes

Routes as: "wp/v2/custom-taxonomy" aren't visible.
Module node-wpapi don't accept .discovery() function - undefined right now.

Right now solution:
Need to add plugin to nuxt.config.js as custom plugin plugins/wpapi-extend.js:

export default ({ app }) => {
    app.$wp.customTaxonomy = app.$wp.registerRoute( 'wp/v2', '/custom-taxonomy');
    app.$wp.customTaxonomy = app.$wp.registerRoute( 'wp/v2', '/custom-taxonomy/(?P<id>[\\d]+)' );
}

Refer:
https://github.com/WP-API/node-wpapi/tree/v1#auto-discovery

Hint:
Add option to module setting adding new routes from array of object.
Example:

{
  "extension" : "wp/v2", 
  "route" : "custom-taxonomy",
 "name" : "customTaxonomy" //Default PascalCode, option to have unique name if similar with default ones
}

IE 11 syntax error

We have an issue when we are using wp-nuxt out of the box on ie11, we get a syntax error in the superagent library (yarn run dev -> vendor.app.js):

.forEach(fn => {

Problem is that arrow-functions (and other ES6) do not work in ie11, so we added all libraries to transpile in the build option. That solves the first error and a couple of others that are following and are ES6 related. Unfortunately, now we are stuck with the following error, which we can't find any fix for (vendor.app.js): "Unable to get property 'replace' of undefined or null reference".

namedGroupedPattern.replace(

Is there a fix for that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.