-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b3ce61
commit 42d78ed
Showing
2 changed files
with
144 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,146 @@ | ||
--- | ||
import { getCollection, type CollectionEntry } from "astro:content" | ||
import Prose from "../../components/Prose.astro" | ||
import { format } from "date-fns" | ||
import Link from "../../components/Link.astro" | ||
import MainContainer from "../../components/MainContainer.astro" | ||
import Micro from "../../components/Micro.astro" | ||
import Prose from "../../components/Prose.astro" | ||
import BaseLayout from "../../layouts/BaseLayout.astro" | ||
export async function getStaticPaths() { | ||
const micros = await getCollection("micro") | ||
return micros | ||
.filter((micro) => micro.data.published) | ||
.filter((micro) => micro.data.published !== false) | ||
.map((micro) => ({ | ||
params: { slug: micro.slug }, | ||
props: { micro }, | ||
})) | ||
} | ||
export interface Props { | ||
type Props = { | ||
micro: CollectionEntry<"micro"> | ||
} | ||
const { micro } = Astro.props | ||
const { Content } = await micro.render() | ||
--- | ||
|
||
<BaseLayout pageTitle={micro.data.title}> | ||
<BaseLayout pageTitle={micro.data.title ?? "Micro Post"}> | ||
<MainContainer> | ||
<div class="grid gap-4 mt-8"> | ||
<Micro micro={micro} /> | ||
</div> | ||
<article class="max-w-2xl mx-auto mt-12"> | ||
{/* Header */} | ||
<header class="mb-12"> | ||
<div | ||
class="flex items-center gap-2 text-sm text-[hsl(var(--muted-foreground))] mb-8" | ||
> | ||
<Link href="/micro" class="hover:text-[hsl(var(--foreground))]"> | ||
← Back to micro | ||
</Link> | ||
</div> | ||
|
||
<div class="flex items-center justify-between mb-6"> | ||
<time | ||
datetime={micro.data.date.toISOString()} | ||
class="text-sm text-[hsl(var(--muted-foreground))]" | ||
> | ||
{format(micro.data.date, "MMMM d, yyyy 'at' h:mm a")} | ||
</time> | ||
|
||
{/* Share buttons */} | ||
<div class="flex items-center gap-2"> | ||
<a | ||
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent(`${micro.data.title ?? ""} https://bhekani.com/micro/${micro.slug}`)}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
class="p-2 text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors" | ||
title="Share on Twitter" | ||
> | ||
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor"> | ||
<path | ||
d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" | ||
></path> | ||
</svg> | ||
</a> | ||
<a | ||
href={`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(`https://bhekani.com/micro/${micro.slug}`)}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
class="p-2 text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors" | ||
title="Share on LinkedIn" | ||
> | ||
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor"> | ||
<path | ||
d="M20.5 2h-17A1.5 1.5 0 002 3.5v17A1.5 1.5 0 003.5 22h17a1.5 1.5 0 001.5-1.5v-17A1.5 1.5 0 0020.5 2zM8 19H5v-9h3zM6.5 8.25A1.75 1.75 0 118.3 6.5a1.78 1.78 0 01-1.8 1.75zM19 19h-3v-4.74c0-1.42-.6-1.93-1.38-1.93A1.74 1.74 0 0013 14.19a.66.66 0 000 .14V19h-3v-9h2.9v1.3a3.11 3.11 0 012.7-1.4c1.55 0 3.36.86 3.36 3.66z" | ||
></path> | ||
</svg> | ||
</a> | ||
<button | ||
class="copy-link p-2 text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors" | ||
title="Copy link" | ||
data-url={`https://bhekani.com/micro/${micro.slug}`} | ||
> | ||
<svg | ||
class="w-5 h-5" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
stroke-width="2" | ||
> | ||
<path | ||
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" | ||
></path> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
{ | ||
micro.data.title && ( | ||
<h1 class="text-3xl font-bold mb-6">{micro.data.title}</h1> | ||
) | ||
} | ||
</header> | ||
|
||
{/* Content */} | ||
<div class="prose prose-lg dark:prose-invert max-w-none"> | ||
<Content /> | ||
</div> | ||
|
||
{/* Footer */} | ||
<footer class="mt-12 pt-8 border-t border-[hsl(var(--muted))]"> | ||
<nav | ||
class="flex justify-between text-sm text-[hsl(var(--muted-foreground))]" | ||
> | ||
<Link href="/micro" class="hover:text-[hsl(var(--foreground))]"> | ||
← All micro posts | ||
</Link> | ||
</nav> | ||
</footer> | ||
</article> | ||
</MainContainer> | ||
</BaseLayout> | ||
|
||
<script> | ||
// Copy link functionality | ||
document.querySelector(".copy-link")?.addEventListener("click", async (e) => { | ||
const button = e.currentTarget as HTMLButtonElement | ||
const url = button.dataset.url | ||
|
||
if (url) { | ||
await navigator.clipboard.writeText(url) | ||
|
||
// Optional: Show feedback | ||
const originalTitle = button.getAttribute("title") | ||
button.setAttribute("title", "Copied!") | ||
setTimeout(() => { | ||
button.setAttribute("title", originalTitle || "Copy link") | ||
}, 2000) | ||
} | ||
}) | ||
</script> | ||
|
||
<style> | ||
/* Optional: Add smooth transitions */ | ||
.prose { | ||
transition: color 0.2s ease-in-out; | ||
} | ||
</style> |