chore: update buildCandidateTrie signature

This commit is contained in:
Kodai Nakamura 2025-02-16 17:42:31 +09:00
parent 16207925a8
commit 1979d8e4ed
3 changed files with 7 additions and 4 deletions

View file

@ -72,7 +72,7 @@ export default class AutomaticLinkerPlugin extends Plugin {
body: fileContent.slice(contentStart),
linkResolverContext: {
filePath: activeFile.path.replace(/\.md$/, ""),
trie: this.trie ?? buildCandidateTrie([]).trie,
trie: this.trie ?? buildCandidateTrie([], undefined).trie,
candidateMap: this.candidateMap ?? new Map(),
},
settings: {

View file

@ -1,2 +1,2 @@
export { getEffectiveNamespace, replaceLinks } from "./replace-links";
export { replaceLinks } from "./replace-links";
export type { ReplaceLinksOptions } from "./types";

View file

@ -25,7 +25,10 @@ export interface TrieNode {
* If the path starts with one of the baseDir (e.g. "pages/"), the directory immediately
* under the baseDir is considered the effective namespace.
*/
export const getEffectiveNamespace = (path: string, baseDir?: string): string => {
export const getEffectiveNamespace = (
path: string,
baseDir?: string,
): string => {
const prefix = baseDir + "/";
if (baseDir) {
if (path.startsWith(prefix)) {
@ -67,7 +70,7 @@ export interface CandidateData {
export const buildCandidateTrie = (
allFiles: PathAndAliases[],
baseDir?: string,
baseDir: string | undefined,
) => {
// Process candidate strings from file paths.
type Candidate = {