@easy-web/seo 1.2.1 → 1.2.3
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 +2 -2
- package/src/components/SeoHead.astro +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-web/seo",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared SEO primitives for @easy-web/* consumer instances — Astro integration wrapping @astrojs/sitemap with i18n hreflang, dynamic robots.txt route with noIndex mode, and <SeoHead> component (canonical, OpenGraph, Twitter Cards, hreflang, theme-color, manifest).",
|
|
6
6
|
"keywords": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@astrojs/sitemap": "^3.7.3",
|
|
35
|
-
"@easy-web/i18n": "1.2.
|
|
35
|
+
"@easy-web/i18n": "1.2.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"astro": "^6.4.0",
|
|
@@ -54,7 +54,16 @@ if (!site) {
|
|
|
54
54
|
// the easyWebSeo() integration.
|
|
55
55
|
const servedStyle: TrailingSlash =
|
|
56
56
|
trailingSlash ?? (process.env.EASY_WEB_SEO_TRAILING_SLASH === 'never' ? 'never' : 'always');
|
|
57
|
-
const
|
|
57
|
+
const servedPath = toServedPath(pathname, servedStyle);
|
|
58
|
+
|
|
59
|
+
// The built 404 documents answer 200 when requested directly, so without this
|
|
60
|
+
// they are ordinary indexable pages whose content happens to say "not found".
|
|
61
|
+
// A self-referencing canonical is omitted for the same reason: it would assert
|
|
62
|
+
// the page is a canonical destination while the body says the opposite.
|
|
63
|
+
const isNotFoundRoute = servedPath.split('/').filter(Boolean).pop() === '404';
|
|
64
|
+
const shouldNoIndex = noIndex || isNotFoundRoute;
|
|
65
|
+
|
|
66
|
+
const canonical = new URL(servedPath, site).href;
|
|
58
67
|
const absoluteOgImage = ogImage ? new URL(ogImage, site).href : undefined;
|
|
59
68
|
// Map locale to OG locale format: 'de' → 'de_DE', 'en' → 'en_US'
|
|
60
69
|
const ogLocale = locale === 'en' ? 'en_US' : locale === 'de' ? 'de_DE' : locale.replace('-', '_');
|
|
@@ -62,8 +71,8 @@ const ogLocaleAlternate = locale === 'en' ? 'de_DE' : 'en_US';
|
|
|
62
71
|
---
|
|
63
72
|
<title>{title}</title>
|
|
64
73
|
{description && <meta name="description" content={description} />}
|
|
65
|
-
<link rel="canonical" href={canonical} />
|
|
66
|
-
{
|
|
74
|
+
{!isNotFoundRoute && <link rel="canonical" href={canonical} />}
|
|
75
|
+
{shouldNoIndex && <meta name="robots" content="noindex, nofollow" />}
|
|
67
76
|
{themeColor && <meta name="theme-color" content={themeColor} />}
|
|
68
77
|
{manifest && <link rel="manifest" href={manifest} />}
|
|
69
78
|
<!-- Open Graph -->
|