@m13v/seo-components 0.8.8 → 0.8.9
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
|
@@ -40,8 +40,10 @@ export function discoverGuides(contentDir?: string): GuideEntry[] {
|
|
|
40
40
|
// e.g. "src/app/(content)/t" -> "/t", "src/app/t" -> "/t"
|
|
41
41
|
const relative = path.relative(appDir, dir);
|
|
42
42
|
const segments = relative
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
? relative
|
|
44
|
+
.split(path.sep)
|
|
45
|
+
.filter((s) => !(s.startsWith("(") && s.endsWith(")")))
|
|
46
|
+
: [];
|
|
45
47
|
const hrefPrefix = "/" + segments.join("/");
|
|
46
48
|
|
|
47
49
|
const guides: GuideEntry[] = allPages
|
package/src/lib/guide-context.ts
CHANGED
|
@@ -19,7 +19,15 @@ export function getGuideContext(
|
|
|
19
19
|
const guide = discoverGuides(dir).find((g) => g.slug === slug);
|
|
20
20
|
if (!guide) return null;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// Derive appDir from contentDir to locate page files by their full href
|
|
23
|
+
const relDir = path.relative(process.cwd(), dir);
|
|
24
|
+
const relParts = relDir.split(path.sep);
|
|
25
|
+
const appIdx = relParts.indexOf("app");
|
|
26
|
+
const appDir =
|
|
27
|
+
appIdx >= 0
|
|
28
|
+
? path.join(process.cwd(), ...relParts.slice(0, appIdx + 1))
|
|
29
|
+
: dir;
|
|
30
|
+
const pagePath = path.join(appDir, guide.href, "page.tsx");
|
|
23
31
|
let rawSource = "";
|
|
24
32
|
try {
|
|
25
33
|
rawSource = fs.readFileSync(pagePath, "utf-8");
|