Merge pull request '更换到Astro' (#9) from switch-to-astro into master

Reviewed-on: #9
 -- [CST 2026-06-19 Friday 13:28:19]
This commit is contained in:
biss
2026-06-19 13:28:19 +08:00 Unverified
commit 01b5e2e1ba
100 changed files with 48921 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
function randomPost() {
fetch('/api/posts.json')
.then(res => {
if (!res.ok) throw new Error(`Failed to load posts: ${res.status}`);
return res.json();
})
.then(posts => {
const postLinks = posts
.map(post => post && post.href)
.filter(href => typeof href === 'string' && href.startsWith('/posts/'));
if (postLinks.length === 0) {
console.warn('No posts available for random navigation.');
return;
}
location.href = postLinks[Math.floor(Math.random() * postLinks.length)];
})
.catch(error => {
console.error('Random post navigation failed:', error);
});
}