Skip to content

Commit

Permalink
Next.js 15 Chore/update (#137)
Browse files Browse the repository at this point in the history
* removed dummy sitemap and using route sitemap

* removed consoles

* removed swc

* metadata to viewport export

* deri upgrade to latest

* next canary stable

* updated client on about page
  • Loading branch information
Riley1101 authored Nov 2, 2024
1 parent a78ab27 commit dc4954b
Show file tree
Hide file tree
Showing 48 changed files with 1,811 additions and 2,595 deletions.
2 changes: 1 addition & 1 deletion actions/postAcions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const getArticles = cache(async function (): Promise<ArticlCardType[]> {
});

export const getArticleBySlug = cache(async function (
slug?: string,
slug: string,
): Promise<ArticleDetailType> {
const query = `
*[_type == "article" && slug.current == $slug][0]{
Expand Down
33 changes: 33 additions & 0 deletions app/(web)/404/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import Link from "next/link";
import Image from "next/image";

export default function NotFound() {
return (
<div className="pt-24 page-container">
<div>
<Image
src="/images/puglie-pug.gif"
alt="sad pug "
className="mb-8 aspect-square rounded-full border border-theme-accent-opaque"
width={150}
height={150}
/>
<h1 className="text-3xl lg:text-5xl text-theme-primary font-theme font-bold mb-12">
😟 Oops! Page Not Found
</h1>
<p className="text-lg mt-4 mb-4 leading-loose ">
Page you’re looking for. It might have been moved, deleted, or never
existed.
<Link
className={` mt-4 max-w-max flex cursor-pointer items-center hover:text-theme-accent py-3 hover:bg-theme-accent-opaque duration-300 transition-all border px-4 rounded-full
bg-theme-primary bg-opacity-5 border-opacity-5 border-theme-primary text-theme-accent`}
href="/articles"
>
Articles
</Link>
</p>
</div>
</div>
);
}
13 changes: 6 additions & 7 deletions app/(web)/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
export const revalidate = 60;
import dynamic from "next/dynamic";
import Image from "next/image";

import ComputerModel from "@/components/common/model/ModelWrapper";
import Hero from "@/components/pages/hero";
import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";
import Image from "next/image";
import type { Metadata } from "next";

const ComputerModel = dynamic(() => import("@/components/common/model"), {
ssr: false,
});
import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";

const hero = {
title: "About",
Expand All @@ -17,12 +14,14 @@ const hero = {

export const metadata: Metadata = {
title: "About | Arkar Myat",

openGraph: getOpenGraph(
"/images/arkar.png",
"About | " + metaData.title,
metaData.description,
new URL("/about", metaData.url),
),

twitter: getTwitterCard(
"/images/arkar.png",
"About | " + metaData.title,
Expand Down
15 changes: 9 additions & 6 deletions app/(web)/articles/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
getArticleSEOContentBySlug,
} from "@/actions/postAcions";
import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";
import { redirect } from "next/navigation";

export async function generateMetadata({
params,
}: {
params: { slug: string };
export async function generateMetadata(props: {
params: Promise<{ slug: string }>;
}) {
const params = await props.params;
const data: ArticleDetailType = await getArticleSEOContentBySlug(params.slug);
return {
title: data?.title,
Expand All @@ -36,8 +36,11 @@ export async function generateMetadata({

async function ArticleDetailPage(props: DetailPageParamTypes) {
const { params } = props;
const data = await getArticleBySlug(params?.slug);
if (data === null) return <></>;
const { slug } = await params;
const data = await getArticleBySlug(slug);
if (data === null) {
return redirect("/404");
}
return (
<div className="page-container md:gap-4 lg:gap-12">
<div className="flex shrink page-left flex-col gap-4">
Expand Down
12 changes: 8 additions & 4 deletions app/(web)/articles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";

export const metadata: Metadata = {
title: "Articles | Arkar",

openGraph: getOpenGraph(
"/images/articles.png",
"Articles | " + metaData.title,
metaData.description,
new URL("/articles", metaData.url),
),

twitter: getTwitterCard(
"/images/articles.png",
"Articles | " + metaData.title,
metaData.description,
),
};

export default async function ArticlePage(props: {
searchParams?: { category: string | undefined };
export default async function ArticlePage({
searchParams,
}: {
searchParams?: Promise<{ category: string | undefined }>;
}) {
const { searchParams } = props;
const param = await searchParams;
const categories = await getCategories();
return (
<div className="page-container gap-4 md:gap-12">
Expand All @@ -34,7 +38,7 @@ export default async function ArticlePage(props: {
<div className="block md:hidden row-start-1 lg:col-start-2">
<Categories categories={categories} />
</div>
<ArticleTimeLine current={searchParams?.category} />
<ArticleTimeLine current={param?.category} />
</div>
<div className="page-right hidden md:block row-start-1 lg:col-start-2">
<Categories categories={categories} />
Expand Down
9 changes: 8 additions & 1 deletion app/(web)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "@styles/globals.css";
import "dracula-prism/dist/css/dracula-prism.min.css";
import "katex/dist/katex.min.css";
import GradientMesh from "@/components/common/gradient-mesh";
import Header from "@/components/common/header";
import NavAside from "@/components/common/nav-aside";
Expand All @@ -13,26 +12,32 @@ import { CSPostHogProvider } from "@/components/providers/PostHogProvider";

export const metadata: Metadata = {
metadataBase: new URL(process.env.NEXT_PUBLIC_DOMAIN || ""),

title: {
default: metaData.title,
template: "%s",
},

description: metaData.description,
generator: "Next.js",
applicationName: metaData.siteName,
referrer: "origin-when-cross-origin",
keywords: metaData.keywords,

authors: [
{ name: metaData.title, url: metaData.url },
{ name: "Arkar Myat", url: "https://arkar.space" },
],

creator: metaData.title,
publisher: metaData.title,

formatDetection: {
email: false,
address: false,
telephone: false,
},

robots: {
index: true,
follow: true,
Expand All @@ -46,12 +51,14 @@ export const metadata: Metadata = {
"max-snippet": -1,
},
},

openGraph: getOpenGraph(
"/images/arkar.png",
metaData.title,
metaData.description,
metaData.url,
),

twitter: getTwitterCard(
"/images/arkar.png",
metaData.title,
Expand Down
12 changes: 8 additions & 4 deletions app/(web)/newsletter/sorry-to-see-you-go/[email]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
"use client";
import Image from "next/image";
import Link from "next/link";
import React, { useState } from "react";
import React, { useState, use } from "react";
import { unsubscribe } from "@/actions/newsLetterActions";
import { useTransition } from "react";

export default function ByeBye({ params }: any) {
export default function ByeBye({
params,
}: {
params: Promise<{ email: string }>;
}) {
const p = use(params);
const [message, setMessage] = useState("Unsubscribe");
const { email } = params;
let [isPending, startTransition] = useTransition();
let mail = decodeURIComponent(email);
let mail = decodeURIComponent(p.email);
return (
<div className="pt-24 page-container">
<div>
Expand Down
11 changes: 11 additions & 0 deletions app/(web)/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from "next/link";

export default function NotFound() {
return (
<div>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</div>
);
}
20 changes: 12 additions & 8 deletions app/(web)/projects/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export const revalidate = 60;

import Hero from "@/components/pages/article/hero";
import client from "@/utils/client";
import type { Project } from "@/types/page/testimonials";
import PortableBody from "@/components/common/portable";
import TableOfContents from "@/components/common/toc";
import client from "@/utils/client";
import type { DetailPageParamTypes } from "@/types";
import type { Project } from "@/types/page/testimonials";
import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";
import { redirect } from "next/navigation";

const query = `
*[_type == "project" && slug.current == $slug][0]{
Expand All @@ -16,11 +18,10 @@ const query = `
'mainImage':mainImage.asset->{url}.url,
body,
}`;
export async function generateMetadata({
params,
}: {
params: { slug: string };
export async function generateMetadata(props: {
params: Promise<{ slug: string }>;
}) {
const params = await props.params;
const seoQuery = `
*[_type == "project" && slug.current == $slug][0]{
title,
Expand Down Expand Up @@ -48,10 +49,13 @@ export async function generateMetadata({
}
async function ProjectDetailPage(props: DetailPageParamTypes) {
const { params } = props;
const { slug } = await params;
const data: Project = await client.fetch(query, {
slug: params?.slug,
slug: slug,
});
if (data === null) return <div>404</div>;
if (data === null) {
return redirect("/404");
}
return (
<div className="page-container md:gap-4 lg:gap-12">
<div className="flex shrink page-left flex-col gap-4">
Expand Down
18 changes: 11 additions & 7 deletions app/(web)/snippets/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export const revalidate = 60;

import Hero from "@/components/pages/article/hero";
import client from "@/utils/client";
import type { DetailPageParamTypes } from "@/types";
import type { SnippetDetailType } from "@/types/articles";
import { getOpenGraph, getTwitterCard, metaData } from "@/utils/metadata";
import CodeBlock from "@/components/pages/snippets/codeblock";
import { redirect } from "next/navigation";

const query = `
*[_type == "snippet" && slug.current == $slug][0]{
Expand All @@ -18,11 +20,10 @@ const query = `
}
`;

export async function generateMetadata({
params,
}: {
params: { slug: string };
export async function generateMetadata(props: {
params: Promise<{ slug: string }>;
}) {
const params = await props.params;
const seoQuery = `
*[_type == "snippet" && slug.current == $slug][0]{
title,
Expand All @@ -44,18 +45,21 @@ export async function generateMetadata({
data.title,
data.description,
new URL(`/snippets/${data?.slug}`, metaData?.url),
'article'
"article",
),
twitter: getTwitterCard(data?.mainImage, data.title, data.description),
};
}

async function SnippetDetailPage(props: DetailPageParamTypes) {
const { params } = props;
const { slug } = await params;
const data: SnippetDetailType = await client.fetch(query, {
slug: params?.slug,
slug,
});
if (data === null) return <></>;
if (data === null) {
return redirect("/404");
}
return (
<div className="page-container md:gap-4 lg:gap-12">
<div className="flex shrink page-left flex-col gap-4">
Expand Down
4 changes: 3 additions & 1 deletion app/(web)/snippets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ const hero = {

export const metadata: Metadata = {
title: "Snippets | Arkar Myat",

openGraph: getOpenGraph(
"/images/snippets.png",
"Snippets | " + metaData.title,
metaData.description,
new URL("/snippets", metaData.url),
"article",
),

twitter: getTwitterCard(
"/images/snippets.png",
"Snippets | " + metaData.title,
metaData.description,
),
)
};

async function ArticlePage() {
Expand Down
4 changes: 3 additions & 1 deletion app/(web)/videos/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ const hero = {

export const metadata: Metadata = {
title: "Videos | Arkar",

openGraph: getOpenGraph(
"/images/videos.png",
"Videos | " + metaData.title,
metaData.description,
new URL("/videos", metaData.url),
),

twitter: getTwitterCard(
"/images/videos.png",
"Videos | " + metaData.title,
metaData.description,
),
)
};

function VideoPage() {
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit dc4954b

Please sign in to comment.