Skip to content

Commit

Permalink
Blog Metadata, Vercel Analytics, Logo ARIA Label
Browse files Browse the repository at this point in the history
  • Loading branch information
Kawtar Choubari committed Sep 8, 2023
1 parent fdfa99f commit f3de639
Show file tree
Hide file tree
Showing 10 changed files with 3,120 additions and 2,938 deletions.
25 changes: 25 additions & 0 deletions app/blog/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FaCalendar, FaChevronLeft } from "react-icons/fa";
import Link from "next/link";
import Image from "next/image";
import { Mdx } from "@/components/mdx/mdx-components";
import { absoluteUrl } from "@/lib/utils";

interface PostPageProps {
params: {
Expand Down Expand Up @@ -45,6 +46,30 @@ export async function generateMetadata({
return {
title: post.title,
description: post.description,
authors: [
{
name: "Kawtar Choubari",
url: "https://choubari.com",
},
],
openGraph: {
title: post.title,
description: post.description,
type: "article",
url: absoluteUrl(post.slug),
images: [
{
url: post.image,
alt: post.title,
},
],
},
twitter: {
card: "summary_large_image",
title: post.title,
description: post.description,
images: [post.image],
},
};
}

Expand Down
4 changes: 4 additions & 0 deletions app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { compareDesc, format, parseISO } from "date-fns";
import { allPosts, Post } from "contentlayer/generated";
import { FaCalendar } from "react-icons/fa";

export const metadata = {
title: "Blog",
};

function PostCard(post: Post) {
return (
<article
Expand Down
2 changes: 2 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "./globals.css";
import { Providers } from "@/lib/provider";
import Footer from "@/components/footer";
import { siteConfig } from "@/config/site";
import Analytics from "@/components/analytics";

export const metadata = {
title: siteConfig.name,
Expand Down Expand Up @@ -68,6 +69,7 @@ export default function RootLayout({
<Nav />
<main className="mx-auto lg:max-w-7xl" role="main">
{children}
<Analytics />
</main>
</Providers>
<Footer />
Expand Down
8 changes: 8 additions & 0 deletions components/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use client";

import React from "react";
import { Analytics as VercelAnalytics } from "@vercel/analytics/react";

export default function Analytics() {
return <VercelAnalytics />;
}
2 changes: 1 addition & 1 deletion components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Footer() {
>
<div className="mx-auto px-8 pt-5 lg:px-8 lg:max-w-7xl grid grid-cols-1 md:grid-cols-12 gap-8">
<div className="md:col-span-4 md:space-y-4">
<Link href="/" aria-label="Navigate to the Home Page">
<Link href="/" aria-label="Choubari's Home Page">
<Logo />
</Link>
<p className="pb-3">
Expand Down
2 changes: 1 addition & 1 deletion components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Nav() {
>
<div className="justify-between px-8 mx-auto lg:max-w-7xl md:items-center md:flex md:px-8">
<div className="flex items-center justify-between py-3 md:py-5 md:block">
<Link href="/" aria-label="Navigate to the Home Page">
<Link href="/" aria-label="Choubari's Home Page">
<Logo />
</Link>
<div className="md:hidden">
Expand Down
2 changes: 1 addition & 1 deletion content/blog/welcome-to-my-blog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Hello, World! Welcome to my blog!
description: I've been proscrasting a lot making this together, let's start the journey!
image: /blog/placeholder.jpg
published: false
published: true
date: 2023-09-05
---

Expand Down
4 changes: 4 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ export function countFormatter(n: number): string {
const countFormat = Intl.NumberFormat("en", { notation: "compact" });
return countFormat.format(n);
}

export function absoluteUrl(path: string) {
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@types/node": "20.2.3",
"@types/react": "18.2.6",
"@types/react-dom": "18.2.4",
"@vercel/analytics": "^1.0.2",
"autoprefixer": "10.4.14",
"classnames": "^2.3.2",
"contentlayer": "^0.3.4",
Expand Down
Loading

0 comments on commit f3de639

Please sign in to comment.