mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-11-05 07:05:40 -05:00
remove dependency on uglify-js
This commit is contained in:
@@ -18,6 +18,7 @@ module.exports = {
|
||||
verifyGoogle: "qQhmLTwjNWYgQ7W42nSTq63xIrTch13X_11mmxBE9zk",
|
||||
verifyBing: "164551986DA47F7F6FC0D21A93FFFCA6",
|
||||
fathomSiteId: "PIUEIVIZ",
|
||||
hcaptchaSiteKey: "60d959de-b01b-4e22-a901-ce395ed086cb",
|
||||
giscusConfig: {
|
||||
// https://github.com/giscus/giscus-component/tree/main/packages/react#readme
|
||||
repo: "jakejarvis/jarv.is",
|
||||
|
||||
@@ -3,6 +3,8 @@ import { meJpg, faviconPng, faviconIco, appleTouchIconPng } from "./favicons";
|
||||
|
||||
import type { DefaultSeoProps, SocialProfileJsonLdProps, ArticleJsonLdProps } from "next-seo";
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || `https://${config.siteDomain}`;
|
||||
|
||||
// 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
|
||||
@@ -17,7 +19,7 @@ export const defaultSeo: DefaultSeoProps = {
|
||||
type: "website",
|
||||
images: [
|
||||
{
|
||||
url: `${process.env.BASE_URL}${meJpg.src}`,
|
||||
url: `${baseUrl}${meJpg.src}`,
|
||||
alt: `${config.siteName} – ${config.shortDescription}`,
|
||||
},
|
||||
],
|
||||
@@ -95,9 +97,9 @@ export const defaultSeo: DefaultSeoProps = {
|
||||
export const socialProfileJsonLd: SocialProfileJsonLdProps = {
|
||||
type: "Person",
|
||||
name: config.authorName,
|
||||
url: `${process.env.BASE_URL}/`,
|
||||
url: `${baseUrl}/`,
|
||||
sameAs: [
|
||||
`${process.env.BASE_URL}/`,
|
||||
`${baseUrl}/`,
|
||||
`https://github.com/${config.authorSocial?.github}`,
|
||||
`https://keybase.io/${config.authorSocial?.keybase}`,
|
||||
`https://twitter.com/${config.authorSocial?.twitter}`,
|
||||
@@ -114,8 +116,8 @@ export const socialProfileJsonLd: SocialProfileJsonLdProps = {
|
||||
export const articleJsonLd: Pick<ArticleJsonLdProps, "authorName" | "publisherName" | "publisherLogo"> = {
|
||||
authorName: {
|
||||
name: config.authorName,
|
||||
url: `${process.env.BASE_URL}/`,
|
||||
url: `${baseUrl}/`,
|
||||
},
|
||||
publisherName: config.siteName,
|
||||
publisherLogo: `${process.env.BASE_URL}${meJpg.src}`,
|
||||
publisherLogo: `${baseUrl}${meJpg.src}`,
|
||||
};
|
||||
|
||||
@@ -18,23 +18,24 @@ export const buildFeed = async (
|
||||
options?: BuildFeedOptions
|
||||
): Promise<ReturnType<GetServerSideFeedProps>> => {
|
||||
const { res } = context;
|
||||
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || `https://${config.siteDomain}`;
|
||||
|
||||
// https://github.com/jpmonette/feed#example
|
||||
const feed = new Feed({
|
||||
id: `${process.env.BASE_URL}/`,
|
||||
link: `${process.env.BASE_URL}/`,
|
||||
id: `${baseUrl}/`,
|
||||
link: `${baseUrl}/`,
|
||||
title: config.siteName,
|
||||
description: config.longDescription,
|
||||
copyright: config.licenseUrl,
|
||||
updated: new Date(process.env.RELEASE_DATE || Date.now()),
|
||||
image: `${process.env.BASE_URL}${meJpg.src}`,
|
||||
image: `${baseUrl}${meJpg.src}`,
|
||||
feedLinks: {
|
||||
rss: `${process.env.BASE_URL}/feed.xml`,
|
||||
atom: `${process.env.BASE_URL}/feed.atom`,
|
||||
rss: `${baseUrl}/feed.xml`,
|
||||
atom: `${baseUrl}/feed.atom`,
|
||||
},
|
||||
author: {
|
||||
name: config.authorName,
|
||||
link: `${process.env.BASE_URL}/`,
|
||||
link: `${baseUrl}/`,
|
||||
email: config.authorEmail,
|
||||
},
|
||||
});
|
||||
@@ -47,11 +48,11 @@ export const buildFeed = async (
|
||||
link: note.permalink,
|
||||
title: note.title,
|
||||
description: note.description,
|
||||
image: note.image && `${process.env.BASE_URL}${note.image}`,
|
||||
image: note.image && `${baseUrl}${note.image}`,
|
||||
author: [
|
||||
{
|
||||
name: config.authorName,
|
||||
link: `${process.env.BASE_URL}/`,
|
||||
link: `${baseUrl}/`,
|
||||
},
|
||||
],
|
||||
date: new Date(note.date),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
import { minify } from "uglify-js";
|
||||
import { getNoteData } from "./parse-notes";
|
||||
|
||||
import type { NoteWithSource } from "../../types";
|
||||
@@ -12,7 +11,7 @@ export const compileNote = async (slug: string): Promise<NoteWithSource> => {
|
||||
"./remark-rehype-plugins"
|
||||
);
|
||||
|
||||
const source = await serialize(content, {
|
||||
const { compiledSource } = await serialize(content, {
|
||||
parseFrontmatter: false,
|
||||
mdxOptions: {
|
||||
remarkPlugins: [
|
||||
@@ -40,19 +39,6 @@ export const compileNote = async (slug: string): Promise<NoteWithSource> => {
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: next-mdx-remote v4 doesn't (yet?) minify compiled JSX output, see:
|
||||
// https://github.com/hashicorp/next-mdx-remote/pull/211#issuecomment-1013658514
|
||||
// ...so for now, let's do it manually (and conservatively) with uglify-js when building for production.
|
||||
const compiledSource =
|
||||
process.env.NODE_ENV === "production"
|
||||
? minify(source.compiledSource, {
|
||||
toplevel: true,
|
||||
parse: {
|
||||
bare_returns: true,
|
||||
},
|
||||
}).code
|
||||
: source.compiledSource;
|
||||
|
||||
return {
|
||||
frontMatter,
|
||||
source: {
|
||||
|
||||
@@ -69,7 +69,7 @@ export const getNoteData = async (
|
||||
title,
|
||||
htmlTitle,
|
||||
slug,
|
||||
permalink: `${process.env.BASE_URL}/notes/${slug}/`,
|
||||
permalink: `${process.env.NEXT_PUBLIC_BASE_URL || ""}/notes/${slug}/`,
|
||||
date: formatDate(data.date), // validate/normalize the date string provided from front matter
|
||||
},
|
||||
content,
|
||||
|
||||
Reference in New Issue
Block a user