@m13v/seo-components 0.22.0 → 0.22.1

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.22.0",
3
+ "version": "0.22.1",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "bump:consumers": "bash scripts/bump-consumers.sh",
@@ -24,7 +24,11 @@ export function getGuideContext(
24
24
  );
25
25
  if (!guide) return null;
26
26
 
27
- // Derive appDir from contentDir to locate page files by their full href
27
+ // Resolve the page file on disk. `guide.href` is a URL path, which has
28
+ // Next.js route-group segments like `(content)` stripped out, so we cannot
29
+ // just join `appDir + href`. Instead, compute the URL prefix that `dir`
30
+ // maps to, strip it from `href`, and append the remainder to `dir` (the
31
+ // real filesystem path the caller passed in).
28
32
  const relDir = path.relative(process.cwd(), dir);
29
33
  const relParts = relDir.split(path.sep);
30
34
  const appIdx = relParts.indexOf("app");
@@ -32,7 +36,20 @@ export function getGuideContext(
32
36
  appIdx >= 0
33
37
  ? path.join(process.cwd(), ...relParts.slice(0, appIdx + 1))
34
38
  : dir;
35
- const pagePath = path.join(appDir, guide.href, "page.tsx");
39
+ const relContent = path.relative(appDir, dir);
40
+ const urlSegments = relContent
41
+ ? relContent
42
+ .split(path.sep)
43
+ .filter((s) => !(s.startsWith("(") && s.endsWith(")")))
44
+ : [];
45
+ const urlPrefix = urlSegments.length ? "/" + urlSegments.join("/") : "";
46
+ let relHref = guide.href;
47
+ if (urlPrefix && relHref.startsWith(urlPrefix + "/")) {
48
+ relHref = relHref.slice(urlPrefix.length + 1);
49
+ } else if (relHref.startsWith("/")) {
50
+ relHref = relHref.slice(1);
51
+ }
52
+ const pagePath = path.join(dir, relHref, "page.tsx");
36
53
  let rawSource = "";
37
54
  try {
38
55
  rawSource = fs.readFileSync(pagePath, "utf-8");