Compare commits
3 commits
de0456f4d4
...
98ee7a3527
Author | SHA1 | Date | |
---|---|---|---|
|
98ee7a3527 | ||
|
c55f49270a | ||
|
b5c6c9f4a6 |
3 changed files with 65 additions and 16 deletions
|
@ -1,10 +1,12 @@
|
||||||
---
|
---
|
||||||
|
// instanceDomain: the domain of the fediverse instance (e.g., "example.com")
|
||||||
|
// userId: the user ID (could be the username when the instance uses software other than mastodon) of the account whose statuses you want to fetch
|
||||||
|
// extraParams: any additional parameters to pass to the API (optional), in object format
|
||||||
|
const { instanceDomain, userId, extraParams = '' } = Astro.props;
|
||||||
---
|
---
|
||||||
{/* WIP: a Fediverse Statuses Component*/}}
|
|
||||||
{/* mainly made for Hugo, src code https://github.com/BlockG-ws/hugo-theme-laboratory/blob/master/layouts/_default/statuses.html */}
|
{/* mainly made for Hugo, src code https://github.com/BlockG-ws/hugo-theme-laboratory/blob/master/layouts/_default/statuses.html */}
|
||||||
{/* reworked some parts to make it work in astro */}}
|
{/* reworked some parts to make it work in astro */}
|
||||||
<h2>My Status</h2>
|
<h2>My Statuses</h2>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="posts"></div>
|
<div id="posts"></div>
|
||||||
<div class="loading">Loading...</div>
|
<div class="loading">Loading...</div>
|
||||||
|
@ -286,7 +288,7 @@
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script define:vars={{ instanceDomain, userId, extraParams }}>
|
||||||
function createFetcher(instanceDomain, userId, extraParams={}) {
|
function createFetcher(instanceDomain, userId, extraParams={}) {
|
||||||
const state = {
|
const state = {
|
||||||
instanceDomain,
|
instanceDomain,
|
||||||
|
@ -466,11 +468,11 @@ function createFetcher(instanceDomain, userId, extraParams={}) {
|
||||||
<a href="${postUrl}"
|
<a href="${postUrl}"
|
||||||
class="post-link"
|
class="post-link"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="在新窗口打开帖子">
|
title="Open post in new tab">
|
||||||
<svg viewBox="0 0 24 24" fill="currentColor">
|
<svg viewBox="0 0 24 24" fill="currentColor">
|
||||||
<path d="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z" />
|
<path d="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z" />
|
||||||
</svg>
|
</svg>
|
||||||
打开原帖
|
Original
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -521,7 +523,7 @@ function createFetcher(instanceDomain, userId, extraParams={}) {
|
||||||
target="_blank">
|
target="_blank">
|
||||||
${post.account.display_name}
|
${post.account.display_name}
|
||||||
</a>
|
</a>
|
||||||
转发了
|
boosted
|
||||||
</div>
|
</div>
|
||||||
<div class="reblogged-content">
|
<div class="reblogged-content">
|
||||||
${renderPostContent(post.reblog)}
|
${renderPostContent(post.reblog)}
|
||||||
|
@ -613,11 +615,5 @@ function createFetcher(instanceDomain, userId, extraParams={}) {
|
||||||
showInLightbox
|
showInLightbox
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
window.fetcher = createFetcher('', '', {
|
window.fetcher = createFetcher(instanceDomain, userId, extraParams);
|
||||||
exclude_replies: true,
|
|
||||||
exclude_reblogs: true,
|
|
||||||
pinned: false,
|
|
||||||
only_media: false,
|
|
||||||
limit: 20
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
47
src/components/shortcodes/Spoiler.astro
Normal file
47
src/components/shortcodes/Spoiler.astro
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
---
|
||||||
|
const { tip = '' } = Astro.props
|
||||||
|
---
|
||||||
|
{/* TODO: make it work in paragraph wrapped elements */}
|
||||||
|
<span class="spoiler" title={tip}>
|
||||||
|
<slot/>
|
||||||
|
</span>
|
||||||
|
<style>
|
||||||
|
.spoiler {
|
||||||
|
background-color: #252525;
|
||||||
|
color: #252525;
|
||||||
|
transition: color 0.5s;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
/* fix blockquotes */
|
||||||
|
.spoiler blockquote {
|
||||||
|
color: #252525;
|
||||||
|
transition: color 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler blockquote:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
/* fix code */
|
||||||
|
.spoiler code pre {
|
||||||
|
color: #252525;
|
||||||
|
transition: color 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler code pre:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fix list bullet*/
|
||||||
|
.spoiler li::marker {
|
||||||
|
color: #252525;
|
||||||
|
transition: color 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spoiler:hover li::marker {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -4,8 +4,14 @@ description: 'This is a test page'
|
||||||
---
|
---
|
||||||
import BlogRoll from "../../components/shortcodes/BlogRoll.astro"
|
import BlogRoll from "../../components/shortcodes/BlogRoll.astro"
|
||||||
import FediStatuses from "../../components/shortcodes/FediStatuses.astro"
|
import FediStatuses from "../../components/shortcodes/FediStatuses.astro"
|
||||||
|
import Spoiler from "../../components/shortcodes/Spoiler.astro"
|
||||||
|
|
||||||
testestestest
|
testestestest
|
||||||
|
|
||||||
<BlogRoll/>
|
<BlogRoll/>
|
||||||
<FediStatuses/>
|
|
||||||
|
<Spoiler tip="Spoiler Title">
|
||||||
|
~~This is the content of the spoiler.~~
|
||||||
|
</Spoiler>
|
||||||
|
|
||||||
|
<FediStatuses instanceDomain='portal.gb0.dev' userId='me' />
|
Loading…
Add table
Add a link
Reference in a new issue