From ba10742c9b3d1cf2b176c8d070c5bec261dc387a Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Mon, 3 Mar 2025 15:56:57 -0500 Subject: [PATCH] properly import and optimize/cache images in markdown files --- .env.example | 4 - app/birthday/page.tsx | 2 +- app/cli/page.tsx | 4 +- app/contact/actions.ts | 7 +- app/contact/form.tsx | 24 +- app/contact/page.tsx | 5 +- app/hillary/page.tsx | 2 +- app/layout.tsx | 39 ++- app/leo/page.tsx | 2 +- app/license/page.tsx | 6 +- app/manifest.ts | 8 +- app/notes/[slug]/page.module.css | 14 +- app/notes/[slug]/page.tsx | 61 +--- app/page.tsx | 2 +- app/previously/page.module.css | 4 - app/previously/page.tsx | 29 +- app/projects/page.tsx | 4 +- app/robots.ts | 3 +- app/sitemap.ts | 17 +- app/themes.css | 1 - app/uses/page.tsx | 4 +- app/zip/page.tsx | 4 +- components/Footer/Footer.module.css | 1 + components/Footer/Footer.tsx | 8 +- components/Header/Header.module.css | 6 +- components/Header/Header.tsx | 2 +- components/HeadingAnchor/HeadingAnchor.tsx | 9 +- components/Image/Image.tsx | 70 +--- components/Layout/Layout.module.css | 10 - components/Layout/Layout.tsx | 4 +- components/Link/Link.module.css | 19 +- components/Link/Link.tsx | 25 +- components/Menu/Menu.tsx | 2 +- components/MenuItem/MenuItem.tsx | 8 +- components/OctocatLink/OctocatLink.tsx | 2 +- components/PageTitle/PageTitle.tsx | 2 +- components/TweetEmbed/TweetEmbed.module.css | 2 +- components/TweetEmbed/TweetEmbed.tsx | 53 ++- components/Video/Video.tsx | 6 +- contexts/ThemeContext.tsx | 13 +- lib/config/favicons.ts | 13 - lib/config/index.js | 7 +- lib/config/menu.ts | 8 +- lib/helpers/build-feed.ts | 20 +- lib/helpers/mdx-components.ts | 25 -- lib/helpers/posts.ts | 6 +- lib/helpers/remark-rehype-plugins.ts | 4 + mdx-components.ts | 49 +++ middleware.ts | 9 +- next.config.ts | 46 ++- notes/bernie-sanders-bern-app-data.mdx | 66 +--- notes/cloudflare-dns-archive-is-blocked.mdx | 8 +- ...bash-tricks-for-your-terminal-dotfiles.mdx | 8 +- notes/coronavirus-open-source.mdx | 90 +---- notes/dropping-dropbox.mdx | 20 +- ...finding-candidates-subdomain-takeovers.mdx | 12 +- notes/github-actions.mdx | 19 +- notes/github-rename-master.mdx | 24 +- notes/how-to-backup-linux-server.mdx | 11 +- notes/how-to-pull-request-fork-github.mdx | 28 +- ...ow-to-shrink-linux-virtual-disk-vmware.mdx | 16 +- notes/hugo-to-nextjs.mdx | 16 +- notes/millenial-with-hillary-clinton.mdx | 22 +- notes/my-first-code.mdx | 37 +- notes/netlify-analytics-review.mdx | 29 +- notes/presidential-candidates-404-pages.mdx | 114 +----- notes/security-headers-cloudflare-workers.mdx | 17 +- notes/shodan-search-queries.mdx | 210 ++--------- notes/y2k-sandbox.mdx | 14 +- package.json | 18 +- pnpm-lock.yaml | 331 +++++++++++++----- 71 files changed, 685 insertions(+), 1100 deletions(-) delete mode 100644 lib/config/favicons.ts delete mode 100644 lib/helpers/mdx-components.ts create mode 100644 mdx-components.ts diff --git a/.env.example b/.env.example index 156c5ad9..f7058992 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,3 @@ -# required. falls back to relative URLs in most places, but still must be set in the Vercel dashboard for production. -# include https:// and leave out the trailing slash, e.g. "https://jarv.is". -NEXT_PUBLIC_BASE_URL= - # required. storage for hit counter endpoints at /api/count and /api/hits. # currently uses Postgres, but this can be changed in prisma/schema.prisma. # https://www.prisma.io/docs/postgres/overview diff --git a/app/birthday/page.tsx b/app/birthday/page.tsx index 6976094a..63c938e7 100644 --- a/app/birthday/page.tsx +++ b/app/birthday/page.tsx @@ -31,8 +31,8 @@ export default function Page() { src={{ webm: "/static/images/birthday/birthday.webm", mp4: "/static/images/birthday/birthday.mp4", - image: thumbnail.src, }} + poster={thumbnail.src} /> diff --git a/app/cli/page.tsx b/app/cli/page.tsx index f23df61d..e4a37940 100644 --- a/app/cli/page.tsx +++ b/app/cli/page.tsx @@ -37,7 +37,9 @@ export default function Page() { anyone, ever). - Terminal Screenshot + + Terminal Screenshot +

Usage

npx @jakejarvis/cli diff --git a/app/contact/actions.ts b/app/contact/actions.ts index c903b448..fe57dd56 100644 --- a/app/contact/actions.ts +++ b/app/contact/actions.ts @@ -15,7 +15,7 @@ export async function sendMessage( try { // these are both backups to client-side validations just in case someone squeezes through without them. the codes // are identical so they're caught in the same fashion. - if (!formData.get("name") || !formData.get("email") || !formData.get("message")) { + if (!formData || !formData.get("name") || !formData.get("email") || !formData.get("message")) { return { success: false, message: "Please make sure that all fields are properly filled in.", payload: formData }; } @@ -30,7 +30,7 @@ export async function sendMessage( }); const turnstileData = await turnstileResponse.json(); - if (!turnstileData.success) { + if (!turnstileData || !turnstileData.success) { return { success: false, message: "Did you complete the CAPTCHA? (If you're human, that is...)", @@ -44,13 +44,14 @@ export async function sendMessage( from: `${formData.get("name")} <${process.env.RESEND_DOMAIN ? `noreply@${process.env.RESEND_DOMAIN}` : "onboarding@resend.dev"}>`, replyTo: `${formData.get("name")} <${formData.get("email")}>`, to: [config.authorEmail], - subject: `[${config.siteDomain}] Contact Form Submission`, + subject: `[${config.siteName}] Contact Form Submission`, text: formData.get("message") as string, }); return { success: true, message: "Thanks! You should hear from me soon.", payload: formData }; } catch (error) { console.error(error); + return { success: false, message: "Internal server error... Try again later or shoot me an old-fashioned email?", diff --git a/app/contact/form.tsx b/app/contact/form.tsx index f3280889..386e2e3b 100644 --- a/app/contact/form.tsx +++ b/app/contact/form.tsx @@ -27,8 +27,8 @@ const ContactForm = () => { placeholder="Name" required className={styles.input} - defaultValue={(formState.payload?.get("name") || "") as string} - disabled={formState.success} + defaultValue={(formState?.payload?.get("name") || "") as string} + disabled={formState?.success} /> { required inputMode="email" className={styles.input} - defaultValue={(formState.payload?.get("email") || "") as string} - disabled={formState.success} + defaultValue={(formState?.payload?.get("email") || "") as string} + disabled={formState?.success} /> { minRows={5} required className={styles.input} - defaultValue={(formState.payload?.get("message") || "") as string} - disabled={formState.success} + defaultValue={(formState?.payload?.get("message") || "") as string} + disabled={formState?.success} />
{ Markdown syntax {" "} is allowed here, e.g.: **bold**, _italics_, [ - + links ](https://jarv.is), and `code`. @@ -86,7 +86,7 @@ const ContactForm = () => { />
- {!formState.success && ( + {!formState?.success && ( )} - {formState.message && ( -
- {formState.success ? : }{" "} - {formState.message} + {formState?.message && ( +
+ {formState?.success ? : }{" "} + {formState?.message}
)}
diff --git a/app/contact/page.tsx b/app/contact/page.tsx index 30b6eb19..a78fd397 100644 --- a/app/contact/page.tsx +++ b/app/contact/page.tsx @@ -31,9 +31,8 @@ export default function Page() { >

Fill out this quick form and I'll get back to you as soon as I can! You can also{" "} - email me directly, send me a{" "} - direct message on Mastodon, or{" "} - text me. + email me directly or send me a{" "} + direct message on Mastodon.

๐Ÿ” You can grab my public key here:{" "} diff --git a/app/hillary/page.tsx b/app/hillary/page.tsx index 348e1382..91081970 100644 --- a/app/hillary/page.tsx +++ b/app/hillary/page.tsx @@ -33,8 +33,8 @@ export default function Page() { webm: "/static/images/hillary/convention-720p.webm", mp4: "/static/images/hillary/convention-720p.mp4", vtt: "/static/images/hillary/subs.en.vtt", - image: thumbnail.src, }} + poster={thumbnail.src} />

= { "@context": "https://schema.org", "@type": "Person", name: config.authorName, - url: metadata.metadataBase?.href || `https://${config.siteDomain}/`, - image: new URL(meJpg.src, metadata.metadataBase || `https://${config.siteDomain}`).href, + url: config.baseUrl, + image: `${config.baseUrl}${meJpg.src}`, sameAs: [ - metadata.metadataBase?.href || `https://${config.siteDomain}/`, + config.baseUrl, `https://github.com/${config.authorSocial?.github}`, `https://keybase.io/${config.authorSocial?.keybase}`, `https://twitter.com/${config.authorSocial?.twitter}`, @@ -73,13 +83,6 @@ export default function RootLayout({ children }: { children: React.ReactNode }) return ( -