@webbio/strapi-plugin-page-builder 0.11.10-platform → 0.11.11-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/dist/package.json +3 -3
- package/dist/server/controllers/index.js +2 -0
- package/dist/server/controllers/sitemap.js +23 -14
- package/dist/server/routes/index.js +11 -0
- package/dist/server/services/index.js +2 -0
- package/dist/server/services/sitemap.js +42 -9
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/controllers/index.ts +2 -0
- package/server/controllers/sitemap.ts +32 -0
- package/server/routes/index.ts +11 -0
- package/server/services/index.ts +2 -0
- package/server/services/sitemap.ts +53 -0
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webbio/strapi-plugin-page-builder",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11-platform",
|
|
4
4
|
"description": "This is the description of the plugin.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"develop": "tsc -p tsconfig.server.json -w",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"aws-sdk": "^2.1528.0",
|
|
33
33
|
"handlebars": "^4.7.8",
|
|
34
34
|
"react-select": "^5.7.4",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"sitemap": "^7.1.1",
|
|
36
|
+
"slugify": "^1.6.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/react": "^18.2.21",
|
|
@@ -8,6 +8,7 @@ const page_type_1 = __importDefault(require("./page-type"));
|
|
|
8
8
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
9
9
|
const template_1 = __importDefault(require("./template"));
|
|
10
10
|
const platform_1 = __importDefault(require("./platform"));
|
|
11
|
+
const sitemap_1 = __importDefault(require("./sitemap"));
|
|
11
12
|
const private_content_1 = __importDefault(require("./private-content"));
|
|
12
13
|
exports.default = {
|
|
13
14
|
page: page_1.default,
|
|
@@ -15,5 +16,6 @@ exports.default = {
|
|
|
15
16
|
'collection-types': collection_types_1.default,
|
|
16
17
|
template: template_1.default,
|
|
17
18
|
platform: platform_1.default,
|
|
19
|
+
sitemap: sitemap_1.default,
|
|
18
20
|
'private-content': private_content_1.default
|
|
19
21
|
};
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const utils_1 = require("@strapi/utils");
|
|
4
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
5
5
|
exports.default = {
|
|
6
6
|
async generate(ctx) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
ctx.set('Content-Type', 'text/xml');
|
|
10
|
+
const domain = (_a = ctx.query) === null || _a === void 0 ? void 0 : _a.domain;
|
|
11
|
+
if (domain == null) {
|
|
12
|
+
return ctx.badRequest('Domain is required.');
|
|
13
|
+
}
|
|
14
|
+
const platform = await strapi.query(constants_1.PLATFORM_UID).findOne({
|
|
15
|
+
select: ['domain'],
|
|
16
|
+
where: {
|
|
17
|
+
domain
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (platform == null) {
|
|
21
|
+
return ctx.notFound('No platform found for specified domain.');
|
|
22
|
+
}
|
|
23
|
+
return strapi.service('plugin::page-builder.sitemap').generateSitemap(domain);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new utils_1.errors.ApplicationError('Unknown error while generating the sitemap.');
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
29
|
};
|
|
@@ -97,6 +97,17 @@ const routes = {
|
|
|
97
97
|
handler: 'platform.findPageTypesByPlatform'
|
|
98
98
|
}
|
|
99
99
|
]
|
|
100
|
+
},
|
|
101
|
+
sitemap: {
|
|
102
|
+
type: 'content-api',
|
|
103
|
+
prefix: undefined,
|
|
104
|
+
routes: [
|
|
105
|
+
{
|
|
106
|
+
method: 'GET',
|
|
107
|
+
path: '/sitemap',
|
|
108
|
+
handler: 'sitemap.generate'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
100
111
|
}
|
|
101
112
|
};
|
|
102
113
|
exports.default = routes;
|
|
@@ -9,6 +9,7 @@ const page_type_1 = __importDefault(require("./page-type"));
|
|
|
9
9
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
10
10
|
const template_1 = __importDefault(require("./template"));
|
|
11
11
|
const platform_1 = __importDefault(require("./platform"));
|
|
12
|
+
const sitemap_1 = __importDefault(require("./sitemap"));
|
|
12
13
|
const email_1 = __importDefault(require("./email"));
|
|
13
14
|
const private_content_1 = __importDefault(require("./private-content"));
|
|
14
15
|
exports.default = {
|
|
@@ -18,6 +19,7 @@ exports.default = {
|
|
|
18
19
|
'collection-types': collection_types_1.default,
|
|
19
20
|
template: template_1.default,
|
|
20
21
|
platform: platform_1.default,
|
|
22
|
+
sitemap: sitemap_1.default,
|
|
21
23
|
email: email_1.default,
|
|
22
24
|
'private-content': private_content_1.default
|
|
23
25
|
};
|
|
@@ -1,17 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sitemap_1 = require("sitemap");
|
|
4
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
3
5
|
exports.default = {
|
|
4
6
|
async generateSitemap(domain) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
try {
|
|
8
|
+
const entities = await strapi.query(constants_1.PAGE_UID).findMany({
|
|
9
|
+
select: ['path', 'updatedAt'],
|
|
10
|
+
filters: {
|
|
11
|
+
$and: [
|
|
12
|
+
{
|
|
13
|
+
platform: {
|
|
14
|
+
domain
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: {
|
|
19
|
+
$notNull: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
publishedAt: {
|
|
24
|
+
$notNull: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
12
28
|
}
|
|
29
|
+
});
|
|
30
|
+
const sitemapStream = new sitemap_1.SitemapStream();
|
|
31
|
+
for (const entity of entities) {
|
|
32
|
+
const { path, updatedAt } = entity;
|
|
33
|
+
sitemapStream.write({
|
|
34
|
+
url: `${domain}${path}`,
|
|
35
|
+
changefreq: 'always',
|
|
36
|
+
lastmod: updatedAt,
|
|
37
|
+
priority: 1
|
|
38
|
+
});
|
|
13
39
|
}
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
sitemapStream.end();
|
|
41
|
+
const sitemapPromise = await (0, sitemap_1.streamToPromise)(sitemapStream);
|
|
42
|
+
const sitemap = sitemapPromise.toString();
|
|
43
|
+
return sitemap;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error(error);
|
|
47
|
+
throw new Error(`Error generating sitemap for domain ${domain}`);
|
|
48
|
+
}
|
|
16
49
|
}
|
|
17
50
|
};
|