@m13v/seo-components 0.8.11 → 0.8.13

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/seo-components",
3
- "version": "0.8.11",
3
+ "version": "0.8.13",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "prepublishOnly": "npm run build:css"
@@ -42,7 +42,9 @@ function onPosthogLoaded(fn: () => void) {
42
42
  /** Derive a slug from any pathname. "/" returns "" (hidden). */
43
43
  function slugFromPath(pathname: string | null): string {
44
44
  if (!pathname || pathname === "/") return "";
45
- return pathname.replace(/^\/+/, "").replace(/\/+$/g, "").replace(/\//g, "-");
45
+ // Return cleaned pathname (e.g. "/solutions/sap" -> "solutions/sap")
46
+ // The server matches by href or last-segment slug.
47
+ return pathname.replace(/^\/+/, "").replace(/\/+$/g, "");
46
48
  }
47
49
 
48
50
  /* ------------------------------------------------------------------ */
@@ -70,9 +70,9 @@ export function discoverGuides(contentDir?: string): GuideEntry[] {
70
70
  : [];
71
71
  const hrefPrefix = "/" + segments.join("/");
72
72
 
73
+ const filterPrefix = hrefPrefix === "/" ? "/" : hrefPrefix + "/";
73
74
  guides = allPages
74
- .filter((p) => p.href.startsWith(hrefPrefix + "/") || p.href === hrefPrefix)
75
- .filter((p) => p.href !== hrefPrefix)
75
+ .filter((p) => p.href.startsWith(filterPrefix) && p.href !== hrefPrefix)
76
76
  .map(pageToGuide);
77
77
  }
78
78
 
@@ -16,7 +16,12 @@ export function getGuideContext(
16
16
  contentDir?: string,
17
17
  ): GuideContext | null {
18
18
  const dir = contentDir ?? path.join(process.cwd(), "src/app/(content)/t");
19
- const guide = discoverGuides(dir).find((g) => g.slug === slug);
19
+ const guides = discoverGuides(dir);
20
+ // Match by last-segment slug or full href path (e.g. "solutions/sap" -> "/solutions/sap")
21
+ const hrefFromSlug = "/" + slug;
22
+ const guide = guides.find(
23
+ (g) => g.slug === slug || g.href === hrefFromSlug,
24
+ );
20
25
  if (!guide) return null;
21
26
 
22
27
  // Derive appDir from contentDir to locate page files by their full href
package/src/next.js CHANGED
@@ -160,8 +160,9 @@ function buildManifest(contentDir) {
160
160
  : [];
161
161
  const hrefPrefix = "/" + segments.join("/");
162
162
 
163
+ const filterPrefix = hrefPrefix === "/" ? "/" : hrefPrefix + "/";
163
164
  const filtered = pages.filter(p =>
164
- (p.href.startsWith(hrefPrefix + "/") || p.href === hrefPrefix) && p.href !== hrefPrefix
165
+ p.href.startsWith(filterPrefix) && p.href !== hrefPrefix
165
166
  );
166
167
 
167
168
  filtered.sort((a, b) =>