@seip/blue-bird 0.4.5 → 0.4.7
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/.env_example +26 -25
- package/AGENTS.md +199 -199
- package/README.md +79 -79
- package/backend/index.js +13 -13
- package/backend/routes/frontend.js +41 -41
- package/backend/routes/seo.js +39 -39
- package/core/app.js +330 -325
- package/core/auth.js +142 -114
- package/core/cache.js +44 -44
- package/core/cli/component.js +42 -42
- package/core/cli/init.js +119 -118
- package/core/cli/react.js +435 -435
- package/core/cli/route.js +42 -42
- package/core/config.js +51 -47
- package/core/debug.js +248 -248
- package/core/logger.js +100 -100
- package/core/middleware.js +27 -27
- package/core/router.js +333 -333
- package/core/seo.js +95 -100
- package/core/template.js +478 -462
- package/core/upload.js +77 -76
- package/core/validate.js +380 -380
- package/frontend/index.html +31 -26
- package/frontend/landing.html +70 -69
- package/frontend/resources/css/tailwind.css +17 -17
- package/frontend/resources/js/App.jsx +70 -70
- package/frontend/resources/js/Main.jsx +18 -18
- package/frontend/resources/js/blue-bird/components/Button.jsx +67 -67
- package/frontend/resources/js/blue-bird/components/Card.jsx +18 -18
- package/frontend/resources/js/blue-bird/components/DataTable.jsx +126 -126
- package/frontend/resources/js/blue-bird/components/Input.jsx +21 -21
- package/frontend/resources/js/blue-bird/components/Label.jsx +12 -12
- package/frontend/resources/js/blue-bird/components/LanguageButton.jsx +23 -23
- package/frontend/resources/js/blue-bird/components/Link.jsx +15 -15
- package/frontend/resources/js/blue-bird/components/Modal.jsx +27 -27
- package/frontend/resources/js/blue-bird/components/Skeleton.jsx +44 -44
- package/frontend/resources/js/blue-bird/components/Translate.jsx +12 -12
- package/frontend/resources/js/blue-bird/components/Typography.jsx +69 -69
- package/frontend/resources/js/blue-bird/contexts/LanguageContext.jsx +41 -41
- package/frontend/resources/js/blue-bird/contexts/SPAContext.jsx +239 -237
- package/frontend/resources/js/blue-bird/contexts/SnackbarContext.jsx +38 -38
- package/frontend/resources/js/blue-bird/contexts/ThemeContext.jsx +49 -49
- package/frontend/resources/js/blue-bird/locales/en.json +47 -47
- package/frontend/resources/js/blue-bird/locales/es.json +47 -47
- package/frontend/resources/js/components/Header.jsx +55 -55
- package/frontend/resources/js/pages/About.jsx +31 -31
- package/frontend/resources/js/pages/Home.jsx +82 -82
- package/package.json +1 -1
- package/vite.config.js +22 -22
- package/frontend/public/robots.txt +0 -0
- package/frontend/public/sitemap.xml +0 -0
package/core/seo.js
CHANGED
|
@@ -1,100 +1,95 @@
|
|
|
1
|
-
import Config from "./config.js";
|
|
2
|
-
|
|
3
|
-
const props = Config.props();
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* SEO utility class for generating sitemaps and robots.txt files.
|
|
7
|
-
*/
|
|
8
|
-
class SEO {
|
|
9
|
-
/**
|
|
10
|
-
* Generates a sitemap.xml string based on a provided routes configuration.
|
|
11
|
-
* Supports multilingual routes with language-prefixed paths.
|
|
12
|
-
*
|
|
13
|
-
* @static
|
|
14
|
-
* @method generateSitemap
|
|
15
|
-
* @param {Array<Object>} routesConfig - The SEO routes configuration array.
|
|
16
|
-
* @param {Object} [options={}] - Configuration options.
|
|
17
|
-
* @param {Array<string>} [options.languages=[]] - List of supported languages.
|
|
18
|
-
* @param {string} [options.defaultLanguage="en"] - The default language.
|
|
19
|
-
* @returns {string} The generated XML sitemap.
|
|
20
|
-
*/
|
|
21
|
-
static generateSitemap(routesConfig, options = {}) {
|
|
22
|
-
const { languages = [], defaultLanguage = "en" } = options;
|
|
23
|
-
const host = (props.
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
expressRouter.get("/
|
|
89
|
-
res.header("Content-Type", "
|
|
90
|
-
res.send(this.
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default SEO;
|
|
1
|
+
import Config from "./config.js";
|
|
2
|
+
|
|
3
|
+
const props = Config.props();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SEO utility class for generating sitemaps and robots.txt files.
|
|
7
|
+
*/
|
|
8
|
+
class SEO {
|
|
9
|
+
/**
|
|
10
|
+
* Generates a sitemap.xml string based on a provided routes configuration.
|
|
11
|
+
* Supports multilingual routes with language-prefixed paths.
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @method generateSitemap
|
|
15
|
+
* @param {Array<Object>} routesConfig - The SEO routes configuration array.
|
|
16
|
+
* @param {Object} [options={}] - Configuration options.
|
|
17
|
+
* @param {Array<string>} [options.languages=[]] - List of supported languages.
|
|
18
|
+
* @param {string} [options.defaultLanguage="en"] - The default language.
|
|
19
|
+
* @returns {string} The generated XML sitemap.
|
|
20
|
+
*/
|
|
21
|
+
static generateSitemap(routesConfig, options = {}) {
|
|
22
|
+
const { languages = [], defaultLanguage = "en" } = options;
|
|
23
|
+
const host = (props.appUrl || `${props.host}:${props.port}`).replace(/\/$/, "");
|
|
24
|
+
const baseUrl = `${host}`;
|
|
25
|
+
const date = new Date().toISOString().split("T")[0];
|
|
26
|
+
|
|
27
|
+
let xml = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
28
|
+
xml +=
|
|
29
|
+
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">';
|
|
30
|
+
|
|
31
|
+
routesConfig.forEach((route) => {
|
|
32
|
+
const { path: routePath } = route;
|
|
33
|
+
|
|
34
|
+
xml += `
|
|
35
|
+
<url>
|
|
36
|
+
<loc>${baseUrl}${routePath}</loc>
|
|
37
|
+
<lastmod>${date}</lastmod>
|
|
38
|
+
<priority>${routePath === "/" ? "1.0" : "0.8"}</priority>
|
|
39
|
+
</url>`;
|
|
40
|
+
if (languages.length > 0) {
|
|
41
|
+
languages.forEach((lang) => {
|
|
42
|
+
const langPath = `/${lang}${routePath === "/" ? "" : routePath}`;
|
|
43
|
+
xml += `
|
|
44
|
+
<url>
|
|
45
|
+
<loc>${baseUrl}${langPath}</loc>
|
|
46
|
+
<lastmod>${date}</lastmod>
|
|
47
|
+
<priority>0.8</priority>
|
|
48
|
+
</url>`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
xml += "\n</urlset>";
|
|
54
|
+
return xml.trim();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Generates a robots.txt string.
|
|
59
|
+
*
|
|
60
|
+
* @static
|
|
61
|
+
* @method generateRobots
|
|
62
|
+
* @returns {string} The generated robots.txt content.
|
|
63
|
+
*/
|
|
64
|
+
static generateRobots() {
|
|
65
|
+
const host = (props.appUrl || "http://localhost").replace(/\/$/, "");
|
|
66
|
+
return `User-agent: *
|
|
67
|
+
Allow: /
|
|
68
|
+
|
|
69
|
+
Sitemap: ${host}/sitemap.xml
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Registers sitemap.xml and robots.txt routes in the given Express router.
|
|
75
|
+
*
|
|
76
|
+
* @static
|
|
77
|
+
* @method registerRoutes
|
|
78
|
+
* @param {import('express').Router} expressRouter - The Express router instance.
|
|
79
|
+
* @param {Array<Object>} routesConfig - The SEO routes configuration array.
|
|
80
|
+
* @param {Object} [options={}] - Configuration options for sitemap generation.
|
|
81
|
+
*/
|
|
82
|
+
static registerRoutes(expressRouter, routesConfig, options = {}) {
|
|
83
|
+
expressRouter.get("/sitemap.xml", (req, res) => {
|
|
84
|
+
res.header("Content-Type", "application/xml");
|
|
85
|
+
res.send(this.generateSitemap(routesConfig, options));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expressRouter.get("/robots.txt", (req, res) => {
|
|
89
|
+
res.header("Content-Type", "text/plain");
|
|
90
|
+
res.send(this.generateRobots());
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default SEO;
|