@prismicio/vue 5.0.0-alpha.1 → 5.0.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/dist/PrismicLink.vue.cjs +0 -36
- package/dist/PrismicLink.vue.cjs.map +1 -1
- package/dist/PrismicLink.vue.js +1 -37
- package/dist/PrismicLink.vue.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +7 -7
- package/src/PrismicLink.vue +1 -42
- package/src/types.ts +1 -1
package/dist/PrismicLink.vue.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const client = require("@prismicio/client");
|
|
4
|
-
const esmEnv = require("esm-env");
|
|
5
|
-
const devMsg = require("./lib/devMsg.cjs");
|
|
6
4
|
const isInternalURL = require("./lib/isInternalURL.cjs");
|
|
7
5
|
const usePrismic = require("./usePrismic.cjs");
|
|
8
6
|
const defaultInternalComponent = "router-link";
|
|
@@ -22,40 +20,6 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
22
20
|
setup(__props) {
|
|
23
21
|
const props = __props;
|
|
24
22
|
const { options } = usePrismic.usePrismic();
|
|
25
|
-
if (esmEnv.DEV) {
|
|
26
|
-
vue.watchEffect(() => {
|
|
27
|
-
if (props.field) {
|
|
28
|
-
if (!props.field.link_type) {
|
|
29
|
-
console.error(
|
|
30
|
-
`[PrismicLink] This "field" prop value caused an error to be thrown.
|
|
31
|
-
`,
|
|
32
|
-
props.field
|
|
33
|
-
);
|
|
34
|
-
throw new Error(
|
|
35
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg.devMsg(
|
|
36
|
-
"missing-link-properties"
|
|
37
|
-
)}`
|
|
38
|
-
);
|
|
39
|
-
} else if (("text" in props.field ? Object.keys(props.field).length > 2 : Object.keys(props.field).length > 1) && !("url" in props.field || "uid" in props.field || "id" in props.field)) {
|
|
40
|
-
console.warn(
|
|
41
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg.devMsg(
|
|
42
|
-
"missing-link-properties"
|
|
43
|
-
)}`,
|
|
44
|
-
props.field
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
} else if (props.document) {
|
|
48
|
-
if (!("url" in props.document || "id" in props.document)) {
|
|
49
|
-
console.warn(
|
|
50
|
-
`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg.devMsg(
|
|
51
|
-
"missing-link-properties"
|
|
52
|
-
)}`,
|
|
53
|
-
props.document
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
23
|
const rawAttrs = vue.computed(() => {
|
|
60
24
|
return client.asLinkAttrs(props.field || props.document, {
|
|
61
25
|
linkResolver: props.linkResolver || options.linkResolver,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue.cjs","sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport {
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue.cjs","sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\"\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\"\n\n/**\n * The default rel attribute rendered for external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * An HTML tag name or a component used to render internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * An HTML tag name or a component used to render external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { options } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || options.linkResolver,\n\t\trel(args) {\n\t\t\tconst maybeRel = props.rel || options.components?.linkRel\n\t\t\tif (maybeRel) {\n\t\t\t\treturn typeof maybeRel === \"function\" ? maybeRel(args) : maybeRel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\toptions.components?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\toptions.components?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"names":["usePrismic","computed","asLinkAttrs","isInternalURL"],"mappings":";;;;;AAmBA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,8BAA8B;;;;;;;;;;;;;AAqEpC,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAIA,sBAAW;AAEzB,UAAA,WAAWC,IAAAA,SAAS,MAAM;AAC/B,aAAOC,OAAY,YAAA,MAAM,SAAS,MAAM,UAAU;AAAA,QACjD,cAAc,MAAM,gBAAgB,QAAQ;AAAA,QAC5C,IAAI,MAAM;;AACT,gBAAM,WAAW,MAAM,SAAO,aAAQ,eAAR,mBAAoB;AAClD,cAAI,UAAU;AACb,mBAAO,OAAO,aAAa,aAAa,SAAS,IAAI,IAAI;AAAA,UAAA;AAGnD,iBAAA,KAAK,aAAa,8BAA8B;AAAA,QAAA;AAAA,MACxD,CACA;AAAA,IAAA,CACD;AAEK,UAAA,YAAYD,IAAAA,SAAS,MAAM;;AAChC,aAAOE,cAAAA,cAAc,SAAS,MAAM,QAAQ,EAAE,IAC3C,MAAM,uBACN,aAAQ,eAAR,mBAAoB,0BACpB,2BACA,MAAM,uBACN,aAAQ,eAAR,mBAAoB,0BACpB;AAAA,IAAA,CACH;AAGK,UAAA,QAAQF,IAAAA,SAAS,MAAM;AACrB,aAAA,UAAU,UAAU,MACxB;AAAA,QACA,MAAM,SAAS,MAAM;AAAA,QACrB,QAAQ,SAAS,MAAM;AAAA,QACvB,KAAK,SAAS,MAAM;AAAA,MAAA,IAEpB;AAAA,QACA,IAAI,SAAS,MAAM;AAAA,QACnB,QAAQ,SAAS,MAAM;AAAA,QACvB,KAAK,SAAS,MAAM;AAAA,MACrB;AAAA,IAAA,CACF;;;;;;;;;;;;;;"}
|
package/dist/PrismicLink.vue.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, computed, openBlock, createBlock, resolveDynamicComponent, normalizeProps, guardReactiveProps, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
2
2
|
import { asLinkAttrs } from "@prismicio/client";
|
|
3
|
-
import { DEV } from "esm-env";
|
|
4
|
-
import { devMsg } from "./lib/devMsg.js";
|
|
5
3
|
import { isInternalURL } from "./lib/isInternalURL.js";
|
|
6
4
|
import { usePrismic } from "./usePrismic.js";
|
|
7
5
|
const defaultInternalComponent = "router-link";
|
|
@@ -21,40 +19,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
21
19
|
setup(__props) {
|
|
22
20
|
const props = __props;
|
|
23
21
|
const { options } = usePrismic();
|
|
24
|
-
if (DEV) {
|
|
25
|
-
watchEffect(() => {
|
|
26
|
-
if (props.field) {
|
|
27
|
-
if (!props.field.link_type) {
|
|
28
|
-
console.error(
|
|
29
|
-
`[PrismicLink] This "field" prop value caused an error to be thrown.
|
|
30
|
-
`,
|
|
31
|
-
props.field
|
|
32
|
-
);
|
|
33
|
-
throw new Error(
|
|
34
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(
|
|
35
|
-
"missing-link-properties"
|
|
36
|
-
)}`
|
|
37
|
-
);
|
|
38
|
-
} else if (("text" in props.field ? Object.keys(props.field).length > 2 : Object.keys(props.field).length > 1) && !("url" in props.field || "uid" in props.field || "id" in props.field)) {
|
|
39
|
-
console.warn(
|
|
40
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(
|
|
41
|
-
"missing-link-properties"
|
|
42
|
-
)}`,
|
|
43
|
-
props.field
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
} else if (props.document) {
|
|
47
|
-
if (!("url" in props.document || "id" in props.document)) {
|
|
48
|
-
console.warn(
|
|
49
|
-
`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(
|
|
50
|
-
"missing-link-properties"
|
|
51
|
-
)}`,
|
|
52
|
-
props.document
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
22
|
const rawAttrs = computed(() => {
|
|
59
23
|
return asLinkAttrs(props.field || props.document, {
|
|
60
24
|
linkResolver: props.linkResolver || options.linkResolver,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismicLink.vue.js","sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport {
|
|
1
|
+
{"version":3,"file":"PrismicLink.vue.js","sources":["../src/PrismicLink.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { AsLinkAttrsConfig } from \"@prismicio/client\"\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n} from \"@prismicio/client\"\nimport { computed } from \"vue\"\n\nimport { isInternalURL } from \"./lib/isInternalURL\"\n\nimport type { ComponentOrTagName } from \"./types\"\n\nimport { usePrismic } from \"./usePrismic\"\n\n/**\n * The default component rendered for internal URLs.\n */\nconst defaultInternalComponent = \"router-link\"\n\n/**\n * The default component rendered for external URLs.\n */\nconst defaultExternalComponent = \"a\"\n\n/**\n * The default rel attribute rendered for external URLs.\n */\nconst defaultExternalRelAttribute = \"noreferrer\"\n\n/**\n * Props for `<PrismicLink />`.\n */\nexport type PrismicLinkProps = {\n\t/**\n\t * A link resolver function used to resolve links when not using the route\n\t * resolver parameter with `@prismicio/client`.\n\t *\n\t * @defaultValue The link resolver provided to `@prismicio/vue` plugin if configured.\n\t *\n\t * @see Link resolver documentation {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#link-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction\n\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"]\n\n\t/**\n\t * An HTML tag name or a component used to render internal links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, {@link RouterLink} otherwise.\n\t */\n\tinternalComponent?: ComponentOrTagName\n\n\t/**\n\t * An HTML tag name or a component used to render external links.\n\t *\n\t * @remarks\n\t * HTML tag names will be rendered using the anchor tag interface (`href`,\n\t * `target`, and `rel` attributes).\n\t * @remarks\n\t * Components will be rendered using Vue Router {@link RouterLink} interface\n\t * (`to` props).\n\t *\n\t * @defaultValue The one provided to `@prismicio/vue` plugin if configured, `\"a\"` otherwise.\n\t */\n\texternalComponent?: ComponentOrTagName\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic link field to render.\n\t\t\t */\n\t\t\tfield: LinkField\n\t\t\tdocument?: never\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Prismic document to render as a link.\n\t\t\t */\n\t\t\tdocument: PrismicDocument\n\t\t\tfield?: never\n\t }\n)\n\nconst props = defineProps<PrismicLinkProps>()\ndefineOptions({ name: \"PrismicLink\" })\n\nconst { options } = usePrismic()\n\nconst rawAttrs = computed(() => {\n\treturn asLinkAttrs(props.field || props.document, {\n\t\tlinkResolver: props.linkResolver || options.linkResolver,\n\t\trel(args) {\n\t\t\tconst maybeRel = props.rel || options.components?.linkRel\n\t\t\tif (maybeRel) {\n\t\t\t\treturn typeof maybeRel === \"function\" ? maybeRel(args) : maybeRel\n\t\t\t}\n\n\t\t\treturn args.isExternal ? defaultExternalRelAttribute : undefined\n\t\t},\n\t})\n})\n\nconst component = computed(() => {\n\treturn isInternalURL(rawAttrs.value.href || \"\")\n\t\t? props.internalComponent ||\n\t\t\t\toptions.components?.linkInternalComponent ||\n\t\t\t\tdefaultInternalComponent\n\t\t: props.externalComponent ||\n\t\t\t\toptions.components?.linkExternalComponent ||\n\t\t\t\tdefaultExternalComponent\n})\n\n// Match Vue Router's `<RouterLink />` interface unless the component is an anchor tag.\nconst attrs = computed(() => {\n\treturn component.value === \"a\"\n\t\t? {\n\t\t\t\thref: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n\t\t: {\n\t\t\t\tto: rawAttrs.value.href,\n\t\t\t\ttarget: rawAttrs.value.target,\n\t\t\t\trel: rawAttrs.value.rel,\n\t\t\t}\n})\n</script>\n\n<template>\n\t<component :is=\"component\" v-bind=\"attrs\">\n\t\t<slot>\n\t\t\t{{ props.field && \"text\" in props.field ? props.field.text : undefined }}\n\t\t</slot>\n\t</component>\n</template>\n"],"names":[],"mappings":";;;;AAmBA,MAAM,2BAA2B;AAKjC,MAAM,2BAA2B;AAKjC,MAAM,8BAA8B;;;;;;;;;;;;;AAqEpC,UAAM,QAAQ;AAGR,UAAA,EAAE,QAAQ,IAAI,WAAW;AAEzB,UAAA,WAAW,SAAS,MAAM;AAC/B,aAAO,YAAY,MAAM,SAAS,MAAM,UAAU;AAAA,QACjD,cAAc,MAAM,gBAAgB,QAAQ;AAAA,QAC5C,IAAI,MAAM;;AACT,gBAAM,WAAW,MAAM,SAAO,aAAQ,eAAR,mBAAoB;AAClD,cAAI,UAAU;AACb,mBAAO,OAAO,aAAa,aAAa,SAAS,IAAI,IAAI;AAAA,UAAA;AAGnD,iBAAA,KAAK,aAAa,8BAA8B;AAAA,QAAA;AAAA,MACxD,CACA;AAAA,IAAA,CACD;AAEK,UAAA,YAAY,SAAS,MAAM;;AAChC,aAAO,cAAc,SAAS,MAAM,QAAQ,EAAE,IAC3C,MAAM,uBACN,aAAQ,eAAR,mBAAoB,0BACpB,2BACA,MAAM,uBACN,aAAQ,eAAR,mBAAoB,0BACpB;AAAA,IAAA,CACH;AAGK,UAAA,QAAQ,SAAS,MAAM;AACrB,aAAA,UAAU,UAAU,MACxB;AAAA,QACA,MAAM,SAAS,MAAM;AAAA,QACrB,QAAQ,SAAS,MAAM;AAAA,QACvB,KAAK,SAAS,MAAM;AAAA,MAAA,IAEpB;AAAA,QACA,IAAI,SAAS,MAAM;AAAA,QACnB,QAAQ,SAAS,MAAM;AAAA,QACvB,KAAK,SAAS,MAAM;AAAA,MACrB;AAAA,IAAA,CACF;;;;;;;;;;;;;"}
|
package/dist/package.json.cjs
CHANGED
package/dist/package.json.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ type PrismicPluginComponentsOptions = {
|
|
|
59
59
|
imagePixelDensitySrcSetDefaults?: number[];
|
|
60
60
|
/**
|
|
61
61
|
* An optional map of Rich Text block types to Vue Components. It is used to
|
|
62
|
-
* render
|
|
62
|
+
* render rich text or title fields.
|
|
63
63
|
*
|
|
64
64
|
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/rich-text}
|
|
65
65
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/vue",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Vue plugin, components, and composables to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@prismicio/client": "^7.
|
|
60
|
+
"@prismicio/client": "^7.15.1",
|
|
61
61
|
"esm-env": "^1.2.2",
|
|
62
62
|
"vue-router": "^4.5.0"
|
|
63
63
|
},
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
|
69
69
|
"@types/jsdom-global": "^3.0.7",
|
|
70
70
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
71
|
-
"@vitest/coverage-v8": "^
|
|
71
|
+
"@vitest/coverage-v8": "^3.0.2",
|
|
72
72
|
"@vue/eslint-config-typescript": "^14.2.0",
|
|
73
73
|
"@vue/test-utils": "^2.4.6",
|
|
74
74
|
"eslint": "^9.18.0",
|
|
75
75
|
"eslint-config-prettier": "^10.0.1",
|
|
76
|
-
"eslint-plugin-prettier": "^5.2.
|
|
76
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
77
77
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
78
78
|
"eslint-plugin-vue": "^9.32.0",
|
|
79
79
|
"jsdom": "^26.0.0",
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"size-limit": "^11.1.6",
|
|
84
84
|
"standard-version": "^9.5.0",
|
|
85
85
|
"typescript": "~5.7.3",
|
|
86
|
-
"typescript-eslint": "^8.
|
|
87
|
-
"vite": "^6.0.
|
|
86
|
+
"typescript-eslint": "^8.21.0",
|
|
87
|
+
"vite": "^6.0.9",
|
|
88
88
|
"vite-plugin-dts": "^4.5.0",
|
|
89
89
|
"vite-plugin-sdk": "^0.1.3",
|
|
90
|
-
"vitest": "^
|
|
90
|
+
"vitest": "^3.0.2",
|
|
91
91
|
"vue": "^3.5.13",
|
|
92
92
|
"vue-tsc": "^2.2.0"
|
|
93
93
|
},
|
package/src/PrismicLink.vue
CHANGED
|
@@ -6,10 +6,8 @@ import {
|
|
|
6
6
|
type PrismicDocument,
|
|
7
7
|
asLinkAttrs,
|
|
8
8
|
} from "@prismicio/client"
|
|
9
|
-
import {
|
|
10
|
-
import { computed, watchEffect } from "vue"
|
|
9
|
+
import { computed } from "vue"
|
|
11
10
|
|
|
12
|
-
import { devMsg } from "./lib/devMsg"
|
|
13
11
|
import { isInternalURL } from "./lib/isInternalURL"
|
|
14
12
|
|
|
15
13
|
import type { ComponentOrTagName } from "./types"
|
|
@@ -103,45 +101,6 @@ defineOptions({ name: "PrismicLink" })
|
|
|
103
101
|
|
|
104
102
|
const { options } = usePrismic()
|
|
105
103
|
|
|
106
|
-
if (DEV) {
|
|
107
|
-
watchEffect(() => {
|
|
108
|
-
if (props.field) {
|
|
109
|
-
if (!props.field.link_type) {
|
|
110
|
-
console.error(
|
|
111
|
-
`[PrismicLink] This "field" prop value caused an error to be thrown.\n`,
|
|
112
|
-
props.field,
|
|
113
|
-
)
|
|
114
|
-
throw new Error(
|
|
115
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(
|
|
116
|
-
"missing-link-properties",
|
|
117
|
-
)}`,
|
|
118
|
-
)
|
|
119
|
-
} else if (
|
|
120
|
-
("text" in props.field
|
|
121
|
-
? Object.keys(props.field).length > 2
|
|
122
|
-
: Object.keys(props.field).length > 1) &&
|
|
123
|
-
!("url" in props.field || "uid" in props.field || "id" in props.field)
|
|
124
|
-
) {
|
|
125
|
-
console.warn(
|
|
126
|
-
`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(
|
|
127
|
-
"missing-link-properties",
|
|
128
|
-
)}`,
|
|
129
|
-
props.field,
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
} else if (props.document) {
|
|
133
|
-
if (!("url" in props.document || "id" in props.document)) {
|
|
134
|
-
console.warn(
|
|
135
|
-
`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(
|
|
136
|
-
"missing-link-properties",
|
|
137
|
-
)}`,
|
|
138
|
-
props.document,
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
104
|
const rawAttrs = computed(() => {
|
|
146
105
|
return asLinkAttrs(props.field || props.document, {
|
|
147
106
|
linkResolver: props.linkResolver || options.linkResolver,
|
package/src/types.ts
CHANGED
|
@@ -95,7 +95,7 @@ type PrismicPluginComponentsOptions = {
|
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* An optional map of Rich Text block types to Vue Components. It is used to
|
|
98
|
-
* render
|
|
98
|
+
* render rich text or title fields.
|
|
99
99
|
*
|
|
100
100
|
* @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/rich-text}
|
|
101
101
|
*/
|