Skip to content

Commit afb27ea

Browse files
authored
update:remove Dayjs from dependencies, adding a format function instead (#19)
Co-authored-by: sinyo-matu <[email protected]>
1 parent 3e23953 commit afb27ea

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/deps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { default as day } from "https://esm.sh/[email protected]";
21
export {
32
basename,
43
extname,

src/sitemap.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// <reference lib="deno.ns" />
55
/// <reference lib="deno.unstable" />
66

7-
import { basename, day, extname } from "./deps.ts";
7+
import { basename, extname } from "./deps.ts";
88
import { type Manifest, type Route, type RouteProps } from "./types.ts";
99

1010
export class SitemapContext {
@@ -94,7 +94,7 @@ export class SitemapContext {
9494
.map((route) => {
9595
return `<url>
9696
<loc>${this.#url}${route.pathName}</loc>
97-
<lastmod>${day(route.lastmod).format("YYYY-MM-DD")}</lastmod>
97+
<lastmod>${formatYearMonthDate(route.lastmod??new Date())}</lastmod>
9898
<changefreq>${route.changefreq ?? "daily"}</changefreq>
9999
<priority>${route.priority ?? "0.8"}</priority>
100100
</url>`;
@@ -125,3 +125,9 @@ export class SitemapContext {
125125
// }
126126
// }
127127
}
128+
129+
function formatYearMonthDate(date: Date) {
130+
return `${date.getFullYear()}-${("00" + (date.getMonth() + 1)).slice(-2)}-${
131+
("00" + date.getDate()).slice(-2)
132+
}`;
133+
}

0 commit comments

Comments
 (0)