mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-09-16 17:55:32 -04:00
group config files
This commit is contained in:
47
lib/config/index.js
Normal file
47
lib/config/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// do not convert to ESM and/or TS -- this needs to be imported in CJS files like next.config.js too
|
||||
module.exports = {
|
||||
// Site info
|
||||
siteName: "Jake Jarvis",
|
||||
siteDomain: "jarv.is",
|
||||
siteLocale: "en_us",
|
||||
baseUrl:
|
||||
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
|
||||
? "https://jarv.is"
|
||||
: process.env.NEXT_PUBLIC_VERCEL_URL
|
||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||
: process.env.IS_DEV_SERVER
|
||||
? "http://localhost:3000"
|
||||
: "", // fallback to relative URLs
|
||||
onionDomain: "http://jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion",
|
||||
shortDescription: "Front-End Web Developer in Boston, MA",
|
||||
longDescription:
|
||||
"Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps.",
|
||||
githubRepo: "jakejarvis/jarv.is",
|
||||
verifyGoogle: "qQhmLTwjNWYgQ7W42nSTq63xIrTch13X_11mmxBE9zk",
|
||||
verifyBing: "164551986DA47F7F6FC0D21A93FFFCA6",
|
||||
fathomSiteId: "WBGNQUKW",
|
||||
webmentionId: "jarv.is",
|
||||
giscusConfig: {
|
||||
// https://github.com/giscus/giscus-component/tree/main/packages/react#readme
|
||||
repo: "jakejarvis/jarv.is",
|
||||
repoId: "MDEwOlJlcG9zaXRvcnk1MzM0MDgxMQ==",
|
||||
category: "Comments",
|
||||
categoryId: "DIC_kwDOAy3qi84CAsjS",
|
||||
},
|
||||
|
||||
// Me info
|
||||
authorName: "Jake Jarvis",
|
||||
authorEmail: "jake@jarv.is",
|
||||
authorSocial: {
|
||||
github: "jakejarvis",
|
||||
twitter: "jakejarvis",
|
||||
facebook: "jakejarvis",
|
||||
keybase: "jakejarvis",
|
||||
medium: "jakejarvis",
|
||||
linkedin: "jakejarvis",
|
||||
instagram: "jakejarvis",
|
||||
},
|
||||
|
||||
// Next.js constants
|
||||
NOTES_DIR: "./notes",
|
||||
};
|
68
lib/config/migrations/hits-db.js
Normal file
68
lib/config/migrations/hits-db.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// Initialize a new pageview database. For use with Fauna Schema Migrate:
|
||||
// https://github.com/fauna-labs/fauna-schema-migrate#readme
|
||||
|
||||
import faunadb from "faunadb";
|
||||
const {
|
||||
CreateCollection,
|
||||
CreateIndex,
|
||||
CreateFunction,
|
||||
Query,
|
||||
Collection,
|
||||
Role,
|
||||
Var,
|
||||
Index,
|
||||
Let,
|
||||
Match,
|
||||
Lambda,
|
||||
Get,
|
||||
Create,
|
||||
Update,
|
||||
Add,
|
||||
Select,
|
||||
If,
|
||||
Exists,
|
||||
ToInteger,
|
||||
} = faunadb.query;
|
||||
|
||||
export default function run() {
|
||||
// initializes the empty database
|
||||
CreateCollection({ name: "hits" });
|
||||
|
||||
// this allows us to quickly pull a post's corresponding row
|
||||
CreateIndex({
|
||||
name: "hits_by_slug",
|
||||
source: Collection("hits"),
|
||||
terms: [
|
||||
{
|
||||
field: ["data", "slug"],
|
||||
},
|
||||
],
|
||||
unique: false,
|
||||
serialized: true,
|
||||
});
|
||||
|
||||
// a wrapper to get a post's row, add one to it, and return the new tally
|
||||
CreateFunction({
|
||||
name: "increment_hit",
|
||||
body: Query(
|
||||
Lambda(
|
||||
"slug",
|
||||
Let(
|
||||
{ match: Match(Index("hits_by_slug"), Var("slug")) },
|
||||
If(
|
||||
Exists(Var("match")),
|
||||
Let(
|
||||
{
|
||||
ref: Select("ref", Get(Var("match"))),
|
||||
hits: ToInteger(Select("hits", Select("data", Get(Var("match"))))),
|
||||
},
|
||||
Update(Var("ref"), { data: { hits: Add(Var("hits"), 1) } })
|
||||
),
|
||||
Create(Collection("hits"), { data: { slug: Var("slug"), hits: 1 } })
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
role: Role("server"),
|
||||
});
|
||||
}
|
130
lib/config/seo.ts
Normal file
130
lib/config/seo.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import * as config from ".";
|
||||
|
||||
import faviconIco from "../../public/static/favicons/favicon.ico";
|
||||
import faviconPng from "../../public/static/favicons/favicon.png";
|
||||
import appleTouchIconPng from "../../public/static/favicons/apple-touch-icon.png";
|
||||
import meJpg from "../../public/static/images/me.jpg";
|
||||
|
||||
import type { DefaultSeoProps } from "next-seo";
|
||||
import type { SocialProfileJsonLdProps } from "next-seo/lib/jsonld/socialProfile";
|
||||
import type { ArticleJsonLdProps } from "next-seo/lib/jsonld/article";
|
||||
|
||||
// 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
|
||||
export const defaultSeo: DefaultSeoProps = {
|
||||
defaultTitle: `${config.siteName} – ${config.shortDescription}`,
|
||||
titleTemplate: `%s – ${config.siteName}`, // appends `– siteName` to title provided by each page (except home)
|
||||
description: config.longDescription,
|
||||
openGraph: {
|
||||
site_name: config.siteName,
|
||||
title: `${config.siteName} – ${config.shortDescription}`,
|
||||
locale: config.siteLocale,
|
||||
type: "website",
|
||||
images: [
|
||||
{
|
||||
url: `${config.baseUrl}${meJpg.src}`,
|
||||
alt: `${config.siteName} – ${config.shortDescription}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
handle: `@${config.authorSocial?.twitter}`,
|
||||
site: `@${config.authorSocial?.twitter}`,
|
||||
cardType: "summary",
|
||||
},
|
||||
additionalMetaTags: [
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1",
|
||||
},
|
||||
{
|
||||
name: "author",
|
||||
content: config.authorName,
|
||||
},
|
||||
{
|
||||
name: "google-site-verification",
|
||||
content: config.verifyGoogle,
|
||||
},
|
||||
{
|
||||
name: "msvalidate.01",
|
||||
content: config.verifyBing,
|
||||
},
|
||||
],
|
||||
additionalLinkTags: [
|
||||
{
|
||||
rel: "icon",
|
||||
href: faviconIco.src,
|
||||
},
|
||||
{
|
||||
rel: "icon",
|
||||
href: faviconPng.src,
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
rel: "apple-touch-icon",
|
||||
href: appleTouchIconPng.src,
|
||||
sizes: `${appleTouchIconPng.width}x${appleTouchIconPng.height}`,
|
||||
},
|
||||
{
|
||||
rel: "manifest",
|
||||
href: "/site.webmanifest",
|
||||
},
|
||||
{
|
||||
rel: "alternate",
|
||||
href: "/feed.xml",
|
||||
type: "application/rss+xml",
|
||||
// @ts-ignore
|
||||
title: `${config.siteName} (RSS)`,
|
||||
},
|
||||
{
|
||||
rel: "alternate",
|
||||
href: "/feed.atom",
|
||||
type: "application/atom+xml",
|
||||
// @ts-ignore
|
||||
title: `${config.siteName} (Atom)`,
|
||||
},
|
||||
{
|
||||
rel: "webmention",
|
||||
href: `https://webmention.io/${config.webmentionId}/webmention`,
|
||||
},
|
||||
{
|
||||
rel: "pingback",
|
||||
href: `https://webmention.io/${config.webmentionId}/xmlrpc`,
|
||||
},
|
||||
{
|
||||
rel: "humans",
|
||||
href: "/humans.txt",
|
||||
},
|
||||
{
|
||||
rel: "pgpkey",
|
||||
href: "/pubkey.asc",
|
||||
type: "application/pgp-keys",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// https://github.com/garmeeh/next-seo#social-profile
|
||||
export const socialProfileJsonLd: SocialProfileJsonLdProps = {
|
||||
type: "Person",
|
||||
name: config.authorName,
|
||||
url: `${config.baseUrl}/`,
|
||||
sameAs: [
|
||||
`${config.baseUrl}/`,
|
||||
`https://github.com/${config.authorSocial?.github}`,
|
||||
`https://keybase.io/${config.authorSocial?.keybase}`,
|
||||
`https://twitter.com/${config.authorSocial?.twitter}`,
|
||||
`https://medium.com/@${config.authorSocial?.medium}`,
|
||||
`https://www.linkedin.com/in/${config.authorSocial?.linkedin}/`,
|
||||
`https://www.facebook.com/${config.authorSocial?.facebook}`,
|
||||
`https://www.instagram.com/${config.authorSocial?.instagram}/`,
|
||||
],
|
||||
};
|
||||
|
||||
// Just the basic items applicable to all notes, extended by pages/notes/[slug].tsx
|
||||
// https://github.com/garmeeh/next-seo#article-1
|
||||
export const articleJsonLd: Pick<ArticleJsonLdProps, "authorName" | "publisherName" | "publisherLogo"> = {
|
||||
authorName: [config.authorName],
|
||||
publisherName: config.siteName,
|
||||
publisherLogo: `${config.baseUrl}${meJpg.src}`,
|
||||
};
|
74
lib/config/themes.ts
Normal file
74
lib/config/themes.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
// Light/dark theme-related CSS variables that are inlined in Layout.tsx and become available globally.
|
||||
// TODO: Probably invert the object so that *each variable* has a light and dark key.
|
||||
const themes = {
|
||||
light: {
|
||||
"background-inner": "#ffffff",
|
||||
"background-outer": "#fcfcfc",
|
||||
"background-header": "rgba(252, 252, 252, 0.7)",
|
||||
text: "#202020",
|
||||
"medium-dark": "#515151",
|
||||
medium: "#5e5e5e",
|
||||
"medium-light": "#757575",
|
||||
light: "#d2d2d2",
|
||||
"kinda-light": "#e3e3e3",
|
||||
"super-light": "#f4f4f4",
|
||||
"super-duper-light": "#fbfbfb",
|
||||
link: "#0e6dc2",
|
||||
"link-underline": "rgba(14, 109, 194, 0.4)",
|
||||
success: "#44a248",
|
||||
error: "#ff1b1b",
|
||||
warning: "#f78200",
|
||||
|
||||
// Syntax Highlighting (light) - modified from Monokai Light: https://github.com/mlgill/pygments-style-monokailight
|
||||
"code-text": "#313131",
|
||||
"code-background": "#fdfdfd",
|
||||
"code-comment": "#656e77",
|
||||
"code-keyword": "#029cb9",
|
||||
"code-attribute": "#70a800",
|
||||
"code-namespace": "#f92672",
|
||||
"code-literal": "#ae81ff",
|
||||
"code-punctuation": "#111111",
|
||||
"code-variable": "#d88200",
|
||||
"code-addition": "#44a248",
|
||||
"code-deletion": "#ff1b1b",
|
||||
},
|
||||
dark: {
|
||||
"background-inner": "#1e1e1e",
|
||||
"background-outer": "#252525",
|
||||
"background-header": "rgba(37, 37, 37, 0.85)",
|
||||
text: "#f1f1f1",
|
||||
"medium-dark": "#d7d7d7",
|
||||
medium: "#b1b1b1",
|
||||
"medium-light": "#959595",
|
||||
light: "#646464",
|
||||
"kinda-light": "#535353",
|
||||
"super-light": "#272727",
|
||||
"super-duper-light": "#1f1f1f",
|
||||
link: "#88c7ff",
|
||||
"link-underline": "rgba(136, 199, 255, 0.4)",
|
||||
success: "#78df55",
|
||||
error: "#ff5151",
|
||||
warning: "#f2b702",
|
||||
|
||||
// Syntax Highlighting (dark) - modified from Dracula: https://github.com/dracula/pygments
|
||||
"code-text": "#e4e4e4",
|
||||
"code-background": "#212121",
|
||||
"code-comment": "#929292",
|
||||
"code-keyword": "#3b9dd2",
|
||||
"code-attribute": "#78df55",
|
||||
"code-namespace": "#f95757",
|
||||
"code-literal": "#d588fb",
|
||||
"code-punctuation": "#cccccc",
|
||||
"code-variable": "#fd992a",
|
||||
"code-addition": "#78df55",
|
||||
"code-deletion": "#ff5151",
|
||||
},
|
||||
};
|
||||
|
||||
// converts each variable in a given theme object to CSS syntax and returns all of them as one long string
|
||||
export const toCSS = (theme: Record<string, string>) =>
|
||||
Object.entries(theme)
|
||||
.map(([name, color]) => `--${name}:${color};`)
|
||||
.join("");
|
||||
|
||||
export default themes;
|
Reference in New Issue
Block a user