Action | Type | Resolved On |
|---|---|---|
| Move slugging function to str.ts to eliminate duplication | refactoring | - - - |
The slugging function is duplicated in both monthly.ts and yearly.ts. Move it to src/lib/str.ts which already contains string utilities.
src/lib/monthly.ts:310-312
function slugging(str: string) {
return String(str).replaceAll(".", "-").replaceAll(" ", "-").toLowerCase();
}
src/lib/yearly.ts:105-107
function slugging(str: string) {
return String(str).replaceAll(".", "-").replaceAll(" ", "-").toLowerCase();
}
src/lib/str.ts:export function slugging(str: string): string {
return String(str).replaceAll(".", "-").replaceAll(" ", "-").toLowerCase();
}
monthly.ts:import { slugging } from "./str";
// Remove local function definition
yearly.ts:import { slugging } from "../str";
// Remove local function definition
src/lib/str.ts (add function)src/lib/monthly.ts (import and remove local)src/lib/yearly.ts (import and remove local)