Skip to content
Snippets Groups Projects
Commit 48f7889c authored by Tianyi Liang's avatar Tianyi Liang
Browse files

refactor: code extracting and cleanup

parent 107cc68b
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
"include": ["src"]
}
......@@ -7,5 +7,5 @@
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "src/utils/index.ts"]
}
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
function stringToSlug(string: string): string {
let slug = String(string).toLowerCase();
slug = slug.replace(/[^a-z0-9-]/g, "-");
slug = slug.replace(/-+/g, "-");
// remove dashes at start and end
const start = slug.search(/[^-]/); // find index of first non-dash
const end = slug.search(/-+$/); // find index of first end dash
return slug.substring(start, end === -1 ? undefined : end);
}
import { stringToSlug } from "./src/utils";
// https://vitejs.dev/config/
export default () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment