1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-10-28 20:55:47 -04:00

set lastmod date of /notes to most recent post's

This commit is contained in:
2022-06-02 08:35:56 -04:00
parent 946cf87af4
commit 07a96917a4
4 changed files with 123 additions and 115 deletions

View File

@@ -14,9 +14,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
url: "/",
priority: 1.0,
changefreq: EnumChangefreq.WEEKLY,
lastmod: RELEASE_DATE,
lastmod: RELEASE_DATE, // timestamp frozen when a new build is deployed
},
{ url: "/notes/", changefreq: EnumChangefreq.WEEKLY, lastmod: RELEASE_DATE },
{ url: "/birthday/" },
{ url: "/cli/" },
{ url: "/contact/" },
@@ -41,6 +40,15 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
})
);
// set lastmod of /notes/ page to most recent post's date
pages.push({
url: "/notes/",
lastmod: new Date(notes[0].date).toISOString(),
});
// sort alphabetically by URL
pages.sort((a, b) => (a.url < b.url ? -1 : 1));
// translate array of all pages to sitemap's stream
pages.forEach((page) => {
stream.write(page);