mirror of
https://github.com/m1ngsama/documents.git
synced 2025-12-24 10:51:23 +00:00
add vue
This commit is contained in:
parent
065b3f2889
commit
e84e7ec4b4
8 changed files with 69 additions and 4 deletions
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"vue.server.includeLanguages": [
|
||||
"vue",
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
12
|
||||
index
|
||||
|
|
@ -9,7 +9,7 @@ type MeetingMinutesParsed = {
|
|||
link: string
|
||||
}
|
||||
|
||||
const stripFileExtension = (filename: string) => {
|
||||
export const stripFileExtension = (filename: string) => {
|
||||
return filename.split(".").slice(0, -1).join(".")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^22.10.10",
|
||||
"dayjs": "^1.11.13"
|
||||
"dayjs": "^1.11.13",
|
||||
"vue": "^3.5.13"
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,9 @@ importers:
|
|||
dayjs:
|
||||
specifier: ^1.11.13
|
||||
version: 1.11.13
|
||||
vue:
|
||||
specifier: ^3.5.13
|
||||
version: 3.5.13
|
||||
devDependencies:
|
||||
vitepress:
|
||||
specifier: ^1.6.3
|
||||
|
|
|
|||
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.vue",
|
||||
"**/*.md",
|
||||
],
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"vueCompilerOptions": {
|
||||
"vitePressExtensions": [
|
||||
".md"
|
||||
],
|
||||
},
|
||||
}
|
||||
40
utils/sidebar.test.ts
Normal file
40
utils/sidebar.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { describe, expect, test, beforeAll, afterAll } from "vitest";
|
||||
import { scanDir } from "../utils/sidebar";
|
||||
import { resolve } from "path";
|
||||
import { mkdtempSync, writeFileSync, rmdirSync } from "fs";
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
|
||||
let tempDir: string;
|
||||
|
||||
beforeAll(() => {
|
||||
tempDir = mkdtempSync(join(tmpdir(), 'test-'));
|
||||
writeFileSync(join(tempDir, 'test1.md'), '# Test 1');
|
||||
writeFileSync(join(tempDir, 'test2.md'), '# Test 2');
|
||||
writeFileSync(join(tempDir, 'test.txt'), 'Test text file');
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
rmdirSync(tempDir, { recursive: true });
|
||||
});
|
||||
|
||||
describe("scanDir", () => {
|
||||
test("should return markdown files with correct structure", () => {
|
||||
const res = scanDir(tempDir);
|
||||
expect(res).toBeInstanceOf(Array);
|
||||
expect(res.length).toBe(2);
|
||||
res.forEach(item => {
|
||||
expect(item).toHaveProperty("filename");
|
||||
expect(item).toHaveProperty("link");
|
||||
expect(item.filename).toMatch(/\.md$/);
|
||||
expect(item.link).toBe(resolve(tempDir, item.filename));
|
||||
});
|
||||
});
|
||||
|
||||
test("should return an empty array if no markdown files are found", () => {
|
||||
const emptyDir = mkdtempSync(join(tmpdir(), 'empty-'));
|
||||
const res = scanDir(emptyDir);
|
||||
expect(res).toEqual([]);
|
||||
rmdirSync(emptyDir, { recursive: true });
|
||||
});
|
||||
});
|
||||
|
|
@ -10,7 +10,7 @@ export const scanDir = (dirname: string) => {
|
|||
return markdownFileNames.map(v => {
|
||||
return {
|
||||
filename: v,
|
||||
link: path.join(dirpath, v)
|
||||
link: path.join(dirname, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Reference in a new issue