Skip to content

Commit f4e0e4a

Browse files
committed
fix up the back and forwardslashes
1 parent 1840033 commit f4e0e4a

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

orama/generate_orama_index_full.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ function buildUrl(relativePath: string, baseUrl?: string): string {
221221
}
222222

223223
let url = relativePath.replace(/\.(md|mdx)$/, "");
224+
// Normalize path separators to forward slashes for web URLs
225+
url = url.replace(/\\/g, "/");
224226
if (url.endsWith("/index")) {
225227
url = url.replace(/\/index$/, "/");
226228
}
@@ -240,6 +242,8 @@ function buildPath(relativePath: string, baseUrl?: string): string {
240242
}
241243

242244
let path = relativePath.replace(/\.(md|mdx)$/, "");
245+
// Normalize path separators to forward slashes for web paths
246+
path = path.replace(/\\/g, "/");
243247
if (path.endsWith("/index")) {
244248
path = path.replace(/\/index$/, "/");
245249
}

orama/indexing/MarkdownIndexer.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ import type {
66

77
const H1_REGEX = /^# (.+)$/m;
88
const FRONTMATTER_TITLE_REGEX = /title: ["'](.+)["']/;
9-
const DESCRIPTION_REGEX = /description: ["'](.+)["']/;
9+
const DESCRIPTION_REGEX private buildPath(relativePath: string): string {
10+
let p = relativePath.replace(/\.(md|mdx)$/, "");
11+
// Normalize path separators to forward slashes for web paths
12+
p = p.replace(/\\/g, "/");
13+
if (p.endsWith("/index")) {
14+
p = p.replace(/\/index$/, "/");
15+
}
16+
if (!p.startsWith("/")) {
17+
p = "/" + p;
18+
}
19+
return p;
20+
}ption: ["'](.+)["']/;
1021
const TAGS_REGEX = /tags: \[(.*?)\]/;
1122
const FRONTMATTER_COMMAND_REGEX = /\bcommand:\s*(["']?)([a-zA-Z0-9_-]+)\1/;
1223

@@ -202,7 +213,9 @@ export class MarkdownIndexer implements IIndexDocuments {
202213
}
203214

204215
private buildUrl(relativePath: string): string {
205-
let url = relativePath.replace(/\.(md|mdx)$/, "");
216+
let url = relativePath.replace(/\.(md|mdx)$/, "");
217+
// Normalize path separators to forward slashes for web URLs
218+
url = url.replace(/\\/g, "/");
206219
if (url.endsWith("/index")) {
207220
url = url.replace(/\/index$/, "/");
208221
}
@@ -213,9 +226,7 @@ export class MarkdownIndexer implements IIndexDocuments {
213226
const BASE_URL = "https://docs.deno.com"; // Replace with your actual base URL
214227

215228
return `${BASE_URL}${url}`;
216-
}
217-
218-
private buildPath(relativePath: string): string {
229+
} private buildPath(relativePath: string): string {
219230
let p = relativePath.replace(/\.(md|mdx)$/, "");
220231
if (p.endsWith("/index")) {
221232
p = p.replace(/\/index$/, "/");

orama/upload_orama_index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*
2020
* # Upload in batches of 1000 documents
2121
* deno run -A upload_orama_index.ts --batch-size=1000
22-
*
23-
* # Deploy after upload
24-
* deno run -A upload_orama_index.ts --deploy
2522
*/
2623

2724
import { fromFileUrl, join } from "@std/path";
@@ -296,18 +293,8 @@ async function main() {
296293
// Upload documents
297294
await uploadDocuments(config, documents, options);
298295

299-
// Deploy if requested
300-
if (shouldDeploy) {
301-
console.log("");
302-
await deployIndex(config);
303-
}
304-
305296
console.log("\nUpload process completed!");
306-
if (shouldDeploy) {
307-
console.log("Index has been deployed and is now live!");
308-
} else {
309-
console.log("Run with --deploy flag to deploy the index");
310-
}
297+
console.log("Index has been updated and is now live!");
311298
}
312299

313300
// Run the main function

0 commit comments

Comments
 (0)