@pixelated-tech/components 3.13.14 → 3.13.16
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/components/general/schema.functions.js +114 -0
- package/dist/components/general/schema.js +662 -0
- package/dist/components/general/sitemap.js +74 -31
- package/dist/components/general/utilities.js +38 -0
- package/dist/components/integrations/spotify.components.js +43 -0
- package/dist/components/integrations/spotify.functions.js +111 -0
- package/dist/components/integrations/wordpress.components.js +2 -2
- package/dist/config/pixelated.config.json.enc +1 -1
- package/dist/index.js +7 -13
- package/dist/index.server.js +3 -1
- package/dist/scripts/release.sh +9 -15
- package/dist/scripts/update.sh +45 -8
- package/dist/types/components/general/schema.d.ts +266 -0
- package/dist/types/components/general/schema.d.ts.map +1 -0
- package/dist/types/components/general/schema.functions.d.ts +77 -0
- package/dist/types/components/general/schema.functions.d.ts.map +1 -0
- package/dist/types/components/general/sitemap.d.ts +4 -4
- package/dist/types/components/general/sitemap.d.ts.map +1 -1
- package/dist/types/components/general/utilities.d.ts +2 -0
- package/dist/types/components/general/utilities.d.ts.map +1 -1
- package/dist/types/components/integrations/spotify.components.d.ts +27 -0
- package/dist/types/components/integrations/spotify.components.d.ts.map +1 -0
- package/dist/types/components/integrations/spotify.functions.d.ts +57 -0
- package/dist/types/components/integrations/spotify.functions.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -13
- package/dist/types/index.server.d.ts +3 -1
- package/dist/types/stories/general/schema.stories.d.ts +1 -1
- package/dist/types/stories/general/schema.stories.d.ts.map +1 -1
- package/dist/types/stories/integrations/loremipsum.stories.d.ts +1 -1
- package/dist/types/stories/integrations/schema-podcast.stories.d.ts +45 -0
- package/dist/types/stories/integrations/schema-podcast.stories.d.ts.map +1 -0
- package/dist/types/stories/integrations/spotify.stories.d.ts +19 -0
- package/dist/types/stories/integrations/spotify.stories.d.ts.map +1 -0
- package/dist/types/tests/schema-podcast.test.d.ts +2 -0
- package/dist/types/tests/schema-podcast.test.d.ts.map +1 -0
- package/dist/types/tests/spotify.test.d.ts +2 -0
- package/dist/types/tests/spotify.test.d.ts.map +1 -0
- package/package.json +46 -42
- package/dist/components/general/schema-blogposting.functions.js +0 -44
- package/dist/components/general/schema-blogposting.js +0 -18
- package/dist/components/general/schema-breadcrumb.js +0 -78
- package/dist/components/general/schema-faq.js +0 -38
- package/dist/components/general/schema-localbusiness.js +0 -125
- package/dist/components/general/schema-product.js +0 -51
- package/dist/components/general/schema-recipe.js +0 -58
- package/dist/components/general/schema-review.js +0 -47
- package/dist/components/general/schema-services.js +0 -79
- package/dist/components/general/schema-website.js +0 -148
- package/dist/types/components/general/schema-blogposting.d.ts +0 -10
- package/dist/types/components/general/schema-blogposting.d.ts.map +0 -1
- package/dist/types/components/general/schema-blogposting.functions.d.ts +0 -27
- package/dist/types/components/general/schema-blogposting.functions.d.ts.map +0 -1
- package/dist/types/components/general/schema-breadcrumb.d.ts +0 -14
- package/dist/types/components/general/schema-breadcrumb.d.ts.map +0 -1
- package/dist/types/components/general/schema-faq.d.ts +0 -10
- package/dist/types/components/general/schema-faq.d.ts.map +0 -1
- package/dist/types/components/general/schema-localbusiness.d.ts +0 -53
- package/dist/types/components/general/schema-localbusiness.d.ts.map +0 -1
- package/dist/types/components/general/schema-product.d.ts +0 -38
- package/dist/types/components/general/schema-product.d.ts.map +0 -1
- package/dist/types/components/general/schema-recipe.d.ts +0 -33
- package/dist/types/components/general/schema-recipe.d.ts.map +0 -1
- package/dist/types/components/general/schema-review.d.ts +0 -34
- package/dist/types/components/general/schema-review.d.ts.map +0 -1
- package/dist/types/components/general/schema-services.d.ts +0 -36
- package/dist/types/components/general/schema-services.d.ts.map +0 -1
- package/dist/types/components/general/schema-website.d.ts +0 -40
- package/dist/types/components/general/schema-website.d.ts.map +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { decode } from 'html-entities';
|
|
2
|
+
/**
|
|
3
|
+
* Converts WordPress REST API blog post to schema.org BlogPosting format
|
|
4
|
+
* @param post WordPress blog post
|
|
5
|
+
* @param includeFullContent Whether to include articleBody (true) or just description (false)
|
|
6
|
+
*/
|
|
7
|
+
export function mapWordPressToBlogPosting(post, includeFullContent = false) {
|
|
8
|
+
const cleanContent = (content) => {
|
|
9
|
+
if (!content)
|
|
10
|
+
return '';
|
|
11
|
+
// Strip HTML tags and decode all HTML entities
|
|
12
|
+
const stripped = content.replace(/<[^>]*>/g, '');
|
|
13
|
+
return decode(stripped).replace(/\[…\]/g, '').trim();
|
|
14
|
+
};
|
|
15
|
+
const description = cleanContent(post.excerpt);
|
|
16
|
+
const articleBody = includeFullContent ? cleanContent(post.content || '') : undefined;
|
|
17
|
+
const schema = {
|
|
18
|
+
'@context': 'https://schema.org',
|
|
19
|
+
'@type': 'BlogPosting',
|
|
20
|
+
url: post.URL,
|
|
21
|
+
headline: decode(post.title.replace(/<[^>]*>/g, '')),
|
|
22
|
+
description: description || decode(post.title.replace(/<[^>]*>/g, '')),
|
|
23
|
+
datePublished: post.date,
|
|
24
|
+
image: post.featured_image || post.post_thumbnail?.URL,
|
|
25
|
+
articleSection: Array.isArray(post.categories) && post.categories.length > 0
|
|
26
|
+
? post.categories[0]
|
|
27
|
+
: 'Blog',
|
|
28
|
+
keywords: Array.isArray(post.categories) ? post.categories : [],
|
|
29
|
+
};
|
|
30
|
+
if (articleBody) {
|
|
31
|
+
schema.articleBody = articleBody;
|
|
32
|
+
}
|
|
33
|
+
if (post.modified) {
|
|
34
|
+
schema.dateModified = post.modified;
|
|
35
|
+
}
|
|
36
|
+
if (post.author) {
|
|
37
|
+
schema.author = {
|
|
38
|
+
'@type': 'Person',
|
|
39
|
+
name: post.author.name,
|
|
40
|
+
url: `https://${new URL(post.URL).hostname}/author/${post.author.login}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return schema;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Converts a podcast episode object to schema.org PodcastEpisode format
|
|
47
|
+
* @param episode Podcast episode data
|
|
48
|
+
*/
|
|
49
|
+
export function mapPodcastEpisodeToSchema(episode) {
|
|
50
|
+
const cleanContent = (content) => {
|
|
51
|
+
if (!content)
|
|
52
|
+
return '';
|
|
53
|
+
// Strip HTML tags and decode all HTML entities
|
|
54
|
+
const stripped = content.replace(/<[^>]*>/g, '');
|
|
55
|
+
const decoded = decode(stripped).replace(/\[…\]/g, '').trim();
|
|
56
|
+
// Normalize whitespace: collapse multiple spaces/nbsp into single space
|
|
57
|
+
return decoded.replace(/\s+/g, ' ');
|
|
58
|
+
};
|
|
59
|
+
const description = cleanContent(episode.summary || episode.description);
|
|
60
|
+
const schema = {
|
|
61
|
+
'@context': 'https://schema.org',
|
|
62
|
+
'@type': 'PodcastEpisode',
|
|
63
|
+
url: episode.link,
|
|
64
|
+
name: cleanContent(episode.title),
|
|
65
|
+
description: description || cleanContent(episode.title),
|
|
66
|
+
datePublished: episode.pubDate,
|
|
67
|
+
image: episode.image,
|
|
68
|
+
explicit: episode.explicit,
|
|
69
|
+
};
|
|
70
|
+
if (episode.creator) {
|
|
71
|
+
schema.author = {
|
|
72
|
+
'@type': 'Person',
|
|
73
|
+
name: episode.creator,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (episode.enclosure?.url) {
|
|
77
|
+
schema.audio = {
|
|
78
|
+
'@type': 'AudioObject',
|
|
79
|
+
contentUrl: episode.enclosure.url,
|
|
80
|
+
encodingFormat: episode.enclosure.type || 'audio/mpeg',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (episode.duration) {
|
|
84
|
+
schema.duration = episode.duration;
|
|
85
|
+
}
|
|
86
|
+
if (episode.episode) {
|
|
87
|
+
schema.episodeNumber = episode.episode;
|
|
88
|
+
}
|
|
89
|
+
return schema;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Converts podcast series metadata to schema.org PodcastSeries format
|
|
93
|
+
* @param series Podcast series data from RSS
|
|
94
|
+
*/
|
|
95
|
+
export function mapPodcastSeriesToSchema(series) {
|
|
96
|
+
const normalizeWhitespace = (text) => {
|
|
97
|
+
return text.replace(/\s+/g, ' ').trim();
|
|
98
|
+
};
|
|
99
|
+
const schema = {
|
|
100
|
+
'@context': 'https://schema.org',
|
|
101
|
+
'@type': 'PodcastSeries',
|
|
102
|
+
name: normalizeWhitespace(decode(series.title)),
|
|
103
|
+
description: series.description ? normalizeWhitespace(decode(series.description)) : undefined,
|
|
104
|
+
url: series.link,
|
|
105
|
+
image: series.image,
|
|
106
|
+
};
|
|
107
|
+
if (series.author) {
|
|
108
|
+
schema.author = {
|
|
109
|
+
'@type': 'Person',
|
|
110
|
+
name: series.author,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return schema;
|
|
114
|
+
}
|