1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-11-05 08:45:41 -05:00

remove dependency on uglify-js

This commit is contained in:
2024-02-26 10:49:14 -05:00
parent ace50ff2c9
commit 955cfe421f
19 changed files with 239 additions and 418 deletions

View File

@@ -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),

View File

@@ -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: {

View File

@@ -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,