@m13v/seo-components 0.8.10 → 0.8.12

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.10",
3
+ "version": "0.8.12",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "prepublishOnly": "npm run build:css"
@@ -28,16 +28,23 @@ export function discoverGuides(contentDir?: string): GuideEntry[] {
28
28
 
29
29
  // Try to load the build-time manifest first (generated by withSeoContent).
30
30
  // This is required on Vercel where fs.readdirSync can't walk source dirs.
31
- const manifestPath = path.join(process.cwd(), ".next", "seo-guides-manifest.json");
31
+ // Check both project root and .next/ for backwards compat.
32
+ const candidates = [
33
+ path.join(process.cwd(), "seo-guides-manifest.json"),
34
+ path.join(process.cwd(), ".next", "seo-guides-manifest.json"),
35
+ ];
32
36
  let manifestPages: PageEntry[] | null = null;
33
- try {
34
- const raw = fs.readFileSync(manifestPath, "utf-8");
35
- const manifest = JSON.parse(raw);
36
- if (Array.isArray(manifest.pages)) {
37
- manifestPages = manifest.pages;
37
+ for (const manifestPath of candidates) {
38
+ try {
39
+ const raw = fs.readFileSync(manifestPath, "utf-8");
40
+ const manifest = JSON.parse(raw);
41
+ if (Array.isArray(manifest.pages)) {
42
+ manifestPages = manifest.pages;
43
+ break;
44
+ }
45
+ } catch {
46
+ // Try next candidate
38
47
  }
39
- } catch {
40
- // No manifest; fall back to filesystem walking
41
48
  }
42
49
 
43
50
  let guides: GuideEntry[];
@@ -63,9 +70,9 @@ export function discoverGuides(contentDir?: string): GuideEntry[] {
63
70
  : [];
64
71
  const hrefPrefix = "/" + segments.join("/");
65
72
 
73
+ const filterPrefix = hrefPrefix === "/" ? "/" : hrefPrefix + "/";
66
74
  guides = allPages
67
- .filter((p) => p.href.startsWith(hrefPrefix + "/") || p.href === hrefPrefix)
68
- .filter((p) => p.href !== hrefPrefix)
75
+ .filter((p) => p.href.startsWith(filterPrefix) && p.href !== hrefPrefix)
69
76
  .map(pageToGuide);
70
77
  }
71
78
 
package/src/next.js CHANGED
@@ -29,12 +29,12 @@ export function withSeoContent(config = {}, opts = {}) {
29
29
  const contentGlob = `./${contentDir}/**/*`;
30
30
  const existing = config.outputFileTracingIncludes ?? {};
31
31
 
32
- // Build a manifest at config evaluation time (runs during `next build`)
32
+ // Build a manifest at config evaluation time (runs during `next build`).
33
+ // Write to project root so outputFileTracingIncludes can find it reliably.
34
+ const manifestFile = "seo-guides-manifest.json";
33
35
  try {
34
36
  const manifest = buildManifest(contentDir);
35
- mkdirSync(join(process.cwd(), ".next"), { recursive: true });
36
- const manifestPath = join(process.cwd(), ".next", "seo-guides-manifest.json");
37
- writeFileSync(manifestPath, JSON.stringify(manifest));
37
+ writeFileSync(join(process.cwd(), manifestFile), JSON.stringify(manifest));
38
38
  } catch (e) {
39
39
  // Non-fatal: the runtime will fall back to filesystem walking
40
40
  }
@@ -43,8 +43,8 @@ export function withSeoContent(config = {}, opts = {}) {
43
43
  ...config,
44
44
  outputFileTracingIncludes: {
45
45
  ...existing,
46
- "/api/guide-chat": [contentGlob, "./.next/seo-guides-manifest.json"],
47
- "/api/guide-chat/route": [contentGlob, "./.next/seo-guides-manifest.json"],
46
+ "/api/guide-chat": [contentGlob, `./${manifestFile}`],
47
+ "/api/guide-chat/route": [contentGlob, `./${manifestFile}`],
48
48
  },
49
49
  };
50
50
  }
@@ -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) =>