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

only reveal a db record via /api/hits if it matches a real page

This commit is contained in:
2022-07-06 11:49:41 -04:00
parent 8d47958473
commit 155c6cacd9
9 changed files with 82 additions and 76 deletions

View File

@@ -1,7 +1,7 @@
import { SitemapStream, SitemapItemLoose, EnumChangefreq } from "sitemap";
import { getAllNotes } from "../lib/helpers/parse-notes";
import { baseUrl } from "../lib/config";
import { RELEASE_DATE } from "../lib/config/constants";
import { RELEASE_DATE, NOTES_DIR } from "../lib/config/constants";
import type { GetServerSideProps } from "next";
export const getServerSideProps: GetServerSideProps<Record<string, never>> = async (context) => {
@@ -42,16 +42,16 @@ export const getServerSideProps: GetServerSideProps<Record<string, never>> = asy
const notes = await getAllNotes();
notes.forEach((note) => {
pages.push({
url: `/notes/${note.slug}/`,
url: `/${NOTES_DIR}/${note.slug}/`,
// pull lastMod from front matter date
lastmod: new Date(note.date).toISOString(),
lastmod: note.date,
});
});
// set lastmod of /notes/ page to most recent post's date
pages.push({
url: "/notes/",
lastmod: new Date(notes[0].date).toISOString(),
url: `/${NOTES_DIR}/`,
lastmod: notes[0].date,
});
// sort alphabetically by URL