@unhead/schema-org 0.6.0 → 1.3.8

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/vue.mjs ADDED
@@ -0,0 +1,303 @@
1
+ export { $ as SchemaOrgUnheadPlugin } from './shared/schema-org.02b3dc98.mjs';
2
+ import { useHead } from '@unhead/vue';
3
+ import { defineComponent, ref, computed, unref, h } from 'vue';
4
+ import 'ufo';
5
+ import '@unhead/shared';
6
+
7
+ const schemaAutoImports = [
8
+ "defineAddress",
9
+ "defineAggregateOffer",
10
+ "defineAggregateRating",
11
+ "defineArticle",
12
+ "defineBook",
13
+ "defineBookEdition",
14
+ "defineBreadcrumb",
15
+ "defineComment",
16
+ "defineCourse",
17
+ "defineEvent",
18
+ "defineHowTo",
19
+ "defineHowToStep",
20
+ "defineImage",
21
+ "defineItemList",
22
+ "defineJobPosting",
23
+ "defineListItem",
24
+ "defineLocalBusiness",
25
+ "defineMovie",
26
+ "defineOffer",
27
+ "defineOpeningHours",
28
+ "defineOrganization",
29
+ "definePerson",
30
+ "definePlace",
31
+ "defineProduct",
32
+ "defineQuestion",
33
+ "defineReadAction",
34
+ "defineRecipe",
35
+ "defineReview",
36
+ "defineSearchAction",
37
+ "defineSoftwareApp",
38
+ "defineVideo",
39
+ "defineVirtualLocation",
40
+ "defineWebPage",
41
+ "defineWebSite",
42
+ "useSchemaOrg"
43
+ ];
44
+ const schemaOrgAutoImports = [
45
+ {
46
+ from: "@unhead/schema-org/vue",
47
+ imports: schemaAutoImports
48
+ }
49
+ ];
50
+ const schemaOrgComponents = [
51
+ "SchemaOrgDebug",
52
+ "SchemaOrgArticle",
53
+ "SchemaOrgBreadcrumb",
54
+ "SchemaOrgComment",
55
+ "SchemaOrgEvent",
56
+ "SchemaOrgHowTo",
57
+ "SchemaOrgImage",
58
+ "SchemaOrgJobPosting",
59
+ "SchemaOrgLocalBusiness",
60
+ "SchemaOrgOrganization",
61
+ "SchemaOrgPerson",
62
+ "SchemaOrgProduct",
63
+ "SchemaOrgQuestion",
64
+ "SchemaOrgRecipe",
65
+ "SchemaOrgReview",
66
+ "SchemaOrgVideo",
67
+ "SchemaOrgWebPage",
68
+ "SchemaOrgWebSite",
69
+ "SchemaOrgMovie",
70
+ "SchemaOrgCourse",
71
+ "SchemaOrgItemList",
72
+ "SchemaOrgBook",
73
+ "SchemaOrgSoftwareApp"
74
+ ];
75
+ function SchemaOrgResolver(options = {}) {
76
+ const { prefix = "" } = options;
77
+ return {
78
+ type: "component",
79
+ resolve: (name) => {
80
+ if (name.startsWith(prefix)) {
81
+ const componentName = name.substring(prefix.length);
82
+ if (schemaOrgComponents.includes(componentName)) {
83
+ return {
84
+ name: componentName,
85
+ from: "@unhead/schema-org/vue"
86
+ };
87
+ }
88
+ }
89
+ }
90
+ };
91
+ }
92
+
93
+ function provideResolver(input, resolver) {
94
+ if (!input)
95
+ input = {};
96
+ input._resolver = resolver;
97
+ return input;
98
+ }
99
+ function defineAddress(input) {
100
+ return provideResolver(input, "address");
101
+ }
102
+ function defineAggregateOffer(input) {
103
+ return provideResolver(input, "aggregateOffer");
104
+ }
105
+ function defineAggregateRating(input) {
106
+ return provideResolver(input, "aggregateRating");
107
+ }
108
+ function defineArticle(input) {
109
+ return provideResolver(input, "article");
110
+ }
111
+ function defineBreadcrumb(input) {
112
+ return provideResolver(input, "breadcrumb");
113
+ }
114
+ function defineComment(input) {
115
+ return provideResolver(input, "comment");
116
+ }
117
+ function defineEvent(input) {
118
+ return provideResolver(input, "event");
119
+ }
120
+ function defineVirtualLocation(input) {
121
+ return provideResolver(input, "virtualLocation");
122
+ }
123
+ function definePlace(input) {
124
+ return provideResolver(input, "place");
125
+ }
126
+ function defineHowTo(input) {
127
+ return provideResolver(input, "howTo");
128
+ }
129
+ function defineHowToStep(input) {
130
+ return provideResolver(input, "howToStep");
131
+ }
132
+ function defineImage(input) {
133
+ return provideResolver(input, "image");
134
+ }
135
+ function defineJobPosting(input) {
136
+ return provideResolver(input, "jobPosting");
137
+ }
138
+ function defineLocalBusiness(input) {
139
+ return provideResolver(input, "localBusiness");
140
+ }
141
+ function defineOffer(input) {
142
+ return provideResolver(input, "offer");
143
+ }
144
+ function defineOpeningHours(input) {
145
+ return provideResolver(input, "openingHours");
146
+ }
147
+ function defineOrganization(input) {
148
+ return provideResolver(input, "organization");
149
+ }
150
+ function definePerson(input) {
151
+ return provideResolver(input, "person");
152
+ }
153
+ function defineProduct(input) {
154
+ return provideResolver(input, "product");
155
+ }
156
+ function defineQuestion(input) {
157
+ return provideResolver(input, "question");
158
+ }
159
+ function defineRecipe(input) {
160
+ return provideResolver(input, "recipe");
161
+ }
162
+ function defineReview(input) {
163
+ return provideResolver(input, "review");
164
+ }
165
+ function defineVideo(input) {
166
+ return provideResolver(input, "video");
167
+ }
168
+ function defineWebPage(input) {
169
+ return provideResolver(input, "webPage");
170
+ }
171
+ function defineWebSite(input) {
172
+ return provideResolver(input, "webSite");
173
+ }
174
+ function defineBook(input) {
175
+ return provideResolver(input, "book");
176
+ }
177
+ function defineCourse(input) {
178
+ return provideResolver(input, "course");
179
+ }
180
+ function defineItemList(input) {
181
+ return provideResolver(input, "itemList");
182
+ }
183
+ function defineListItem(input) {
184
+ return provideResolver(input, "listItem");
185
+ }
186
+ function defineMovie(input) {
187
+ return provideResolver(input, "movie");
188
+ }
189
+ function defineSearchAction(input) {
190
+ return provideResolver(input, "searchAction");
191
+ }
192
+ function defineReadAction(input) {
193
+ return provideResolver(input, "readAction");
194
+ }
195
+ function defineSoftwareApp(input) {
196
+ return provideResolver(input, "softwareApp");
197
+ }
198
+ function defineBookEdition(input) {
199
+ return provideResolver(input, "bookEdition");
200
+ }
201
+ let isSPA = null;
202
+ function useSchemaOrg(input) {
203
+ if (process.env.NODE_ENV !== "development" && typeof window !== "undefined") {
204
+ if (isSPA === null && !window.document.querySelector("#schema-org-graph"))
205
+ isSPA = true;
206
+ if (!isSPA)
207
+ return;
208
+ }
209
+ return useHead({
210
+ script: [
211
+ {
212
+ type: "application/ld+json",
213
+ id: "schema-org-graph",
214
+ key: "schema-org-graph",
215
+ // @ts-expect-error runtime type
216
+ nodes: input
217
+ }
218
+ ]
219
+ }, { mode: isSPA ? void 0 : "server" });
220
+ }
221
+
222
+ function shallowVNodesToText(nodes) {
223
+ let text = "";
224
+ for (const node of nodes) {
225
+ if (typeof node.children === "string")
226
+ text += node.children.trim();
227
+ }
228
+ return text;
229
+ }
230
+ function fixKey(s) {
231
+ let key = s.replace(/-./g, (x) => x[1].toUpperCase());
232
+ if (key === "type" || key === "id")
233
+ key = `@${key}`;
234
+ return key;
235
+ }
236
+ function ignoreKey(s) {
237
+ if (s.startsWith("aria-") || s.startsWith("data-"))
238
+ return false;
239
+ return ["class", "style"].includes(s);
240
+ }
241
+ function defineSchemaOrgComponent(name, defineFn) {
242
+ return defineComponent({
243
+ name,
244
+ props: {
245
+ as: String
246
+ },
247
+ setup(props, { slots, attrs }) {
248
+ const node = ref(null);
249
+ const nodePartial = computed(() => {
250
+ const val = {};
251
+ Object.entries(unref(attrs)).forEach(([key, value]) => {
252
+ if (!ignoreKey(key)) {
253
+ val[fixKey(key)] = unref(value);
254
+ }
255
+ });
256
+ if (!node.value) {
257
+ for (const [key, slot] of Object.entries(slots)) {
258
+ if (!slot || key === "default")
259
+ continue;
260
+ val[fixKey(key)] = shallowVNodesToText(slot(props));
261
+ }
262
+ }
263
+ return val;
264
+ });
265
+ if (defineFn) {
266
+ useSchemaOrg(defineFn(unref(nodePartial)));
267
+ }
268
+ return () => {
269
+ const data = unref(nodePartial);
270
+ if (!slots.default)
271
+ return null;
272
+ const childSlots = [];
273
+ if (slots.default)
274
+ childSlots.push(slots.default(data));
275
+ return h(props.as || "div", {}, childSlots);
276
+ };
277
+ }
278
+ });
279
+ }
280
+ const SchemaOrgArticle = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgArticle", defineArticle);
281
+ const SchemaOrgBreadcrumb = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgBreadcrumb", defineBreadcrumb);
282
+ const SchemaOrgComment = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgComment", defineComment);
283
+ const SchemaOrgEvent = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgEvent", defineEvent);
284
+ const SchemaOrgHowTo = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgHowTo", defineHowTo);
285
+ const SchemaOrgImage = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgImage", defineImage);
286
+ const SchemaOrgJobPosting = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgJobPosting", defineJobPosting);
287
+ const SchemaOrgLocalBusiness = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgLocalBusiness", defineLocalBusiness);
288
+ const SchemaOrgOrganization = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgOrganization", defineOrganization);
289
+ const SchemaOrgPerson = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgPerson", definePerson);
290
+ const SchemaOrgProduct = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgProduct", defineProduct);
291
+ const SchemaOrgQuestion = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgQuestion", defineQuestion);
292
+ const SchemaOrgRecipe = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgRecipe", defineRecipe);
293
+ const SchemaOrgReview = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgReview", defineReview);
294
+ const SchemaOrgVideo = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgVideo", defineVideo);
295
+ const SchemaOrgWebPage = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgWebPage", defineWebPage);
296
+ const SchemaOrgWebSite = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgWebSite", defineWebSite);
297
+ const SchemaOrgMovie = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgMovie", defineMovie);
298
+ const SchemaOrgCourse = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgCourse", defineCourse);
299
+ const SchemaOrgItemList = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgItemList", defineItemList);
300
+ const SchemaOrgBook = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgBook", defineBook);
301
+ const SchemaOrgSoftwareApp = /* @__PURE__ */ defineSchemaOrgComponent("SchemaOrgSoftwareApp", defineSoftwareApp);
302
+
303
+ export { SchemaOrgArticle, SchemaOrgBook, SchemaOrgBreadcrumb, SchemaOrgComment, SchemaOrgCourse, SchemaOrgEvent, SchemaOrgHowTo, SchemaOrgImage, SchemaOrgItemList, SchemaOrgJobPosting, SchemaOrgLocalBusiness, SchemaOrgMovie, SchemaOrgOrganization, SchemaOrgPerson, SchemaOrgProduct, SchemaOrgQuestion, SchemaOrgRecipe, SchemaOrgResolver, SchemaOrgReview, SchemaOrgSoftwareApp, SchemaOrgVideo, SchemaOrgWebPage, SchemaOrgWebSite, defineAddress, defineAggregateOffer, defineAggregateRating, defineArticle, defineBook, defineBookEdition, defineBreadcrumb, defineComment, defineCourse, defineEvent, defineHowTo, defineHowToStep, defineImage, defineItemList, defineJobPosting, defineListItem, defineLocalBusiness, defineMovie, defineOffer, defineOpeningHours, defineOrganization, definePerson, definePlace, defineProduct, defineQuestion, defineReadAction, defineRecipe, defineReview, defineSchemaOrgComponent, defineSearchAction, defineSoftwareApp, defineVideo, defineVirtualLocation, defineWebPage, defineWebSite, schemaAutoImports, schemaOrgAutoImports, schemaOrgComponents, useSchemaOrg };
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@unhead/schema-org",
3
- "version": "0.6.0",
4
- "description": "Node Schema.org for Simple and Automated Google Rich Results",
3
+ "version": "1.3.8",
4
+ "description": "Unhead Schema.org for Simple and Automated Google Rich Results",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
8
- "homepage": "https://github.com/harlan-zw/@unhead/schema-org#readme",
8
+ "homepage": "https://unhead.unjs.io",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/harlan-zw/@unhead/schema-org.git"
11
+ "url": "git+https://github.com/unjs/unhead.git",
12
+ "directory": "packages/schema-org"
12
13
  },
13
14
  "bugs": {
14
- "url": "https://github.com/harlan-zw/@unhead/schema-org/issues"
15
+ "url": "https://github.com/unjs/unhead/issues"
15
16
  },
16
17
  "keywords": [
17
18
  "schema.org",
@@ -22,8 +23,13 @@
22
23
  "exports": {
23
24
  ".": {
24
25
  "types": "./dist/index.d.ts",
25
- "require": "./dist/index.cjs",
26
- "import": "./dist/index.mjs"
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.cjs"
28
+ },
29
+ "./vue": {
30
+ "types": "./dist/vue.d.ts",
31
+ "import": "./dist/vue.mjs",
32
+ "require": "./dist/vue.cjs"
27
33
  }
28
34
  },
29
35
  "main": "dist/index.cjs",
@@ -33,13 +39,19 @@
33
39
  "dist"
34
40
  ],
35
41
  "peerDependencies": {
36
- "unhead": ">=1.1.9"
42
+ "unhead": ">=1.3.5",
43
+ "@unhead/shared": "1.3.8"
37
44
  },
38
45
  "dependencies": {
39
- "ufo": "^1.1.2"
46
+ "ufo": "^1.3.0"
40
47
  },
41
48
  "devDependencies": {
42
- "unhead": "^1.1.27"
49
+ "unplugin-vue-components": "^0.25.1",
50
+ "vue": "^3.3.4",
51
+ "@unhead/schema": "1.3.8",
52
+ "@unhead/shared": "1.3.8",
53
+ "@unhead/vue": "1.3.8",
54
+ "unhead": "1.3.8"
43
55
  },
44
56
  "scripts": {
45
57
  "build": "unbuild .",