From b8909cf9ce501fd096c8fda4758e1f6ad187e028 Mon Sep 17 00:00:00 2001 From: HangerThem Date: Mon, 3 Aug 2026 17:34:05 +0200 Subject: [PATCH] Added commit tracker/link to sidebar --- .../categories/[categorySlug]/page.tsx | 4 +- app/(withRecent)/categories/page.tsx | 2 +- app/(withRecent)/page.tsx | 2 +- app/posts/[slug]/page.tsx | 6 +- components/content/ImageWrapper.tsx | 2 +- components/layout/NavLinks.tsx | 12 +++- components/layout/Sidebar.tsx | 69 ++++++++++++++++--- components/layout/navItems.tsx | 2 +- components/post/Post.tsx | 6 +- components/post/RecentlyUpdatedPosts.tsx | 4 +- components/post/TableOfContents.tsx | 38 +++++----- utils/git.ts | 53 ++++++++++++++ 12 files changed, 156 insertions(+), 44 deletions(-) create mode 100644 utils/git.ts diff --git a/app/(withRecent)/categories/[categorySlug]/page.tsx b/app/(withRecent)/categories/[categorySlug]/page.tsx index e7be18e..3950a14 100644 --- a/app/(withRecent)/categories/[categorySlug]/page.tsx +++ b/app/(withRecent)/categories/[categorySlug]/page.tsx @@ -40,7 +40,7 @@ export default async function CategoryPage({ params }: CategoryPageProps) { if (!category) { return ( -
+

Category not found

Back to categories
@@ -48,7 +48,7 @@ export default async function CategoryPage({ params }: CategoryPageProps) { } return ( -
+

Category: {category}

    {posts.map((post) => ( diff --git a/app/(withRecent)/categories/page.tsx b/app/(withRecent)/categories/page.tsx index a3369e4..419562f 100644 --- a/app/(withRecent)/categories/page.tsx +++ b/app/(withRecent)/categories/page.tsx @@ -33,7 +33,7 @@ export default function CategoriesPage() { const categoryNames = Object.keys(categories) return ( -
    +
    ~/categories
      diff --git a/app/(withRecent)/page.tsx b/app/(withRecent)/page.tsx index f347463..4d1476a 100644 --- a/app/(withRecent)/page.tsx +++ b/app/(withRecent)/page.tsx @@ -11,7 +11,7 @@ export default function BlogIndex() { } return ( -
      +
      {posts.length === 0 ? (
      diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx index 8776d4c..17d944b 100644 --- a/app/posts/[slug]/page.tsx +++ b/app/posts/[slug]/page.tsx @@ -43,7 +43,7 @@ export default async function Post({ params }: { params: Promise<{ slug: string return (
      -
      +
      {meta.category && (
      - +
      ) } diff --git a/components/content/ImageWrapper.tsx b/components/content/ImageWrapper.tsx index 7c04362..5feea57 100644 --- a/components/content/ImageWrapper.tsx +++ b/components/content/ImageWrapper.tsx @@ -9,7 +9,7 @@ type ImageWrapperProps = { export function ImageWrapper({ src, alt, isListing }: ImageWrapperProps) { return ( -
      +
      { @@ -26,7 +30,11 @@ export function NavLinks() { > {item.isExternal ? ( {item.icon} diff --git a/components/layout/Sidebar.tsx b/components/layout/Sidebar.tsx index da0d57e..e522693 100644 --- a/components/layout/Sidebar.tsx +++ b/components/layout/Sidebar.tsx @@ -1,18 +1,69 @@ import { metadata } from '@/app/metadata' import { NotepadText } from 'lucide-react' import { NavLinks } from '@/components/layout/NavLinks' +import { siBluesky, siGithub, siMatrix, siTelegram, type SimpleIcon } from 'simple-icons' +import { ExternalLink } from '@/components/ui/ExternalLink' +import { getGitCommitHash, getGitOriginUrl } from '@/utils/git' + +type SocialLink = { + icon: SimpleIcon + url: string +} + +const socialLinks: SocialLink[] = [ + { + icon: siBluesky, + url: 'https://bsky.app/profile/hangerthem.com', + }, + { + icon: siGithub, + url: 'https://github.com/hangerthem', + }, + { + icon: siMatrix, + url: 'https://matrix.to/#/@hangerthem:hangerthem.com', + }, + { + icon: siTelegram, + url: 'https://t.me/hangerthem', + }, +] + +export async function Sidebar() { + const gitCommitHash = (await getGitCommitHash())?.substring(0, 7) + const gitOriginUrl = await getGitOriginUrl() -export function Sidebar() { return ( ) diff --git a/components/layout/navItems.tsx b/components/layout/navItems.tsx index 8cb0886..5f3d512 100644 --- a/components/layout/navItems.tsx +++ b/components/layout/navItems.tsx @@ -21,7 +21,7 @@ export const navItems: NavItem[] = [ isExternal: true, }, { - href: 'https://git.hangerthem.com/hangerthem/blog.hangerthem.com', + href: '{gitOriginUrl}', label: 'Source Code', icon: , isExternal: true, diff --git a/components/post/Post.tsx b/components/post/Post.tsx index 6650079..0fbc8d6 100644 --- a/components/post/Post.tsx +++ b/components/post/Post.tsx @@ -1,8 +1,8 @@ import { ImageWrapper } from '@/components/content/ImageWrapper' -import { cn } from '@/utils/cn' import { PostMeta } from '@/types/Post.type' import Link from 'next/link' import { dateFormatter } from '@/utils/time' +import { cn } from '@/utils/cn' type PostProps = { post: PostMeta @@ -32,11 +32,11 @@ export function Post({ post, isLatest, showImageSlot }: PostProps) { return (
      {(isLatest || showImageSlot) && ( -
      +
      {coverImage && }
      )} -
      +
      {isLatest && Latest post} {category && (
      diff --git a/components/post/RecentlyUpdatedPosts.tsx b/components/post/RecentlyUpdatedPosts.tsx index 3dec17e..d4be1b0 100644 --- a/components/post/RecentlyUpdatedPosts.tsx +++ b/components/post/RecentlyUpdatedPosts.tsx @@ -4,8 +4,8 @@ import Link from 'next/link' export function RecentlyUpdatedPosts() { const posts = getAllPostsMeta() return ( -