@prismicio/vue 2.0.11 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +81 -149
- package/components/common.js +289 -47
- package/components/index.js +283 -45
- package/components/umd.js +292 -49
- package/dist/prismic-vue.common.js +299 -55
- package/dist/prismic-vue.esm.js +292 -50
- package/dist/prismic-vue.js +303 -59
- package/dist/prismic-vue.min.js +1 -1
- package/package.json +86 -47
- package/src/components/Embed.js +32 -32
- package/src/components/Image.js +27 -22
- package/src/components/Link.js +87 -51
- package/src/components/RichText.js +40 -41
- package/src/components/SliceZone.js +145 -0
- package/src/components/Text.js +37 -0
- package/src/components/index.js +26 -22
- package/src/components-bundler.js +10 -5
- package/src/index.js +51 -39
- package/src/methods.js +16 -22
- package/vetur/attributes.json +86 -0
- package/vetur/tags.json +38 -0
package/src/components/index.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import Embed from
|
|
2
|
-
import Image from
|
|
3
|
-
import Link from
|
|
4
|
-
import RichText from
|
|
1
|
+
import Embed from "./Embed";
|
|
2
|
+
import Image from "./Image";
|
|
3
|
+
import Link from "./Link";
|
|
4
|
+
import RichText from "./RichText";
|
|
5
|
+
import Text from "./Text";
|
|
6
|
+
import { SliceZone } from "./SliceZone";
|
|
5
7
|
|
|
6
|
-
const NuxtLink = Link({ component:
|
|
7
|
-
const VueRouterLink = Link({ component:
|
|
8
|
+
const NuxtLink = Link({ component: "nuxt-link" });
|
|
9
|
+
const VueRouterLink = Link({ component: "router-link" });
|
|
8
10
|
|
|
9
11
|
const exp = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
common: {
|
|
13
|
+
Embed,
|
|
14
|
+
Image,
|
|
15
|
+
RichText,
|
|
16
|
+
Text,
|
|
17
|
+
SliceZone,
|
|
18
|
+
},
|
|
19
|
+
nuxt: {
|
|
20
|
+
Link: NuxtLink,
|
|
21
|
+
},
|
|
22
|
+
vueRouter: {
|
|
23
|
+
Link: VueRouterLink,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
22
26
|
|
|
23
|
-
export const common = exp.common
|
|
24
|
-
export const nuxt = exp.nuxt
|
|
25
|
-
export const vueRouter = exp.vueRouter
|
|
27
|
+
export const common = exp.common;
|
|
28
|
+
export const nuxt = exp.nuxt;
|
|
29
|
+
export const vueRouter = exp.vueRouter;
|
|
26
30
|
|
|
27
|
-
export default exp
|
|
31
|
+
export default exp;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import exp from
|
|
1
|
+
import exp from "./components";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export {
|
|
4
|
+
getSliceComponentProps,
|
|
5
|
+
defineSliceZoneComponents,
|
|
6
|
+
} from "./components/SliceZone";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
+
export const common = exp.common;
|
|
9
|
+
export const nuxt = exp.nuxt;
|
|
10
|
+
export const vueRouter = exp.vueRouter;
|
|
11
|
+
|
|
12
|
+
export default exp;
|
package/src/index.js
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
import prismicJS from
|
|
1
|
+
import prismicJS from "@prismicio/client";
|
|
2
|
+
const { client } = prismicJS;
|
|
2
3
|
|
|
3
|
-
import Components from
|
|
4
|
-
import { asHtml, asText, asDate, asLink } from
|
|
4
|
+
import Components from "./components";
|
|
5
|
+
import { asHtml, asText, asDate, asLink } from "./methods";
|
|
5
6
|
|
|
6
7
|
function attachMethods(Vue, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
Vue.prototype.$prismic.asHtml = function (
|
|
9
|
+
richText,
|
|
10
|
+
linkResolver,
|
|
11
|
+
htmlSerializer,
|
|
12
|
+
) {
|
|
13
|
+
return asHtml(
|
|
14
|
+
richText,
|
|
15
|
+
linkResolver || options.linkResolver,
|
|
16
|
+
htmlSerializer || options.htmlSerializer,
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
Vue.prototype.$prismic.asHTML = Vue.prototype.$prismic.asHtml;
|
|
20
|
+
Vue.prototype.$prismic.asText = asText;
|
|
21
|
+
Vue.prototype.$prismic.richTextAsPlain = asText;
|
|
22
|
+
Vue.prototype.$prismic.asDate = asDate;
|
|
23
|
+
Vue.prototype.$prismic.asLink = function (link, linkResolver) {
|
|
24
|
+
return asLink(link, linkResolver || options.linkResolver);
|
|
25
|
+
};
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
const PrismicVue = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
install: function (Vue, options) {
|
|
30
|
+
const { linkType = "vueRouter" } = options;
|
|
31
|
+
Vue.prototype.$prismic = prismicJS;
|
|
32
|
+
Vue.prototype.$prismic.predicate = prismicJS.Predicates;
|
|
33
|
+
Vue.prototype.$prismic.cookie = {
|
|
34
|
+
preview: prismicJS.previewCookie,
|
|
35
|
+
};
|
|
36
|
+
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
37
|
+
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
38
|
+
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
39
|
+
Vue.prototype.$prismic.client = client(
|
|
40
|
+
options.endpoint,
|
|
41
|
+
options.apiOptions,
|
|
42
|
+
);
|
|
30
43
|
|
|
31
|
-
|
|
44
|
+
attachMethods(Vue, options);
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
const components = {
|
|
47
|
+
...Components.common,
|
|
48
|
+
...Components[linkType],
|
|
49
|
+
};
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
51
|
+
/**
|
|
52
|
+
* Global registration of common components + stack specific components.
|
|
53
|
+
* Currently, only Nuxt links differ though. Use `linkType: 'nuxt'` in that case.
|
|
54
|
+
*/
|
|
55
|
+
Object.entries(components).forEach(([_, c]) => {
|
|
56
|
+
Vue.component(c.name, c);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
};
|
|
48
60
|
|
|
49
|
-
export default PrismicVue
|
|
61
|
+
export default PrismicVue;
|
package/src/methods.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import PrismicDOM from
|
|
1
|
+
import PrismicDOM from "prismic-dom";
|
|
2
2
|
|
|
3
3
|
export function asHtml(richText, linkResolver, htmlSerializer) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
linkResolver,
|
|
8
|
-
htmlSerializer
|
|
9
|
-
)
|
|
10
|
-
}
|
|
4
|
+
if (richText) {
|
|
5
|
+
return PrismicDOM.RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
6
|
+
}
|
|
11
7
|
}
|
|
12
8
|
export function asText(richText, joinString) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
if (richText) {
|
|
10
|
+
return PrismicDOM.RichText.asText(richText, joinString);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return "";
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
export function asLink(link, linkResolver) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
linkResolver
|
|
24
|
-
)
|
|
25
|
-
}
|
|
17
|
+
if (link) {
|
|
18
|
+
return PrismicDOM.Link.url(link, linkResolver);
|
|
19
|
+
}
|
|
26
20
|
}
|
|
27
21
|
export function asDate(date) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
22
|
+
if (date) {
|
|
23
|
+
return PrismicDOM.Date(date);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prismic-embed/field": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "The Prismic embed field to render."
|
|
5
|
+
},
|
|
6
|
+
"prismic-embed/wrapper": {
|
|
7
|
+
"type": "string | object | function",
|
|
8
|
+
"description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"prismic-image/field": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "The Prismic image field to render."
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
"prismic-link/field": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"description": "The Prismic link field or document to render."
|
|
19
|
+
},
|
|
20
|
+
"prismic-link/link-resolver": {
|
|
21
|
+
"type": "function",
|
|
22
|
+
"description": "A link resolver function used to resolve links when not using the route resolver parameter with `@prismicio/client`. Defaults to the link resolver provided to `@prismicio/vue` plugin if configured."
|
|
23
|
+
},
|
|
24
|
+
"prismic-link/target": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "An explicit `target` attribute to apply to the rendered link."
|
|
27
|
+
},
|
|
28
|
+
"prismic-link/rel": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "An explicit `rel` attribute to apply to the rendered link."
|
|
31
|
+
},
|
|
32
|
+
"prismic-link/blank-target-rel-attribute": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Value of the `rel` attribute to use on links rendered with `target=\"_blank\"`. Defaults to the one provided to `@prismicio/vue` plugin if configured, `\"noopener noreferrer\"` otherwise."
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
"prismic-rich-text/field": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"description": "The Prismic rich text or title field to render."
|
|
40
|
+
},
|
|
41
|
+
"prismic-rich-text/link-resolver": {
|
|
42
|
+
"type": "function",
|
|
43
|
+
"description": "A link resolver function used to resolve links when not using the route resolver parameter with `@prismicio/client`. Defaults to the link resolver provided to `@prismicio/vue` plugin if configured."
|
|
44
|
+
},
|
|
45
|
+
"prismic-rich-text/html-serializer": {
|
|
46
|
+
"type": "function | object",
|
|
47
|
+
"description": "An HTML serializer to customize the way rich text fields are rendered. Defaults to the HTML serializer provided to `@prismicio/vue` plugin if configured."
|
|
48
|
+
},
|
|
49
|
+
"prismic-rich-text/wrapper": {
|
|
50
|
+
"type": "string | object | function",
|
|
51
|
+
"description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
"prismic-text/field": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"description": "The Prismic rich text or title field to render."
|
|
57
|
+
},
|
|
58
|
+
"prismic-text/separator": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "Separator used to join each element. Defaults to `\" \"` (a space)"
|
|
61
|
+
},
|
|
62
|
+
"prismic-text/wrapper": {
|
|
63
|
+
"type": "string | object | function",
|
|
64
|
+
"description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"slice-zone/slices": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"description": "List of Slice data from the Slice Zone."
|
|
70
|
+
},
|
|
71
|
+
"slice-zone/components": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"description": "A record mapping Slice types to Vue components."
|
|
74
|
+
},
|
|
75
|
+
"slice-zone/context": {
|
|
76
|
+
"description": "Arbitrary data made available to all Slice components."
|
|
77
|
+
},
|
|
78
|
+
"slice-zone/default-component": {
|
|
79
|
+
"type": "string | object | function",
|
|
80
|
+
"description": "A component or a functional component rendered if a component mapping from the `components` prop cannot be found. Defaults to the Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else `\"todo-slice-component\"`"
|
|
81
|
+
},
|
|
82
|
+
"slice-zone/wrapper": {
|
|
83
|
+
"type": "string | object | function",
|
|
84
|
+
"description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
|
|
85
|
+
}
|
|
86
|
+
}
|
package/vetur/tags.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prismic-embed": {
|
|
3
|
+
"attributes": ["field", "wrapper"],
|
|
4
|
+
"description": "Component to render a Prismic embed field."
|
|
5
|
+
},
|
|
6
|
+
"prismic-image": {
|
|
7
|
+
"attributes": ["field"],
|
|
8
|
+
"description": "Component to render a Prismic image field."
|
|
9
|
+
},
|
|
10
|
+
"prismic-link": {
|
|
11
|
+
"attributes": [
|
|
12
|
+
"field",
|
|
13
|
+
"link-resolver",
|
|
14
|
+
"target",
|
|
15
|
+
"rel",
|
|
16
|
+
"blank-target-rel-attribute"
|
|
17
|
+
],
|
|
18
|
+
"description": "Component to render a Prismic link field."
|
|
19
|
+
},
|
|
20
|
+
"prismic-rich-text": {
|
|
21
|
+
"attributes": ["field", "link-resolver", "html-serializer", "wrapper"],
|
|
22
|
+
"description": "Component to render a Prismic rich text field as HTML."
|
|
23
|
+
},
|
|
24
|
+
"prismic-text": {
|
|
25
|
+
"attributes": ["field", "separator", "wrapper"],
|
|
26
|
+
"description": "Component to render a Prismic rich text field as plain text."
|
|
27
|
+
},
|
|
28
|
+
"slice-zone": {
|
|
29
|
+
"attributes": [
|
|
30
|
+
"slices",
|
|
31
|
+
"components",
|
|
32
|
+
"context",
|
|
33
|
+
"default-component",
|
|
34
|
+
"wrapper"
|
|
35
|
+
],
|
|
36
|
+
"description": "Component to render a Prismic Slice Zone."
|
|
37
|
+
}
|
|
38
|
+
}
|