Skip to content

Commit

Permalink
Update babel and add render in placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
marconi1992 committed Aug 14, 2019
1 parent ed92300 commit 295c338
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hypernova-vue",
"version": "2.0.0",
"version": "2.1.0",
"description": "Vue bindings for Hypernova",
"main": "lib/index.js",
"author": "Felipe Guizar Diaz <felipegaiacharly@gmail.com>",
Expand All @@ -21,14 +21,17 @@
"url": "git@github.com:marconi1992/hypernova-vue.git"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-airbnb": "^2.5.3",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.5.5",
"babel-preset-airbnb": "^4.0.1",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0"
},
"peerDependencies": {
"dependencies": {
"hypernova": "^2.5.0",
"nova-helpers": "^1.0.1-alpha.0",
"vue": "^2.6.6",
"vue-server-renderer": "^2.6.6"
}
Expand Down
24 changes: 24 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
import vue from 'vue';
import { createRenderer } from 'vue-server-renderer';
import hypernova, { serialize, load } from 'hypernova';
import { findNode, getData } from 'nova-helpers';

const { document } = global;

const mountComponent = (Component, node, data) => {
const vm = new Component({
propsData: data,
});

if (!node.firstChild) {
node.appendChild(document.createElement('div'));
}

vm.$mount(node.children[0]);
};

export const Vue = vue;

export const renderInPlaceholder = (name, Component, id) => {
const node = findNode(name, id);
const data = getData(name, id);

if (node && data) {
mountComponent(Component, node, data);
}
};

export const renderVue = (name, Component) => hypernova({
server() {
return async (propsData) => {
Expand Down

0 comments on commit 295c338

Please sign in to comment.