1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-06-30 22:46:39 -04: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
title={title}
description={description}
canonical={`${config.baseURL}${router.asPath}`}
canonical={`${config.baseUrl}${router.asPath}`}
openGraph={{
title: title,
url: `${config.baseURL}${router.asPath}`,
url: `${config.baseUrl}${router.asPath}`,
}}
/>
<div className={styles.container}>{children}</div>

View File

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

View File

@ -1,33 +1,27 @@
// Site info
export const siteName = "Jake Jarvis";
export const siteDomain = "jarv.is";
export const shortDescription = "Front-End Web Developer in Boston, MA";
export const longDescription =
"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 themeColorLight = "#fcfcfc";
export const themeColorDark = "#252525";
export const githubRepo = "jakejarvis/jarv.is";
export const fathomSiteId = "WBGNQUKW";
export const fathomCustomDomain = "blue-chilly.jarv.is";
module.exports = {
// Site info
siteName: "Jake Jarvis",
siteDomain: "jarv.is",
onionDomain: "jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion",
baseUrl: process.env.BASE_URL,
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.",
themeColorLight: "#fcfcfc",
themeColorDark: "#252525",
githubRepo: "jakejarvis/jarv.is",
fathomSiteId: "WBGNQUKW",
fathomCustomDomain: "blue-chilly.jarv.is",
let baseURL = ""; // default to relative URLs
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
// vercel production (set manually above)
baseURL = `https://${siteDomain}`;
} else if (process.env.NEXT_PUBLIC_VERCEL_URL) {
// vercel deploy previews
baseURL = `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
}
export { baseURL };
// Me info
authorName: "Jake Jarvis",
twitterHandle: "jakejarvis",
facebookAppId: "3357248167622283",
webmentionId: "jarv.is",
monetization: "$ilp.uphold.com/BJp6d2FrEB69",
// Me info
export const authorName = "Jake Jarvis";
export const twitterHandle = "jakejarvis";
export const facebookAppId = "3357248167622283";
export const webmentionId = "jarv.is";
export const monetization = "$ilp.uphold.com/BJp6d2FrEB69";
// Next.js constants
NOTES_DIR: "./notes",
// Next.js constants
export const NOTES_DIR = "notes";
// ...note / TODO: there is still a metric poop ton of this kind of info hard-coded.
// ...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 {
...data,
slug: slug,
slug,
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 = {
siteUrl:
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
? "https://jarv.is"
: `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`,
siteUrl: config.baseUrl || "https://jarv.is",
generateRobotsTxt: true,
sitemapSize: 99,
};

View File

@ -3,118 +3,137 @@
*/
const path = require("path");
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
const config = require("./lib/config");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
module.exports = withBundleAnalyzer({
swcMinify: true,
reactStrictMode: true,
trailingSlash: true,
productionBrowserSourceMaps: true,
images: {
formats: ["image/webp"],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
},
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",
module.exports = (phase) => {
let BASE_URL = ""; // fallback to relative urls
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
// vercel production (set manually)
BASE_URL = `https://jarv.is`;
} else if (process.env.NEXT_PUBLIC_VERCEL_URL) {
// vercel deploy previews
BASE_URL = `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
} else if (phase === PHASE_DEVELOPMENT_SERVER) {
// local dev server
BASE_URL = "http://localhost:3000";
}
return withBundleAnalyzer({
swcMinify: true,
reactStrictMode: true,
trailingSlash: true,
productionBrowserSourceMaps: true,
env: {
BASE_URL,
},
images: {
formats: ["image/webp"],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
},
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;
},
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",
},
],
return config;
},
{
source: "/pubkey.asc",
headers: [
{
key: "Cache-Control",
value: "private, no-cache, no-store, must-revalidate",
},
{
key: "Content-Type",
value: "text/plain; charset=utf-8",
},
],
},
],
rewrites: async () => [
{ 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: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" },
],
redirects: async () => [
{ source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 },
{ source: "/resume/", destination: "/static/resume.pdf", permanent: false },
{ source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false },
{ source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false },
{ source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true },
{ source: "/index.xml", destination: "/feed.xml", permanent: true },
{ source: "/feed/", destination: "/feed.xml", permanent: true },
{ source: "/rss/", destination: "/feed.xml", permanent: true },
{ 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/",
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,
},
],
});
headers: async () => [
{
source: "/:path(.*)",
headers: [
{
key: "Onion-Location",
value: `http://${config.onionDomain}/: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",
},
],
},
{
source: "/pubkey.asc",
headers: [
{
key: "Cache-Control",
value: "private, no-cache, no-store, must-revalidate",
},
{
key: "Content-Type",
value: "text/plain; charset=utf-8",
},
],
},
],
rewrites: async () => [
{ 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: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" },
],
redirects: async () => [
{ source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 },
{ source: "/resume/", destination: "/static/resume.pdf", permanent: false },
{ source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false },
{ source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false },
{ source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true },
{ source: "/index.xml", destination: "/feed.xml", permanent: true },
{ source: "/feed/", destination: "/feed.xml", permanent: true },
{ source: "/rss/", destination: "/feed.xml", permanent: true },
{ 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/",
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}`}
titleTemplate={`%s ${config.siteName}`}
description={config.longDescription}
canonical={`${config.baseURL}/`}
canonical={`${config.baseUrl}/`}
openGraph={{
site_name: config.siteName,
title: `${config.siteName} ${config.shortDescription}`,
url: `${config.baseURL}/`,
url: `${config.baseUrl}/`,
locale: "en_US",
type: "website",
images: [
{
url: `${config.baseURL}${meJpg.src}`,
url: `${config.baseUrl}${meJpg.src}`,
alt: `${config.siteName} ${config.shortDescription}`,
},
],
@ -170,9 +170,9 @@ const App = ({ Component, pageProps }: AppProps) => {
<SocialProfileJsonLd
type="Person"
name="Jake Jarvis"
url={`${config.baseURL}/`}
url={`${config.baseUrl}/`}
sameAs={[
`${config.baseURL}/`,
`${config.baseUrl}/`,
"https://github.com/jakejarvis",
"https://keybase.io/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 || "",
});
const BASE_URL = config.baseURL === "" ? `https://${config.siteDomain}/` : `${config.baseURL}/`;
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try {
// permissive access control headers
@ -94,7 +92,7 @@ const getSiteStats = async (client) => {
// get database and RSS results asynchronously
const parser = new Parser();
const [feed, result] = await Promise.all([
parser.parseURL(`${BASE_URL}feed.xml`),
parser.parseURL(`${config.baseUrl}/feed.xml`),
client.query(
q.Map(
q.Paginate(q.Documents(q.Collection("hits")), { size: 99 }),
@ -111,7 +109,7 @@ const getSiteStats = async (client) => {
pages.map((p) => {
// 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) {
p.title = decode(match.title);
p.url = match.link;

View File

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