Skip to content

Commit

Permalink
fix(routing): 🐛 remove baseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydrichards committed May 15, 2024
1 parent 4814056 commit b1ca8d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/app/(posts)/blogs/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Metadata } from "next";
import "@/styles/mdx.css";
import { getBlog } from "@/service/get-blog";
import { getAllBlogs } from "@/service/get-all-blog";
import { getBaseUrl } from "@/lib/utils";

export interface BlogPageProps {
params: {
Expand All @@ -15,7 +14,7 @@ export async function generateMetadata({
params,
}: BlogPageProps): Promise<Metadata> {
const { title, description, slug } = await getBlog(params.slug);
const ogImage = `${getBaseUrl()}/api/og?title=${encodeURIComponent(title)}`;
const ogImage = `/api/og?title=${encodeURIComponent(title)}`;

return {
title,
Expand All @@ -24,7 +23,7 @@ export async function generateMetadata({
title,
description,
type: "article",
url: `${getBaseUrl()}${slug}`,
url: slug,
images: [
{
url: ogImage,
Expand Down
5 changes: 2 additions & 3 deletions src/app/(posts)/labs/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Metadata } from "next";
import { FC } from "react";
import { getLab } from "@/service/get-lab";
import { getAllLabs } from "@/service/get-all-lab";
import { getBaseUrl } from "@/lib/utils";

export interface LabPageProps {
params: {
Expand All @@ -28,7 +27,7 @@ export async function generateMetadata({
params,
}: LabPageProps): Promise<Metadata> {
const { title, description, slug } = await getLab(params.slug);
const ogImage = `${getBaseUrl()}/api/og?title=${encodeURIComponent(title)}`;
const ogImage = `/api/og?title=${encodeURIComponent(title)}`;

return {
title,
Expand All @@ -37,7 +36,7 @@ export async function generateMetadata({
title,
description,
type: "article",
url: `${getBaseUrl()}${slug}`,
url: slug,
images: [
{
url: ogImage,
Expand Down
18 changes: 9 additions & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ import { Layout } from "@/components/template/layout/layout";
import { ThemeProvider } from "next-themes";

import "../styles/globals.css";
import { getBaseUrl } from "@/lib/utils";

export const metadata = {
title: "Lloyd Richards Design",
description:
"Digital playground of Lloyd Richards, a designer and developer.",
icons: {
icon: "/favicon.svg",
icon: `/favicon.svg`,
},
openGraph: {
locale: "en_US",
url: getBaseUrl(),
title: "Lloyd Richards Design",
description:
"Digital playground of Lloyd Richards, a designer and developer.",
images: [
{
url: `${getBaseUrl()}/images/lloyd_richards_portrait.png`,
width: 400,
height: 600,
alt: "Lloyd Richards Portrait",
url: `/images/lloyd_richards_portrait.png`,
},
],
siteName: "Lloyd Richards Design",
},
twitter: {
card: "summary_large_image",
title: "Lloyd Richards Design",
description:
"Digital playground of Lloyd Richards, a designer and developer.",
images: [`/images/lloyd_richards_portrait.png`],
},
};

Expand Down
4 changes: 2 additions & 2 deletions src/lab_modules/033.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const handleErrors = (appError: AppError): T.Task<string> => {
}
};

const getFromUrl = (url: string) =>
const _getFromUrl = (url: string) =>
pipe(
TE.tryCatch(
() => fetch(url),
Expand All @@ -105,7 +105,7 @@ const getFromUrl = (url: string) =>
TE.fold(handleErrors, (data) => T.of(data.value.name)),
);

getFromUrl("https://api.chucknorris.io/jokes/random")().then(console.log); // Output: "Invalid value undefined supplied to : { status: string, value: { id: number, name: string } }/status: string"
// getFromUrl("https://api.chucknorris.io/jokes/random")().then(console.log); // Output: "Invalid value undefined supplied to : { status: string, value: { id: number, name: string } }/status: string"

/*
* Branching Render Logic
Expand Down

0 comments on commit b1ca8d3

Please sign in to comment.