Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
turtton committed Mar 31, 2023
1 parent 667a23d commit 77ae14c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
84 changes: 42 additions & 42 deletions src/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,47 @@ export interface RawContent {
}

export function getSearchIndex(): SearchData[] {
const result: SearchData[] = [];
const filePaths = getAllMarkdownFiles();
filePaths.forEach((markdownFile) => {
const title = Transformer.parseFileNameFromPath(markdownFile);
if (title == null || title.match(/\.[a-zA-Z0-9]*$/)) {
return;
}
const rawTitle = isJapanese(title) ? toRomaji(title) : title;
const content = fs.readFileSync(markdownFile);
if (content === null || content === undefined) {
return;
}
const path = getRouterPath(`${title}.md`);
if (path === null) {
return;
}
content
.toString()
.split("\n")
.forEach((line, index) => {
if (line.match("```") !== null || line.match("---") !== null) return;
let rawContent: RawContent | null = null;
if (isJapanese(line)) {
const raw = toRomaji(line);
const kenized = tokenize(line);
const kanaizedRomaji = kenized.map((k) => toRomaji(toKana(k)));
rawContent = {
raw,
separatedOriginal: kenized,
separatedRaw: kanaizedRomaji,
};
}
result.push({
title,
rawTitle,
singleLineContent: line,
lineAt: index,
path,
rawContent,
});
const result: SearchData[] = [];
const filePaths = getAllMarkdownFiles();
filePaths.forEach((markdownFile) => {
const title = Transformer.parseFileNameFromPath(markdownFile);
if (title == null || title.match(/\.[a-zA-Z0-9]*$/)) {
return;
}
const rawTitle = isJapanese(title) ? toRomaji(title) : title;
const content = fs.readFileSync(markdownFile);
if (content === null || content === undefined) {
return;
}
const path = getRouterPath(`${title}.md`);
if (path === null) {
return;
}
content
.toString()
.split("\n")
.forEach((line, index) => {
if (line.match("```") !== null || line.match("---") !== null) return;
let rawContent: RawContent | null = null;
if (isJapanese(line)) {
const raw = toRomaji(line);
const kenized = tokenize(line);
const kanaizedRomaji = kenized.map((k) => toRomaji(toKana(k)));
rawContent = {
raw,
separatedOriginal: kenized,
separatedRaw: kanaizedRomaji,
};
}
result.push({
title,
rawTitle,
singleLineContent: line,
lineAt: index,
path,
rawContent,
});
});
return result;
});
});
return result;
}
2 changes: 1 addition & 1 deletion src/pages/[...id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function getStaticPaths(): Promise<{
}> {
clearPublicDir();
const directoryData = getDirectoryData();
const searchIndex = getSearchIndex()
const searchIndex = getSearchIndex();
const slugs = await initCache(
JSON.stringify(directoryData),
JSON.stringify(searchIndex),
Expand Down

0 comments on commit 77ae14c

Please sign in to comment.