@parameter1/base-cms-marko-web 3.2.2 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
package/browser/index.js
CHANGED
@@ -14,10 +14,13 @@ const load = async ({
|
|
14
14
|
props,
|
15
15
|
on,
|
16
16
|
hydrate,
|
17
|
+
skipWhenExists,
|
17
18
|
} = {}) => {
|
18
19
|
if (!el || !name) throw new Error('A Vue component name and element must be provided.');
|
19
20
|
const Component = components[name];
|
20
21
|
if (!Component) throw new Error(`No Vue component found for '${name}'`);
|
22
|
+
const shouldRender = skipWhenExists ? document.querySelectorAll(`script.component[data-name="${name}"]`).length <= 1 : true;
|
23
|
+
if (!shouldRender) return;
|
21
24
|
const component = new Vue({
|
22
25
|
provide: providers[name],
|
23
26
|
render: h => h(Component, { props, on: { ...on, ...listeners[name] } }),
|
@@ -7,8 +7,9 @@ $ const tag = defaultValue(input.tag, "div");
|
|
7
7
|
$ const { name } = input;
|
8
8
|
$ const ssr = defaultValue(input.ssr, false);
|
9
9
|
$ const hydrate = ssr ? true : defaultValue(input.hydrate, false);
|
10
|
+
$ const skipWhenExists = defaultValue(input.skipWhenExists, false);
|
10
11
|
$ const props = JSON.stringify(input.props || {});
|
11
|
-
$ const contents = `CMSBrowserComponents.load({ el: '#${id}', name: '${name}', props: ${props}, hydrate: ${hydrate} });`;
|
12
|
+
$ const contents = `CMSBrowserComponents.load({ el: '#${id}', name: '${name}', props: ${props}, hydrate: ${hydrate}, skipWhenExists: ${skipWhenExists} });`;
|
12
13
|
|
13
14
|
<if(ssr)>
|
14
15
|
$ const { compiledVueComponents } = out.global;
|
@@ -23,4 +24,4 @@ $ const contents = `CMSBrowserComponents.load({ el: '#${id}', name: '${name}', p
|
|
23
24
|
<${input.renderBody} />
|
24
25
|
</>
|
25
26
|
</else>
|
26
|
-
<script>$!{contents}</script>
|
27
|
+
<script class="component" data-name=name>$!{contents}</script>
|
package/components/marko.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@parameter1/base-cms-marko-web",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.3.0",
|
4
4
|
"description": "Core Marko+Express components for BaseCMS websites",
|
5
5
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
6
6
|
"main": "index.js",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ee5705e924b161f9617b1984a95c21f73004e4b5"
|
50
50
|
}
|