Skip to content

Commit

Permalink
Support bluesky shortcode (#1398)
Browse files Browse the repository at this point in the history
* initial commit

* feat: add documentation
  • Loading branch information
HEIGE-PCloud authored Dec 14, 2024
1 parent b1ff487 commit dd9ecaf
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
}

/*
! tailwindcss v3.4.15 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com
*/

/*
Expand Down
14 changes: 14 additions & 0 deletions exampleSite/content/posts/tests/bluesky-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Bluesky Tests"
date: 2024-12-14T23:35:20+00:00
lastmod: 2024-12-14T23:35:20+00:00
draft: true
description: "Bluesky Shortcode Tests"
categories: [Tests]
hiddenFromHomePage: true
hiddenFromSearch: true
---

<!--more-->

{{< bluesky link="https://bsky.app/profile/bsky.app/post/3latotljnec2h" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -1598,3 +1598,23 @@ Without an explicitly given picture, a generic icon is used. This input:
```

This renders as {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.

## bluesky

`bluesky` is a shortcode to embed a post from [Bluesky](https://bsky.app).

The `bluesky` shortcode has the following named parameters:

* **link** *[required]*

URL of the Bluesky post.

Example `bluesky` input:

```markdown
{{</* bluesky link="https://bsky.app/profile/bsky.app/post/3latotljnec2h" */>}}
```

The rendered output looks like this:

{{< bluesky link="https://bsky.app/profile/bsky.app/post/3latotljnec2h" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -1600,4 +1600,22 @@ print("Hello world!")
{{</* person "https://dillonzq.com/" Dillon "author of the LoveIt theme" */>}}
```

呈现的输出效果为 {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.
呈现的输出效果为 {{< person "https://dillonzq.com/" Dillon "author of the LoveIt theme" >}}.

## bluesky

`bluesky` shortcode 用于嵌入 [Bluesky](https://bsky.app) 的帖子。

`bluesky` shortcode 有以下命名参数:

* **link** *[必需]*

Bluesky 帖子的 URL。

一个 `bluesky` 示例:

```markdown
{{</* bluesky link="https://bsky.app/profile/bsky.app/post/3latotljnec2h" */>}}
```

呈现的输出效果为 {{< bluesky link="https://bsky.app/profile/bsky.app/post/3latotljnec2h" >}}
8 changes: 8 additions & 0 deletions layouts/shortcodes/bluesky.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- $link := .Get "link" -}}
{{- $query := querify "url" $link -}}
{{- $request := printf "https://embed.bsky.app/oembed?%s" $query -}}

{{- $jsonOembed := resources.GetRemote $request -}}
{{- $jsonOembed = $jsonOembed | transform.Unmarshal -}}
{{- $jsonOHTML := $jsonOembed.html -}}
{{- $jsonOHTML | safeHTML -}}

0 comments on commit dd9ecaf

Please sign in to comment.