1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-17 11:35:32 -04:00

enable vercel analytics

This commit is contained in:
2023-06-17 20:14:43 -04:00
parent cab79559e6
commit afbdcc7b06
23 changed files with 3046 additions and 2049 deletions

View File

@@ -3,10 +3,11 @@
// directory containing .mdx files relative to project root
export const NOTES_DIR = "notes";
// normalize the timestamp saved when building/deploying (see next.config.js) and fall back to right now:
// normalize the timestamp saved when building/deploying (see next.config.js) and fall back to right now
export const RELEASE_DATE = new Date(process.env.RELEASE_DATE || Date.now()).toISOString();
// detect if running locally via `next dev` (phase is checked in next.config.js)
export const IS_DEV_SERVER = process.env.IS_DEV_SERVER === "true";
// attempt to normalize the various environment flags
export const BUILD_ENV = process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.NODE_ENV;

View File

@@ -1,8 +1,8 @@
import type { DefaultSeoProps, SocialProfileJsonLdProps, ArticleJsonLdProps } from "next-seo";
import * as config from ".";
import { meJpg, faviconPng, faviconIco, appleTouchIconPng } from "./favicons";
import type { DefaultSeoProps, SocialProfileJsonLdProps, ArticleJsonLdProps } from "next-seo";
// Most of this file simply takes the data already defined in ./config.js and translates it into objects that are
// compatible with next-seo's props:
// https://github.com/garmeeh/next-seo#default-seo-configuration
@@ -49,6 +49,7 @@ export const defaultSeo: DefaultSeoProps = {
{
rel: "icon",
href: faviconIco.src,
sizes: "any", // https://twitter.com/subzey/status/1417099064949235712
},
{
rel: "icon",

View File

@@ -1,11 +1,13 @@
import fs from "fs/promises";
import path from "path";
import glob from "fast-glob";
import matter from "gray-matter";
import { marked } from "marked";
import removeMarkdown from "remove-markdown";
import pMap from "p-map";
import pMemoize from "p-memoize";
import matter from "gray-matter";
import removeMarkdown from "remove-markdown";
import { marked } from "marked";
// @ts-ignore
import { markedSmartypants } from "marked-smartypants";
import { formatDate } from "./format-date";
import { baseUrl } from "../config";
import { NOTES_DIR } from "../config/constants";
@@ -36,6 +38,10 @@ export const getNoteData = async (
const rawContent = await fs.readFile(fullPath, "utf8");
const { data, content } = matter(rawContent);
// attach marked extensions:
// https://marked.js.org/using_advanced#extensions
marked.use(markedSmartypants());
// return both the parsed YAML front matter (with a few amendments) and the raw, unparsed markdown content
return {
frontMatter: {
@@ -45,7 +51,9 @@ export const getNoteData = async (
// allow markdown formatting to appear in post titles in some places (rarely used):
htmlTitle: marked.parseInline(data.title, {
silent: true,
smartypants: true,
// these are deprecated and throw very noisy warnings but are still defaults, make it make sense...
mangle: false,
headerIds: false,
}),
slug,
permalink: `${baseUrl}/${NOTES_DIR}/${slug}/`,

View File

@@ -0,0 +1,6 @@
// a weird system but makes it impossible to accidentally end up with multiple imports of the same font. see:
// https://nextjs.org/docs/pages/building-your-application/optimizing/fonts#reusing-fonts
export { default as Inter } from "./loaders/Inter";
export { default as SourceCodePro } from "./loaders/SourceCodePro";
export { default as ComicNeue } from "./loaders/ComicNeue";

View File

@@ -0,0 +1,13 @@
import { Comic_Neue as ComicNeueLoader } from "next/font/google";
const ComicNeue = ComicNeueLoader({
weight: ["400", "700"],
style: ["normal", "italic"],
subsets: ["latin"],
display: "swap",
fallback: ["'Comic Sans MS'", "'Comic Sans'"],
adjustFontFallback: false,
preload: false,
});
export default ComicNeue;

View File

@@ -0,0 +1,10 @@
import { Inter as InterLoader } from "next/font/google";
const Inter = InterLoader({
weight: "variable",
subsets: ["latin"],
display: "fallback",
preload: true,
});
export default Inter;

View File

@@ -0,0 +1,10 @@
import { Source_Code_Pro as SourceCodeProLoader } from "next/font/google";
const SourceCodePro = SourceCodeProLoader({
weight: "variable",
subsets: ["latin"],
display: "fallback",
preload: true,
});
export default SourceCodePro;

View File

@@ -2,11 +2,11 @@ import { createStitches } from "@stitches/react";
import type * as Stitches from "@stitches/react";
// misc. helpers
import hexToRgba from "./utils/hex-to-rgba";
import normalizeStyles from "./utils/normalize";
import { rgba } from "polished";
import normalizeCss from "stitches-normalize";
// web fonts
import { Inter, SourceCodePro } from "./utils/fonts";
import { Inter, SourceCodePro } from "./fonts";
// https://stitches.dev/docs/typescript#type-a-css-object
export type CSS = Stitches.CSS<typeof stitchesConfig>;
@@ -30,7 +30,7 @@ export const {
colors: {
backgroundInner: "#ffffff",
backgroundOuter: "#fcfcfc",
backgroundHeader: hexToRgba("#fcfcfc", 0.7),
backgroundHeader: rgba("#fcfcfc", 0.7),
text: "#202020",
mediumDark: "#515151",
medium: "#5e5e5e",
@@ -40,7 +40,7 @@ export const {
superLight: "#f4f4f4",
superDuperLight: "#fbfbfb",
link: "#0e6dc2",
linkUnderline: hexToRgba("#0e6dc2", 0.4),
linkUnderline: rgba("#0e6dc2", 0.4),
success: "#44a248",
error: "#ff1b1b",
warning: "#f78200",
@@ -93,7 +93,7 @@ export const {
alpha?: number;
}) => ({
// allow both pre-set rgba stitches variables and hex values
$$underlineColor: color.startsWith("#") ? hexToRgba(color, alpha) : color,
$$underlineColor: color.startsWith("#") ? rgba(color, alpha) : color,
}),
},
});
@@ -102,7 +102,7 @@ export const darkTheme = createTheme({
colors: {
backgroundInner: "#1e1e1e",
backgroundOuter: "#252525",
backgroundHeader: hexToRgba("#252525", 0.85),
backgroundHeader: rgba("#252525", 0.85),
text: "#f1f1f1",
mediumDark: "#d7d7d7",
medium: "#b1b1b1",
@@ -112,7 +112,7 @@ export const darkTheme = createTheme({
superLight: "#272727",
superDuperLight: "#1f1f1f",
link: "#88c7ff",
linkUnderline: hexToRgba("#88c7ff", 0.4),
linkUnderline: rgba("#88c7ff", 0.4),
success: "#78df55",
error: "#ff5151",
warning: "#f2b702",
@@ -132,9 +132,12 @@ export const darkTheme = createTheme({
},
});
// @ts-ignore
export const globalStyles = globalCss(
// @ts-ignore
normalizeStyles,
...normalizeCss({
systemFonts: false,
}),
{
body: {
fontFamily: theme.fonts.sans,

View File

@@ -1,32 +0,0 @@
import {
Inter as InterLoader,
Source_Code_Pro as SourceCodeProLoader,
Comic_Neue as ComicNeueLoader,
} from "next/font/google";
const Inter = InterLoader({
weight: "variable",
subsets: ["latin"],
display: "fallback",
preload: true,
});
const SourceCodePro = SourceCodeProLoader({
weight: "variable",
subsets: ["latin"],
display: "fallback",
preload: true,
});
// only for use in pages/previously.tsx (and tree-shaken out everywhere else in production)
const ComicNeue = ComicNeueLoader({
weight: ["400", "700"],
style: ["normal", "italic"],
subsets: ["latin"],
display: "swap",
fallback: ["'Comic Sans MS'", "'Comic Sans'"],
adjustFontFallback: false,
preload: false,
});
export { Inter, SourceCodePro, ComicNeue };

View File

@@ -1,6 +0,0 @@
import hexToRgbaOrig from "hex-to-rgba";
// removes spaces from default hex-to-rgba output
const hexToRgba = (color: string, alpha?: number) => hexToRgbaOrig(color, alpha).replace(/\s/g, "");
export default hexToRgba;

View File

@@ -1,104 +0,0 @@
/*! stitches-normalize | MIT License | https://github.com/jakejarvis/stitches-normalize */
/*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
import type * as Stitches from "@stitches/react";
const normalizeStyles: Record<string, Stitches.CSSProperties> = {
"*, ::before, ::after": {
boxSizing: "border-box",
},
html: {
lineHeight: 1.15,
tabSize: 4,
// @ts-ignore
WebkitTextSizeAdjust: "100%",
},
body: {
margin: 0,
},
hr: {
height: 0,
color: "inherit",
},
"abbr[title]": {
textDecoration: "underline dotted",
},
"b, strong": {
fontWeight: "bolder",
},
"code, kbd, samp, pre": {
fontSize: "1em",
},
small: {
fontSize: "80%",
},
"sub, sup": {
fontSize: "75%",
lineHeight: 0,
position: "relative",
verticalAlign: "baseline",
},
sub: {
bottom: "-0.25em",
},
sup: {
top: "-0.5em",
},
table: {
textIndent: 0,
borderColor: "inherit",
},
"button, input, optgroup, select, textarea": {
fontFamily: "inherit",
fontSize: "100%",
lineHeight: 1.15,
margin: 0,
// @ts-ignore
WebkitAppearance: "button",
},
"button, select": {
textTransform: "none",
},
legend: {
padding: 0,
},
progress: {
verticalAlign: "baseline",
},
summary: {
display: "list-item",
},
"[type='search']": {
outlineOffset: -2,
// @ts-ignore
WebkitAppearance: "textfield",
},
// `-webkit` compatibility properties and rules
"::-webkit-search-decoration": {
// @ts-ignore
WebkitAppearance: "none",
},
"::-webkit-inner-spin-button, ::-webkit-outer-spin-button": {
height: "auto",
},
"::-webkit-file-upload-button": {
font: "inherit",
// @ts-ignore
WebkitAppearance: "button",
},
// `-moz` compatibility properties and rules
"::-moz-focus-inner": {
borderStyle: "none",
padding: 0,
},
":-moz-focusring": {
outline: "1px dotted ButtonText",
},
":-moz-ui-invalid": {
boxShadow: "none",
},
};
export default normalizeStyles;