1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 15:16:40 -04:00

less resource-intensive methods of parsing URLs

This commit is contained in:
2022-06-01 18:40:57 -04:00
parent d1ee8b2632
commit 33c210aacf
16 changed files with 195 additions and 188 deletions

View File

@ -2,7 +2,6 @@ import { useEffect } from "react";
import { useRouter } from "next/router";
import { DefaultSeo, SocialProfileJsonLd } from "next-seo";
import * as Fathom from "fathom-client";
import urlJoin from "url-join";
import { ThemeProvider } from "../contexts/ThemeContext";
import Layout from "../components/Layout";
import * as config from "../lib/config";
@ -25,7 +24,7 @@ const App = ({ Component, pageProps }: AppProps) => {
// get this page's URL with full domain, and hack around query parameters and anchors
// NOTE: this assumes trailing slashes are enabled in next.config.js
const canonical = urlJoin(config.baseUrl, router.pathname === "/" ? "" : router.pathname, "/");
const canonical = `${config.baseUrl}${router.pathname === "/" ? "" : router.pathname}/`;
useEffect(() => {
// don't track pageviews on branch/deploy previews and localhost

View File

@ -1,7 +1,6 @@
import { InView } from "react-intersection-observer";
import { NextSeo, ArticleJsonLd } from "next-seo";
import { MDXRemote } from "next-mdx-remote";
import urlJoin from "url-join";
import Content from "../../components/Content";
import NoteMeta from "../../components/NoteMeta";
import Comments from "../../components/Comments";
@ -31,7 +30,7 @@ const Note = ({ frontMatter, source }: Note) => {
},
images: frontMatter.image && [
{
url: urlJoin(config.baseUrl, frontMatter.image),
url: `${config.baseUrl}${frontMatter.image}`,
alt: frontMatter.title,
},
],
@ -46,7 +45,7 @@ const Note = ({ frontMatter, source }: Note) => {
description={frontMatter.description}
datePublished={frontMatter.date}
dateModified={frontMatter.date}
images={frontMatter.image && [urlJoin(config.baseUrl, frontMatter.image)]}
images={frontMatter.image && [`${config.baseUrl}${frontMatter.image}`]}
{...articleJsonLd}
/>