1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-11-05 07:05:40 -05:00

test config changes before messing everything up too much

This commit is contained in:
2022-01-03 09:59:42 -05:00
parent c708383afb
commit 36e3cfa18e
9 changed files with 178 additions and 169 deletions

View File

@@ -18,10 +18,10 @@ const Container = ({ title, description, children }: Props) => {
<NextSeo <NextSeo
title={title} title={title}
description={description} description={description}
canonical={`${config.baseURL}${router.asPath}`} canonical={`${config.baseUrl}${router.asPath}`}
openGraph={{ openGraph={{
title: title, title: title,
url: `${config.baseURL}${router.asPath}`, url: `${config.baseUrl}${router.asPath}`,
}} }}
/> />
<div className={styles.container}>{children}</div> <div className={styles.container}>{children}</div>

View File

@@ -3,22 +3,21 @@ import { getAllNotes } from "./parse-notes";
import * as config from "./config"; import * as config from "./config";
export const buildFeed = () => { export const buildFeed = () => {
const baseURL = config.baseURL || "http://localhost:3000"; // necessary for local testing
const feed = new Feed({ const feed = new Feed({
id: `${baseURL}/`, id: `${config.baseUrl}/`,
link: `${baseURL}/`, link: `${config.baseUrl}/`,
title: config.siteName, title: config.siteName,
description: config.longDescription, description: config.longDescription,
copyright: "https://creativecommons.org/licenses/by/4.0/", copyright: "https://creativecommons.org/licenses/by/4.0/",
updated: new Date(), updated: new Date(),
image: `${baseURL}/static/images/me.jpg`, image: `${config.baseUrl}/static/images/me.jpg`,
feedLinks: { feedLinks: {
rss: `${baseURL}/feed.xml`, rss: `${config.baseUrl}/feed.xml`,
atom: `${baseURL}/feed.atom`, atom: `${config.baseUrl}/feed.atom`,
}, },
author: { author: {
name: config.authorName, name: config.authorName,
link: baseURL, link: config.baseUrl,
email: "jake@jarv.is", email: "jake@jarv.is",
}, },
}); });
@@ -27,14 +26,14 @@ export const buildFeed = () => {
notes.forEach((note: any) => { notes.forEach((note: any) => {
feed.addItem({ feed.addItem({
title: note.title, title: note.title,
link: `${baseURL}/notes/${note.slug}/`, link: `${config.baseUrl}/notes/${note.slug}/`,
guid: `${baseURL}/notes/${note.slug}/`, guid: `${config.baseUrl}/notes/${note.slug}/`,
description: note.description, description: note.description,
image: note.image ? `${baseURL}${note.image}` : "", image: note.image ? `${config.baseUrl}${note.image}` : "",
author: [ author: [
{ {
name: config.authorName, name: config.authorName,
link: baseURL, link: config.baseUrl,
}, },
], ],
date: new Date(note.date), date: new Date(note.date),

View File

@@ -1,33 +1,27 @@
// Site info module.exports = {
export const siteName = "Jake Jarvis"; // Site info
export const siteDomain = "jarv.is"; siteName: "Jake Jarvis",
export const shortDescription = "Front-End Web Developer in Boston, MA"; siteDomain: "jarv.is",
export const longDescription = onionDomain: "jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion",
"Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps."; baseUrl: process.env.BASE_URL,
export const themeColorLight = "#fcfcfc"; shortDescription: "Front-End Web Developer in Boston, MA",
export const themeColorDark = "#252525"; longDescription:
export const githubRepo = "jakejarvis/jarv.is"; "Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps.",
export const fathomSiteId = "WBGNQUKW"; themeColorLight: "#fcfcfc",
export const fathomCustomDomain = "blue-chilly.jarv.is"; themeColorDark: "#252525",
githubRepo: "jakejarvis/jarv.is",
fathomSiteId: "WBGNQUKW",
fathomCustomDomain: "blue-chilly.jarv.is",
let baseURL = ""; // default to relative URLs // Me info
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") { authorName: "Jake Jarvis",
// vercel production (set manually above) twitterHandle: "jakejarvis",
baseURL = `https://${siteDomain}`; facebookAppId: "3357248167622283",
} else if (process.env.NEXT_PUBLIC_VERCEL_URL) { webmentionId: "jarv.is",
// vercel deploy previews monetization: "$ilp.uphold.com/BJp6d2FrEB69",
baseURL = `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
}
export { baseURL };
// Me info // Next.js constants
export const authorName = "Jake Jarvis"; NOTES_DIR: "./notes",
export const twitterHandle = "jakejarvis";
export const facebookAppId = "3357248167622283";
export const webmentionId = "jarv.is";
export const monetization = "$ilp.uphold.com/BJp6d2FrEB69";
// Next.js constants // ...note / TODO: there is still a metric poop ton of this kind of info hard-coded.
export const NOTES_DIR = "notes"; };
// ...note / TODO: there is still a metric poop ton of this kind of info hard-coded.

View File

@@ -12,9 +12,9 @@ export const getNoteData = (file: string) => {
return { return {
...data, ...data,
slug: slug, slug,
date: parseISO(data.date).toISOString(), // validate/normalize the date string provided from front matter date: parseISO(data.date).toISOString(), // validate/normalize the date string provided from front matter
year: parseInt(format(parseISO(data.date), "yyyy")), year: parseInt(format(parseISO(data.date), "yyyy")), // parse years here so it's easier to group them on list page
}; };
}; };

View File

@@ -1,8 +1,7 @@
const config = require("./lib/config");
module.exports = { module.exports = {
siteUrl: siteUrl: config.baseUrl || "https://jarv.is",
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
? "https://jarv.is"
: `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`,
generateRobotsTxt: true, generateRobotsTxt: true,
sitemapSize: 99, sitemapSize: 99,
}; };

View File

@@ -3,118 +3,137 @@
*/ */
const path = require("path"); const path = require("path");
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
const config = require("./lib/config");
const withBundleAnalyzer = require("@next/bundle-analyzer")({ const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true", enabled: process.env.ANALYZE === "true",
}); });
module.exports = withBundleAnalyzer({ module.exports = (phase) => {
swcMinify: true, let BASE_URL = ""; // fallback to relative urls
reactStrictMode: true, if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
trailingSlash: true, // vercel production (set manually)
productionBrowserSourceMaps: true, BASE_URL = `https://jarv.is`;
images: { } else if (process.env.NEXT_PUBLIC_VERCEL_URL) {
formats: ["image/webp"], // vercel deploy previews
deviceSizes: [640, 750, 828, 1080, 1200, 1920], BASE_URL = `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
}, } else if (phase === PHASE_DEVELOPMENT_SERVER) {
experimental: { // local dev server
optimizeFonts: true, BASE_URL = "http://localhost:3000";
optimizeImages: true, }
},
webpack: (config) => { return withBundleAnalyzer({
config.module.rules.push({ swcMinify: true,
test: /\.svg$/, reactStrictMode: true,
issuer: { and: [/\.(js|ts)x?$/] }, trailingSlash: true,
include: [path.resolve(__dirname, "components/icons")], productionBrowserSourceMaps: true,
use: [ env: {
{ BASE_URL,
loader: "@svgr/webpack", },
options: { images: {
icon: true, formats: ["image/webp"],
typescript: true, deviceSizes: [640, 750, 828, 1080, 1200, 1920],
svgProps: { },
className: "icon", experimental: {
optimizeFonts: true,
optimizeImages: true,
},
webpack: (config) => {
config.module.rules.push({
test: /\.svg$/,
issuer: { and: [/\.(js|ts)x?$/] },
include: [path.resolve(__dirname, "components/icons")],
use: [
{
loader: "@svgr/webpack",
options: {
icon: true,
typescript: true,
svgProps: {
className: "icon",
},
}, },
}, },
}, ],
], });
});
return config; return config;
},
headers: async () => [
{
source: "/:path(.*)",
headers: [
{
key: "Onion-Location",
value: "http://jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion/:path*",
},
{
// https://developer.chrome.com/blog/floc/#how-can-websites-opt-out-of-the-floc-computation
key: "Permissions-Policy",
value: "interest-cohort=()",
},
{
key: "Referrer-Policy",
value: "no-referrer-when-downgrade",
},
],
}, },
{ headers: async () => [
source: "/pubkey.asc", {
headers: [ source: "/:path(.*)",
{ headers: [
key: "Cache-Control", {
value: "private, no-cache, no-store, must-revalidate", key: "Onion-Location",
}, value: `http://${config.onionDomain}/:path*`,
{ },
key: "Content-Type", {
value: "text/plain; charset=utf-8", // https://developer.chrome.com/blog/floc/#how-can-websites-opt-out-of-the-floc-computation
}, key: "Permissions-Policy",
], value: "interest-cohort=()",
}, },
], {
rewrites: async () => [ key: "Referrer-Policy",
{ source: "/favicon.ico", destination: "/static/favicons/favicon.ico" }, value: "no-referrer-when-downgrade",
{ source: "/apple-touch-icon.png", destination: "/static/favicons/apple-touch-icon.png" }, },
{ source: "/apple-touch-icon-precomposed.png", destination: "/static/favicons/apple-touch-icon.png" }, ],
{ source: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" }, },
], {
redirects: async () => [ source: "/pubkey.asc",
{ source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 }, headers: [
{ source: "/resume/", destination: "/static/resume.pdf", permanent: false }, {
{ source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false }, key: "Cache-Control",
{ source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false }, value: "private, no-cache, no-store, must-revalidate",
{ source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true }, },
{ source: "/index.xml", destination: "/feed.xml", permanent: true }, {
{ source: "/feed/", destination: "/feed.xml", permanent: true }, key: "Content-Type",
{ source: "/rss/", destination: "/feed.xml", permanent: true }, value: "text/plain; charset=utf-8",
{ source: "/blog/:path*", destination: "/notes/", permanent: true }, },
{ source: "/archives/:path*", destination: "/notes/", permanent: true }, ],
{ },
source: "/2013/11/21/no-homo-still-raps-motto/", ],
destination: "/notes/no-homo-still-raps-motto/", rewrites: async () => [
permanent: true, { source: "/favicon.ico", destination: "/static/favicons/favicon.ico" },
}, { source: "/apple-touch-icon.png", destination: "/static/favicons/apple-touch-icon.png" },
{ { source: "/apple-touch-icon-precomposed.png", destination: "/static/favicons/apple-touch-icon.png" },
source: "/2016/02/28/millenial-with-hillary-clinton/", { source: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" },
destination: "/notes/millenial-with-hillary-clinton/", ],
permanent: true, redirects: async () => [
}, { source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 },
{ { source: "/resume/", destination: "/static/resume.pdf", permanent: false },
source: "/2018/12/04/how-to-shrink-linux-virtual-disk-vmware/", { source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false },
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/", { source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false },
permanent: true, { source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true },
}, { source: "/index.xml", destination: "/feed.xml", permanent: true },
{ { source: "/feed/", destination: "/feed.xml", permanent: true },
source: "/2018/12/07/shrinking-a-linux-virtual-disk-with-vmware/", { source: "/rss/", destination: "/feed.xml", permanent: true },
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/", { source: "/blog/:path*", destination: "/notes/", permanent: true },
permanent: true, { source: "/archives/:path*", destination: "/notes/", permanent: true },
}, {
{ source: "/2013/11/21/no-homo-still-raps-motto/",
source: "/2018/12/10/cool-bash-tricks-for-your-terminal-dotfiles/", destination: "/notes/no-homo-still-raps-motto/",
destination: "/notes/cool-bash-tricks-for-your-terminal-dotfiles/", permanent: true,
permanent: true, },
}, {
], source: "/2016/02/28/millenial-with-hillary-clinton/",
}); destination: "/notes/millenial-with-hillary-clinton/",
permanent: true,
},
{
source: "/2018/12/04/how-to-shrink-linux-virtual-disk-vmware/",
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
permanent: true,
},
{
source: "/2018/12/07/shrinking-a-linux-virtual-disk-with-vmware/",
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
permanent: true,
},
{
source: "/2018/12/10/cool-bash-tricks-for-your-terminal-dotfiles/",
destination: "/notes/cool-bash-tricks-for-your-terminal-dotfiles/",
permanent: true,
},
],
});
};

View File

@@ -49,16 +49,16 @@ const App = ({ Component, pageProps }: AppProps) => {
defaultTitle={`${config.siteName} ${config.shortDescription}`} defaultTitle={`${config.siteName} ${config.shortDescription}`}
titleTemplate={`%s ${config.siteName}`} titleTemplate={`%s ${config.siteName}`}
description={config.longDescription} description={config.longDescription}
canonical={`${config.baseURL}/`} canonical={`${config.baseUrl}/`}
openGraph={{ openGraph={{
site_name: config.siteName, site_name: config.siteName,
title: `${config.siteName} ${config.shortDescription}`, title: `${config.siteName} ${config.shortDescription}`,
url: `${config.baseURL}/`, url: `${config.baseUrl}/`,
locale: "en_US", locale: "en_US",
type: "website", type: "website",
images: [ images: [
{ {
url: `${config.baseURL}${meJpg.src}`, url: `${config.baseUrl}${meJpg.src}`,
alt: `${config.siteName} ${config.shortDescription}`, alt: `${config.siteName} ${config.shortDescription}`,
}, },
], ],
@@ -170,9 +170,9 @@ const App = ({ Component, pageProps }: AppProps) => {
<SocialProfileJsonLd <SocialProfileJsonLd
type="Person" type="Person"
name="Jake Jarvis" name="Jake Jarvis"
url={`${config.baseURL}/`} url={`${config.baseUrl}/`}
sameAs={[ sameAs={[
`${config.baseURL}/`, `${config.baseUrl}/`,
"https://github.com/jakejarvis", "https://github.com/jakejarvis",
"https://keybase.io/jakejarvis", "https://keybase.io/jakejarvis",
"https://twitter.com/jakejarvis", "https://twitter.com/jakejarvis",

View File

@@ -12,8 +12,6 @@ Sentry.init({
environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "", environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "",
}); });
const BASE_URL = config.baseURL === "" ? `https://${config.siteDomain}/` : `${config.baseURL}/`;
const handler = async (req: NextApiRequest, res: NextApiResponse) => { const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try { try {
// permissive access control headers // permissive access control headers
@@ -94,7 +92,7 @@ const getSiteStats = async (client) => {
// get database and RSS results asynchronously // get database and RSS results asynchronously
const parser = new Parser(); const parser = new Parser();
const [feed, result] = await Promise.all([ const [feed, result] = await Promise.all([
parser.parseURL(`${BASE_URL}feed.xml`), parser.parseURL(`${config.baseUrl}/feed.xml`),
client.query( client.query(
q.Map( q.Map(
q.Paginate(q.Documents(q.Collection("hits")), { size: 99 }), q.Paginate(q.Documents(q.Collection("hits")), { size: 99 }),
@@ -111,7 +109,7 @@ const getSiteStats = async (client) => {
pages.map((p) => { pages.map((p) => {
// match URLs from RSS feed with db to populate some metadata // match URLs from RSS feed with db to populate some metadata
const match = feed.items.find((x) => x.link === `${BASE_URL}${p.slug}/`); const match = feed.items.find((x) => x.link === `${config.baseUrl}/${p.slug}/`);
if (match) { if (match) {
p.title = decode(match.title); p.title = decode(match.title);
p.url = match.link; p.url = match.link;

View File

@@ -32,7 +32,7 @@ const Note = ({ source, frontMatter, slug }) => (
}, },
images: [ images: [
{ {
url: `${config.baseURL}${frontMatter.image}`, url: `${config.baseUrl}${frontMatter.image}`,
alt: frontMatter.title, alt: frontMatter.title,
}, },
], ],
@@ -44,15 +44,15 @@ const Note = ({ source, frontMatter, slug }) => (
}} }}
/> />
<ArticleJsonLd <ArticleJsonLd
url={`${config.baseURL}/notes/${slug}`} url={`${config.baseUrl}/notes/${slug}`}
title={frontMatter.title} title={frontMatter.title}
description={frontMatter.description} description={frontMatter.description}
datePublished={frontMatter.date} datePublished={frontMatter.date}
dateModified={frontMatter.date} dateModified={frontMatter.date}
images={[`${config.baseURL}${frontMatter.image}`]} images={[`${config.baseUrl}${frontMatter.image}`]}
authorName={[config.authorName]} authorName={[config.authorName]}
publisherName={config.siteName} publisherName={config.siteName}
publisherLogo={`${config.baseURL}/static/images/me.jpg`} publisherLogo={`${config.baseUrl}/static/images/me.jpg`}
/> />
<Layout> <Layout>