Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Blog Functionality #18

Merged
merged 26 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9c7fdcd
feat: add Sanity Studio configuration and related files
charlottewiltshire0 Jan 1, 2025
4152602
feat: add blog functionality with tag filtering and search
charlottewiltshire0 Jan 1, 2025
8e05941
feat: add article card component to display blog posts
charlottewiltshire0 Jan 1, 2025
2391e59
feat: add ArticleContent component to render post body
charlottewiltshire0 Jan 1, 2025
5c989da
feat: add ArticleNotFoundPage component for 404 handling
charlottewiltshire0 Jan 1, 2025
5c2efca
feat: add ArticleSplash component for blog post preview
charlottewiltshire0 Jan 1, 2025
50d35b5
feat: define Sanity schemas for Tag, Author, and Post
charlottewiltshire0 Jan 1, 2025
92cd423
feat: add blog-related helper functions for fetching posts and tags
charlottewiltshire0 Jan 1, 2025
67e9798
feat: add blog locales
charlottewiltshire0 Jan 1, 2025
4b67f9d
chore: add dependencies for Sanity, remark
charlottewiltshire0 Jan 1, 2025
3a627d8
feat: add reusable Tag component
charlottewiltshire0 Jan 1, 2025
beba37c
feat: add image optimization and redirect configuration
charlottewiltshire0 Jan 1, 2025
188522c
feat: create dynamic blog article page
charlottewiltshire0 Jan 1, 2025
3d6d32d
feat: add download button to mobile navbar
charlottewiltshire0 Jan 1, 2025
350d4e7
feat: add latest blog hero section
charlottewiltshire0 Jan 1, 2025
225e2f7
style: improve layout and responsiveness of the download information …
charlottewiltshire0 Jan 1, 2025
ac0f670
style: markdown support
charlottewiltshire0 Jan 1, 2025
6f7626d
fix: update footer link from "news" to "blog"
charlottewiltshire0 Jan 1, 2025
99ba482
feat: add reusable Input component
charlottewiltshire0 Jan 1, 2025
abb5540
style: prettier fix
charlottewiltshire0 Jan 1, 2025
c49c25c
chore: add environment variables to build workflow
charlottewiltshire0 Jan 2, 2025
cf95a36
chore: add pre-commit
charlottewiltshire0 Jan 2, 2025
1653053
chore: remove `runtime = "edge"` from blog article page
charlottewiltshire0 Jan 2, 2025
1f02e4a
chore: remove `runtime = "edge"` from blog article page
charlottewiltshire0 Jan 2, 2025
295cc6c
chore: remove unnecessary `runtime = "edge"` configurations
charlottewiltshire0 Jan 2, 2025
c3a985a
feat: dynamically import `ArticleContent` component for client-side r…
charlottewiltshire0 Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ jobs:

- name: Build Next.js App
run: bun run build
env:
NEXT_PUBLIC_GTM_ID: ${{ secrets.NEXT_PUBLIC_GTM_ID }}
NEXT_PUBLIC_SANITY_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_SANITY_PROJECT_ID }}
NEXT_PUBLIC_SANITY_DATASET: ${{ secrets.NEXT_PUBLIC_SANITY_DATASET }}
17 changes: 17 additions & 0 deletions app/(admin)/studio/[[...tool]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This route is responsible for the built-in authoring environment using Sanity Studio.
* All routes under your studio path is handled by this file using Next.js' catch-all routes:
* https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
*
* You can learn more about the next-sanity package here:
* https://github.com/sanity-io/next-sanity
*/

import { NextStudio } from "next-sanity/studio";
import config from "../../../../sanity.config";

export { metadata, viewport } from "next-sanity/studio";

export default function StudioPage() {
return <NextStudio config={config} />;
}
42 changes: 42 additions & 0 deletions app/(root)/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use client";

import { getPostBySlug } from "@/lib/blog";
import { ArticleSplash } from "@/components/blog/article-splash";
import { ArticleNotFoundPage } from "@/components/blog/article-not-found";
import dynamic from "next/dynamic";
import { Post } from "@/sanity/schemaTypes/postType";

const ArticleContentClient = dynamic<{
article: Post;
}>(
() =>
import("@/components/blog/article-content").then(
(mod) => mod.ArticleContent
),
{ ssr: false }
);

export default async function Article({
params,
}: {
params: Promise<{ slug: string }>;
}) {
const slug = (await params).slug;

const post = await getPostBySlug(slug);

if (!post || post.length === 0) {
return <ArticleNotFoundPage />;
}

return (
<div className="mb-24 px-5 lg:px-40">
<div className="flex flex-col items-center justify-center">
<div className="max-w-[800px]">
<ArticleSplash article={post[0]} />
<ArticleContentClient article={post[0]} />
</div>
</div>
</div>
);
}
15 changes: 15 additions & 0 deletions app/(root)/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getUsedTags, getLatestArticle, getPosts } from "@/lib/blog";
import BlogClient from "@/components/sections/blog/blog-client";

export default async function Blog() {
const tags = await getUsedTags();

const searchParams = new URLSearchParams();
const selectedTag = searchParams.get("tag") || "";
const search = searchParams.get("search") || "";

const posts = await getPosts(selectedTag, search);
const latestBlog = await getLatestArticle();

return <BlogClient posts={posts} latestBlog={latestBlog} tags={tags} />;
}
2 changes: 0 additions & 2 deletions app/(root)/download/[platform]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { SupportedPlatform } from "@/components/sections/download/supported-plat
import { Help } from "@/components/sections/download/help";
import { Information } from "@/components/sections/download/information";

export const runtime = "edge";

export default async function DownloadPlatform({
params,
}: {
Expand Down
2 changes: 0 additions & 2 deletions app/(root)/download/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { useEffect } from "react";
import { detect } from "detect-browser";
import { platformMapping } from "@/constants/platformMapping";

export const runtime = "edge";

export default function Download() {
const router = useRouter();

Expand Down
2 changes: 0 additions & 2 deletions app/(root)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import dynamic from "next/dynamic";
import { Hero } from "@/components/sections/landing/hero";
import { ProductShowcase } from "@/components/sections/landing/product-showcase";

export const runtime = "edge";

const Features = dynamic(
() =>
import("@/components/sections/landing/features").then(
Expand Down
Loading
Loading