@webbio/strapi-plugin-page-builder 0.11.16-platform → 0.11.17-platform
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/package.json
CHANGED
|
@@ -4,28 +4,11 @@ import { PAGE_UID } from '../../shared/utils/constants';
|
|
|
4
4
|
export default {
|
|
5
5
|
async generateSitemap(domain: string): Promise<string> {
|
|
6
6
|
try {
|
|
7
|
-
const entities: Array<{ path: string; updatedAt: string }> = await
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
platform: {
|
|
13
|
-
domain
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
path: {
|
|
18
|
-
$notNull: true
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
publishedAt: {
|
|
23
|
-
$notNull: true
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
});
|
|
7
|
+
const entities: Array<{ path: string; updatedAt: string }> = await this.fetchPages(domain);
|
|
8
|
+
|
|
9
|
+
if (entities.length === 0) {
|
|
10
|
+
throw new Error('Cannot generate a sitemap with 0 pages');
|
|
11
|
+
}
|
|
29
12
|
|
|
30
13
|
const sitemapStream = new SitemapStream();
|
|
31
14
|
|
|
@@ -50,5 +33,51 @@ export default {
|
|
|
50
33
|
console.error(error);
|
|
51
34
|
throw new Error(`Error generating sitemap for domain ${domain}`);
|
|
52
35
|
}
|
|
36
|
+
},
|
|
37
|
+
async fetchPages(domain: string): Promise<Array<{ path: string; updatedAt: string }>> {
|
|
38
|
+
const entities: Array<{ path: string; updatedAt: string }> = await strapi.query(PAGE_UID).findMany({
|
|
39
|
+
select: ['path', 'updatedAt'],
|
|
40
|
+
where: {
|
|
41
|
+
$and: [
|
|
42
|
+
{
|
|
43
|
+
platform: {
|
|
44
|
+
domain: {
|
|
45
|
+
$eq: domain
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
path: {
|
|
51
|
+
$notNull: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
publishedAt: {
|
|
56
|
+
$notNull: true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
$or: [
|
|
61
|
+
{
|
|
62
|
+
seo: {
|
|
63
|
+
metaRobots: {
|
|
64
|
+
$notContainsi: 'noindex'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
seo: {
|
|
70
|
+
metaRobots: {
|
|
71
|
+
$null: true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return entities;
|
|
53
82
|
}
|
|
54
83
|
};
|