-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
27 changed files
with
264 additions
and
170 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
import { BASE } from "../config.json"; | ||
import FormattedDate from "./FormattedDate.astro"; | ||
import Tag from "./Tag.astro"; | ||
import HeroImage from "./HeroImage.astro"; | ||
const { title, description, pubDate, slug, heroImage, tags } = Astro.props; | ||
--- | ||
|
||
<article | ||
class="relative isolate flex flex-col gap-8 lg:flex-row group md:grid md:grid-cols-2 mt-8" | ||
> | ||
<div class="relative aspect-[16/9] lg:w-full lg:shrink-0"> | ||
<HeroImage image={heroImage} /> | ||
</div> | ||
<div class="h-full flex flex-col justify-center"> | ||
<div class="flex items-center gap-x-4 text-xs"> | ||
<time datetime="2020-03-16" class="text-base-500"> | ||
<FormattedDate date={pubDate} /> | ||
</time> | ||
{tags?.map((tag: string) => <Tag {tag} />)} | ||
</div> | ||
<div class="max-w-xl"> | ||
<div | ||
class="mt-3 text-xl md:text-2xl font-bold leading-6 text-base-900 dark:text-base-50" | ||
> | ||
<a href={BASE + `/posts/${slug}/`}> | ||
<span class="absolute inset-0"></span> | ||
{title} | ||
</a> | ||
|
||
<div | ||
class="absolute -inset-2 md:-inset-4 rounded-2xl opacity-0 group-hover:opacity-100 scale-95 group-hover:scale-100 bg-base-200/50 dark:bg-base-800/50 -z-10 transition-all duration-150" | ||
> | ||
</div> | ||
</div> | ||
<p class="mt-5 text-sm leading-6 text-base-600 dark:text-base-400"> | ||
{description} | ||
</p> | ||
</div> | ||
</div> | ||
</article> |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
import { Image } from "astro:assets"; | ||
const { image } = Astro.props; | ||
const images = import.meta.glob<{ default: ImageMetadata }>( | ||
"/src/assets/*.{jpeg,jpg,png,gif}" | ||
); | ||
// replace ../.. with src in image | ||
let replacedImage = image.replace("../..", "/src"); | ||
if (!images[replacedImage]) | ||
throw new Error( | ||
`"${replacedImage}" does not exist in glob: "src/assets/*.{jpeg,jpg,png,gif}"` | ||
); | ||
--- | ||
|
||
<Image | ||
src={images[replacedImage]()} | ||
alt="" | ||
class="absolute inset-0 h-full w-full rounded-2xl bg-base-50 dark:bg-base-900 object-cover" | ||
/> | ||
|
||
<div | ||
class="absolute inset-0 rounded-2xl ring-1 ring-inset ring-base-900/10 dark:ring-base-100/10" | ||
> | ||
</div> |
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,42 +1,45 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import { atUriToPostUri, getUserPosts, getLikes, getPost, getComments } from "./utils"; | ||
import { cn } from "src/utils"; | ||
import Comment from "./Comment.svelte"; | ||
let { uri, likesCount, likesData, user, comments } = $props(); | ||
let postUri = $state(uri); | ||
onMount(async () => { | ||
if (!uri && user) { | ||
let posts = await getUserPosts(user); | ||
const url = window.location.href; | ||
// @ts-expect-error: weird type fuckery | ||
const post = posts.find((post) => post.post.embed?.external?.uri === url); | ||
if (post) { | ||
postUri = post.post.uri; | ||
comments = await getComments(post.post.uri); | ||
} | ||
} else if (uri) { | ||
comments = await getComments(uri); | ||
} | ||
console.log(comments); | ||
}); | ||
</script> | ||
|
||
<div class="not-prose mt-8"> | ||
|
||
import { onMount } from "svelte"; | ||
import { getUserPosts, getComments, getCommentCount } from "./utils"; | ||
import Comment from "./Comment.svelte"; | ||
let { uri, user, comments } = $props(); | ||
let postUri = $state(uri); | ||
onMount(async () => { | ||
if (!uri && user) { | ||
let posts = await getUserPosts(user); | ||
const url = window.location.href; | ||
// @ts-expect-error: weird type fuckery | ||
const post = posts.find((post) => post.post.embed?.external?.uri === url); | ||
if (post) { | ||
postUri = post.post.uri; | ||
comments = await getComments(post.post.uri); | ||
} | ||
} else if (uri) { | ||
comments = await getComments(uri); | ||
} | ||
console.log(comments); | ||
}); | ||
</script> | ||
|
||
<div class="not-prose mt-8"> | ||
{#if comments.length > 0} | ||
<div> | ||
{#each comments as comment} | ||
<Comment comment={comment} /> | ||
{/each} | ||
</div> | ||
<div class="text-sm text-base-950 dark:text-base-100 font-semibold"> | ||
{getCommentCount(comments)} comments, sorted by newest first | ||
</div> | ||
{/if} | ||
|
||
</div> | ||
{#if comments.length > 0} | ||
<div class="pt-4"> | ||
{#each comments as comment} | ||
<Comment {comment} /> | ||
{/each} | ||
</div> | ||
{/if} | ||
</div> |
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
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: "Showing comments using Bluesky" | ||
description: "showing comments on your blog posts using bluesky" | ||
pubDate: "Dec 02 2024" | ||
published: true | ||
heroImage: "/src/assets/blog-placeholder-1.jpg" | ||
tags: ["setup"] | ||
--- | ||
|
||
You can also show comments on your blog posts using bluesky. | ||
|
||
## How it works | ||
|
||
Set the `BLUESKY_IDENTIFIER` in your `src/config.json` file to your bluesky handle (without the `@`). | ||
|
||
Then just post a link to your blog post on bluesky and comments will be shown on your blog posts, looking something like this: | ||
|
||
<div class="max-w-md rounded-xl overflow-hidden border border-base-200 dark:border-base-800 shadow-lg not-prose"> | ||
![showing comments]($assets/comments.png) | ||
</div> | ||
|
||
Note that no "add comment" link is shown if there is no post on bluesky linking to your blog post. | ||
|
||
Comments are both server-side rendered on build and updated on the client when you navigate to the page | ||
(so they work without javascript, but might be a bit outdated). | ||
|
||
If you post a link to your blog post on bluesky, likes will also be shown (see [likes via bluesky](../likes-via-bluesky)). | ||
If you don't want to show likes, you can disable them using the `disableLikes` option in your post options. | ||
|
||
```yml | ||
disableLikes: true | ||
``` | ||
See a live example below: |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.