1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-19 05:35:30 -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

@@ -3,8 +3,7 @@ import { getAllNotes } from "./parse-notes";
import * as config from "../config";
import { RELEASE_DATE } from "../config/constants";
import { favicons } from "../config/seo";
import type { GetServerSidePropsContext, GetServerSidePropsResult, PreviewData } from "next";
import type { ParsedUrlQuery } from "querystring";
import type { GetServerSideProps } from "next";
export type BuildFeedOptions = {
edgeCacheAge?: number; // in seconds, defaults to 43200 (12 hours)
@@ -13,10 +12,10 @@ export type BuildFeedOptions = {
// handles literally *everything* about building the server-side rss/atom feeds and writing the response.
// all the page needs to do is `return buildFeed(context, "rss")` from getServerSideProps.
export const buildFeed = async (
context: GetServerSidePropsContext<ParsedUrlQuery, PreviewData>,
context: Parameters<GetServerSideProps>[0],
type: "rss" | "atom" | "json",
options?: BuildFeedOptions
): Promise<GetServerSidePropsResult<Record<string, never>>> => {
): Promise<ReturnType<GetServerSideProps<Record<string, never>>>> => {
const { res } = context;
// https://github.com/jpmonette/feed#example