-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pathToUrlResolver / utils functions /
- Loading branch information
1 parent
f7ef9d5
commit 6712e30
Showing
7 changed files
with
69 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { WikiLink } from "../../utils"; | ||
import { File, Tag } from "./schemaTypes"; | ||
import { File } from "./schemaTypes"; | ||
|
||
export interface FileObject { | ||
file: File; | ||
tags: Tag[]; | ||
export interface FileObject extends File { | ||
tags: string[]; | ||
links: WikiLink[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ export enum Table { | |
Tags = "tags", | ||
FileTags = "file_tags", | ||
Links = "links", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const defaultFilePathToUrl = (filePath: string) => { | ||
let url = filePath | ||
.replace(/\.(mdx|md)/, "") | ||
.replace(/\\/g, "/") // replace windows backslash with forward slash | ||
.replace(/(\/)?index$/, ""); // remove index from the end of the permalink | ||
url = url.length > 0 ? url : "/"; // for home page | ||
return encodeURI(url); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { FileObject } from "../lib/types/FileObject.js"; | ||
|
||
export function extractFileSchemeFromObject(fileObject: FileObject) { | ||
return { | ||
_id: fileObject._id, | ||
file_path: fileObject.file_path, | ||
extension: fileObject.extension, | ||
url_path: fileObject.url_path, | ||
filetype: fileObject.filetype, | ||
metadata: fileObject.metadata, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export { recursiveWalkDir } from "./recursiveWalkDir.js"; | ||
export { extractWikiLinks, WikiLink } from "./extractWikiLinks.js"; | ||
export { parseFile } from "./parseFile.js"; | ||
export { parseMarkdownContent } from "./parseMarkdownContent.js"; | ||
export { getUniqueValues } from "./getUniqueValues.js"; | ||
export { generateFileIdFromPath } from "./generateFileIdFromPath.js"; | ||
export { getFileExtensionFromPath } from "./getFileExtensionFromPath.js"; | ||
export { defaultFilePathToUrl } from "./defaultFilePathToUrl.js"; | ||
export { extractFileSchemeFromObject } from "./extractFileSchemeFromObject.js"; |