Skip to content

Commit

Permalink
[][s]: Add url_path to all files
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsalem401 committed Jan 31, 2024
1 parent 39f1428 commit abdc2c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-cameras-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mddb": patch
---

Add url_path to all files
3 changes: 1 addition & 2 deletions src/lib/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function processFile(
_id: id,
file_path: filePath,
extension,
url_path: null,
url_path: pathToUrlResolver(relativePath),
filetype: null,
metadata: {},
tags: [],
Expand All @@ -59,7 +59,6 @@ export function processFile(
permalinks: filePathsToIndex,
});

fileInfo.url_path = pathToUrlResolver(relativePath);
fileInfo.metadata = metadata;
fileInfo.links = links;

Expand Down
7 changes: 7 additions & 0 deletions src/tests/markdowndb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ describe("MarkdownDB - default config", () => {
const dbFile2 = await mddb.getFileByUrl("blog/blog2");
expect(dbFile2).not.toBeNull();
});

test('test can get file canvas by url', async () => {
const dbFile1 = await mddb.getFileByUrl('hi.canvas');
expect(dbFile1).not.toBeNull();
expect(dbFile1.url_path).toBe('hi.canvas');
expect(dbFile1.extension).toBe('canvas');
});
});

describe("querying files", () => {
Expand Down

0 comments on commit abdc2c6

Please sign in to comment.