-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vu Van Dung <[email protected]>
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { MetadataRoute } from "next"; | ||
|
||
export default function robots(): MetadataRoute.Robots { | ||
return { | ||
rules: [ | ||
{ | ||
userAgent: "*", | ||
disallow: [ | ||
"/apps/cuid2/", | ||
"/apps/irasuto/add", | ||
"/apps/link/success", | ||
"/apps/link/l", | ||
"/apps/live-reaction", | ||
"/admin", | ||
"/api", | ||
"/p", | ||
"/sign-in", | ||
], | ||
}, | ||
], | ||
sitemap: "https://joulev.dev/sitemap.xml", | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { execSync } from "node:child_process"; | ||
import type { MetadataRoute } from "next"; | ||
import { meta } from "./(public)/blogs/meta"; | ||
|
||
function getLastUpdatedDate(filePath: string) { | ||
const command = `git log -1 --format=%cd --date=format:'%Y-%m-%d' '${filePath}'`; | ||
const lastCommitDate = execSync(command, { encoding: "utf-8" }).trim(); | ||
return lastCommitDate; | ||
} | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
const now = new Date(); | ||
now.setUTCHours(0, 0, 0, 0); | ||
return [ | ||
{ | ||
url: "https://joulev.dev", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/(home)")), | ||
priority: 1, | ||
}, | ||
{ | ||
url: "https://joulev.dev/glui", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/glui")), | ||
priority: 1, | ||
}, | ||
{ | ||
url: "https://joulev.dev/blogs", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/blogs/meta.ts")), | ||
priority: 0.9, | ||
}, | ||
...meta.map(({ slug, postedDate }) => ({ | ||
url: `https://joulev.dev/blogs/${slug}`, | ||
lastModified: new Date(postedDate), | ||
priority: 0.9, | ||
})), | ||
...[ | ||
"", | ||
"/watching", | ||
"/rewatching", | ||
"/completed/tv", | ||
"/completed/movies", | ||
"/completed/others", | ||
"/paused", | ||
"/dropped", | ||
"/planning", | ||
].map(status => ({ | ||
url: `https://joulev.dev/apps/anime${status}`, | ||
lastModified: now, | ||
changeFrequency: "daily" as const, | ||
})), | ||
{ | ||
url: "https://joulev.dev/apps/cuid2", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/apps/cuid2")), | ||
}, | ||
{ | ||
url: "https://joulev.dev/apps/irasuto", | ||
lastModified: now, | ||
changeFrequency: "daily", | ||
}, | ||
{ | ||
url: "https://joulev.dev/apps/irasuto/random", | ||
lastModified: now, | ||
changeFrequency: "daily", | ||
}, | ||
{ | ||
url: "https://joulev.dev/apps/link", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/apps/link")), | ||
}, | ||
{ | ||
url: "https://joulev.dev/apps/snippets", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/apps/snippets")), | ||
}, | ||
{ | ||
url: "https://joulev.dev/apps/tategaki", | ||
lastModified: new Date(getLastUpdatedDate("src/app/(public)/apps/tategaki")), | ||
}, | ||
]; | ||
} |