Skip to content

Commit 688bd53

Browse files
committed
feature(@repo/netlogo-docs): add filtering routes via glob patterns
1 parent f1197bd commit 688bd53

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/netlogo-docs/src/helpers/routes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type TemplateRenderer from "@repo/template";
22
import type { PageResult } from "@repo/template";
33
import fs from "fs/promises";
4+
import { minimatch } from "minimatch";
45
import path from "path";
56
import { toSlug } from "./slugify";
67

@@ -32,3 +33,11 @@ export async function getRoutes(baseUrl: string = "/"): Promise<Array<string> |
3233
.map((route) => (route.startsWith("/") ? route.slice(1) : route))
3334
.map((route) => baseUrl + route);
3435
}
36+
37+
export async function getRoutesSubset(
38+
patterns: Array<string>,
39+
baseUrl: string = "/",
40+
): Promise<Array<string>> {
41+
const routes = await getRoutes(baseUrl);
42+
return routes.filter((route) => patterns.some((pattern) => minimatch(route, pattern)));
43+
}

packages/netlogo-docs/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"outDir": "./dist/esm",
88
"declaration": true,
99
"declarationDir": "./dist/types",
10-
"esModuleInterop": true
10+
"rootDir": "./src",
11+
"esModuleInterop": true,
12+
"types": ["node"]
1113
},
1214
"include": ["src"],
1315
"exclude": ["dist", "build", "node_modules", "**/*.test.ts", "**/*.spec.ts"]

0 commit comments

Comments
 (0)