feat: add a friend link (blogroll) shortcode
This commit is contained in:
parent
6a2d5fd912
commit
de4de10703
6 changed files with 54 additions and 13 deletions
19
src/components/shortcodes/BlogRoll.astro
Normal file
19
src/components/shortcodes/BlogRoll.astro
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
import {getCollection} from "astro:content";
|
||||||
|
import { Image } from 'astro:assets';
|
||||||
|
const links = await getCollection('links');
|
||||||
|
---
|
||||||
|
<h2>My Blogroll</h2>
|
||||||
|
{links.length > 0 && links.map((link =>
|
||||||
|
<div class="link">
|
||||||
|
{link.data.avatar && <Image src={link.data.avatar} alt={`avatar of ${link.id}`} width="16" height="16"></Image>}
|
||||||
|
<a href={link.data.link} target="_blank" rel="noopener noreferrer">
|
||||||
|
{link.id}
|
||||||
|
</a> - {link.data.description}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<style>
|
||||||
|
.link img {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import {defineCollection} from 'astro:content';
|
import {defineCollection} from 'astro:content';
|
||||||
import {posts} from './posts/_schemas';
|
import {posts} from './posts/_schemas';
|
||||||