@m13v/seo-components 0.8.6 → 0.8.8

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.6",
3
+ "version": "0.8.8",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "prepublishOnly": "npm run build:css"
@@ -14,7 +14,10 @@
14
14
  "./components/*": "./src/components/*",
15
15
  "./lib/*": "./src/lib/*",
16
16
  "./server": "./src/server.ts",
17
- "./next": "./src/next.ts",
17
+ "./next": {
18
+ "types": "./src/next.d.ts",
19
+ "default": "./src/next.js"
20
+ },
18
21
  "./styles.css": "./dist/styles.css",
19
22
  "./styles.src.css": "./src/styles.css"
20
23
  },
@@ -19,7 +19,7 @@ function slugify(text: string): string {
19
19
  * This keeps the sidebar ToC clickable without requiring every page
20
20
  * author to add id attributes manually.
21
21
  */
22
- export function HeadingAnchors() {
22
+ export function HeadingAnchors({ children }: { children?: React.ReactNode } = {}) {
23
23
  const pathname = usePathname();
24
24
 
25
25
  useEffect(() => {
@@ -55,5 +55,5 @@ export function HeadingAnchors() {
55
55
  }
56
56
  }, [pathname]);
57
57
 
58
- return null;
58
+ return children ? <>{children}</> : null;
59
59
  }
@@ -25,9 +25,15 @@ export function discoverGuides(contentDir?: string): GuideEntry[] {
25
25
 
26
26
  if (cachedDir === dir && cachedGuides) return cachedGuides;
27
27
 
28
- // Determine which URL prefix these pages live under by
29
- // finding the path segments after src/app (skipping route groups).
30
- const appDir = path.join(process.cwd(), "src/app");
28
+ // Determine the Next.js app directory root from contentDir.
29
+ // e.g. "src/app/t" -> "src/app", "app" -> "app", "src/app/(content)/t" -> "src/app"
30
+ const relDir = path.relative(process.cwd(), dir);
31
+ const relParts = relDir.split(path.sep);
32
+ const appIdx = relParts.indexOf("app");
33
+ const appDir =
34
+ appIdx >= 0
35
+ ? path.join(process.cwd(), ...relParts.slice(0, appIdx + 1))
36
+ : path.join(process.cwd(), "src/app");
31
37
  const allPages = walkPages({ appDir });
32
38
 
33
39
  // Figure out the href prefix from contentDir.
package/src/next.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ export interface WithSeoContentOptions {
4
+ /** Relative path to your content directory. Default: "src/app/t". */
5
+ contentDir?: string;
6
+ }
7
+
8
+ export function withSeoContent(
9
+ config?: NextConfig,
10
+ opts?: WithSeoContentOptions,
11
+ ): NextConfig;
@@ -1,26 +1,20 @@
1
- import type { NextConfig } from "next";
2
-
3
- export interface WithSeoContentOptions {
4
- /** Relative path to your content directory. Default: "src/app/t". */
5
- contentDir?: string;
6
- }
7
-
8
1
  /**
9
2
  * Wrap a Next.js config so the guide-chat API route can read content files
10
3
  * at runtime on Vercel. Adds `outputFileTracingIncludes` for the guide-chat
11
- * endpoint so Next.js's file tracer includes every file under `contentDir`
4
+ * endpoint so Next.js's file tracer includes every page.tsx under `contentDir`
12
5
  * in the serverless function bundle.
13
6
  *
14
- * Usage (next.config.ts):
7
+ * Usage (next.config.ts or next.config.mjs):
15
8
  *
16
9
  * import { withSeoContent } from "@m13v/seo-components/next";
17
10
  * const nextConfig = { ... };
18
11
  * export default withSeoContent(nextConfig, { contentDir: "src/app/t" });
12
+ *
13
+ * @param {import('next').NextConfig} [config]
14
+ * @param {{ contentDir?: string }} [opts]
15
+ * @returns {import('next').NextConfig}
19
16
  */
20
- export function withSeoContent(
21
- config: NextConfig = {},
22
- opts: WithSeoContentOptions = {},
23
- ): NextConfig {
17
+ export function withSeoContent(config = {}, opts = {}) {
24
18
  const contentDir = opts.contentDir ?? "src/app/t";
25
19
  const glob = `./${contentDir}/**/*`;
26
20
  const existing = config.outputFileTracingIncludes ?? {};