@m13v/seo-components 0.12.0 → 0.12.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.12.0",
3
+ "version": "0.12.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",
@@ -1,5 +1,5 @@
1
- import type { PageEntry } from "../lib/walk-pages";
2
- import { groupByCategory, categoryLabel } from "../lib/walk-pages";
1
+ import type { PageEntry } from "../lib/page-entry";
2
+ import { groupByCategory, categoryLabel } from "../lib/page-entry";
3
3
 
4
4
  export interface HtmlSitemapProps {
5
5
  /** All pages discovered via `walkPages()` on the server. */
@@ -0,0 +1,41 @@
1
+ export interface PageSection {
2
+ id: string;
3
+ title: string;
4
+ }
5
+
6
+ export interface PageEntry {
7
+ href: string;
8
+ title: string;
9
+ description: string;
10
+ datePublished?: string;
11
+ sections: PageSection[];
12
+ category: string;
13
+ }
14
+
15
+ export function groupByCategory(pages: PageEntry[]): Map<string, PageEntry[]> {
16
+ const groups = new Map<string, PageEntry[]>();
17
+ for (const page of pages) {
18
+ const cat = page.category || "pages";
19
+ if (!groups.has(cat)) groups.set(cat, []);
20
+ groups.get(cat)!.push(page);
21
+ }
22
+ return groups;
23
+ }
24
+
25
+ export function categoryLabel(category: string): string {
26
+ const labels: Record<string, string> = {
27
+ t: "Guides",
28
+ compare: "Comparisons",
29
+ blog: "Blog",
30
+ "use-case": "Use Cases",
31
+ automate: "Automations",
32
+ alternative: "Alternatives",
33
+ };
34
+ return (
35
+ labels[category] ??
36
+ category
37
+ .split("-")
38
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
39
+ .join(" ")
40
+ );
41
+ }
@@ -1,20 +1,9 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { slugify } from "./slugify";
4
-
5
- export interface PageSection {
6
- id: string;
7
- title: string;
8
- }
9
-
10
- export interface PageEntry {
11
- href: string;
12
- title: string;
13
- description: string;
14
- datePublished?: string;
15
- sections: PageSection[];
16
- category: string;
17
- }
4
+ import type { PageEntry, PageSection } from "./page-entry";
5
+ export { groupByCategory, categoryLabel } from "./page-entry";
6
+ export type { PageEntry, PageSection } from "./page-entry";
18
7
 
19
8
  export interface WalkPagesOptions {
20
9
  /** Absolute path to src/app directory. Defaults to `process.cwd()/src/app`. */
@@ -204,41 +193,3 @@ export function walkPages(opts?: WalkPagesOptions): PageEntry[] {
204
193
  return pages;
205
194
  }
206
195
 
207
- /**
208
- * Groups pages by their category (first URL segment).
209
- * Returns a Map where keys are category names and values are page arrays.
210
- * Categories are auto-labeled from the path segment (e.g. "use-case" becomes "Use Case").
211
- */
212
- export function groupByCategory(
213
- pages: PageEntry[],
214
- ): Map<string, PageEntry[]> {
215
- const groups = new Map<string, PageEntry[]>();
216
- for (const page of pages) {
217
- const cat = page.category || "pages";
218
- if (!groups.has(cat)) groups.set(cat, []);
219
- groups.get(cat)!.push(page);
220
- }
221
- return groups;
222
- }
223
-
224
- /**
225
- * Converts a category slug to a display label.
226
- * "t" -> "Guides", "use-case" -> "Use Cases", "compare" -> "Comparisons", etc.
227
- */
228
- export function categoryLabel(category: string): string {
229
- const labels: Record<string, string> = {
230
- t: "Guides",
231
- compare: "Comparisons",
232
- blog: "Blog",
233
- "use-case": "Use Cases",
234
- automate: "Automations",
235
- alternative: "Alternatives",
236
- };
237
- return (
238
- labels[category] ??
239
- category
240
- .split("-")
241
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
242
- .join(" ")
243
- );
244
- }