1 parent
033af8097d
commit
b377bdc687
4 files changed
+284
-3
No files matched your search
+1
-1
@@ -41,7 +41,7 @@ export const siteConfig = {
|
||||
},
|
||||
social: [
|
||||
{ label: '发送邮件', href: 'mailto:bishsh2006@gmail.com', icon: 'fa-solid fa-envelope' },
|
||||
{ label: '订阅 RSS', href: '/rss.xml', icon: 'fa-solid fa-rss' },
|
||||
{ label: '订阅 RSS', href: '/rss/', icon: 'fa-solid fa-rss' },
|
||||
{ label: 'GitHub', href: 'https://github.com/bishshi', icon: 'fa-brands fa-github', external: true },
|
||||
],
|
||||
pagination: {
|
||||
|
||||
@@ -61,7 +61,7 @@ const tags = post.tags;
|
||||
</svg>
|
||||
<span>分享</span>
|
||||
</button>
|
||||
<a class="post-copyright-action" href="/rss.xml" title="订阅 RSS">
|
||||
<a class="post-copyright-action" href="/rss/" title="订阅 RSS">
|
||||
<svg aria-hidden="true" viewBox="0 0 24 24">
|
||||
<path d="M5 5a14 14 0 0 1 14 14" />
|
||||
<path d="M5 11a8 8 0 0 1 8 8" />
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
---
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import PageHeaderCard from '@/components/PageHeaderCard.astro';
|
||||
import { getAllPosts } from '@/lib/posts';
|
||||
import { siteConfig } from '../../site.config.mjs';
|
||||
|
||||
const posts = (await getAllPosts()).slice(0, 10);
|
||||
const feedUrl = new URL('/rss.xml', siteConfig.site.url).href;
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title="RSS 订阅"
|
||||
description={`订阅 ${siteConfig.site.name},在 RSS 阅读器中获取最新文章。`}
|
||||
canonicalPath="/rss/"
|
||||
>
|
||||
<section class="content-wrap narrow rss-page">
|
||||
<PageHeaderCard title="RSS 订阅" subtitle="不必反复刷新网页,让新文章主动出现在你的阅读器里。" />
|
||||
|
||||
<div class="rss-subscribe-card">
|
||||
<div class="rss-subscribe-icon" aria-hidden="true">
|
||||
<i class="fa-solid fa-rss"></i>
|
||||
</div>
|
||||
<div class="rss-subscribe-copy">
|
||||
<p class="rss-kicker">订阅源地址</p>
|
||||
<h2>复制地址,添加到你的 RSS 阅读器</h2>
|
||||
<p>支持 Feedly、Inoreader、Fluent Reader、NetNewsWire 等常见阅读器。</p>
|
||||
<div class="rss-url-row">
|
||||
<input id="rss-feed-url" type="url" value={feedUrl} readonly aria-label="RSS 订阅源地址" />
|
||||
<button id="rss-copy-button" type="button" data-feed-url={feedUrl}>
|
||||
<i class="fa-regular fa-copy" aria-hidden="true"></i>
|
||||
<span>复制地址</span>
|
||||
</button>
|
||||
</div>
|
||||
<a class="rss-raw-link" href="/rss.xml">
|
||||
查看原始 RSS XML
|
||||
<i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i>
|
||||
</a>
|
||||
<p class="rss-copy-status" role="status" aria-live="polite"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="rss-latest" aria-labelledby="rss-latest-title">
|
||||
<div class="rss-section-heading">
|
||||
<div>
|
||||
<p class="rss-kicker">Feed preview</p>
|
||||
<h2 id="rss-latest-title">最近更新</h2>
|
||||
</div>
|
||||
<span>{posts.length} 篇</span>
|
||||
</div>
|
||||
|
||||
<div class="rss-post-list">
|
||||
{posts.map((post) => (
|
||||
<article>
|
||||
<time datetime={post.date.toISOString()}>{post.dateText}</time>
|
||||
<h3><a href={post.href}>{post.title}</a></h3>
|
||||
<p>{post.summary}</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<script>
|
||||
const copyButton = document.querySelector<HTMLButtonElement>('#rss-copy-button');
|
||||
const feedInput = document.querySelector<HTMLInputElement>('#rss-feed-url');
|
||||
const copyStatus = document.querySelector<HTMLElement>('.rss-copy-status');
|
||||
|
||||
copyButton?.addEventListener('click', async () => {
|
||||
const feedUrl = copyButton.dataset.feedUrl ?? feedInput?.value ?? '';
|
||||
let copied = false;
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(feedUrl);
|
||||
copied = true;
|
||||
} catch {
|
||||
if (feedInput) {
|
||||
feedInput.select();
|
||||
copied = document.execCommand('copy');
|
||||
}
|
||||
}
|
||||
|
||||
if (copyStatus) copyStatus.textContent = copied ? '订阅地址已复制。' : '复制失败,请手动选择上面的地址。';
|
||||
const label = copyButton.querySelector('span');
|
||||
if (label && copied) {
|
||||
label.textContent = '已复制';
|
||||
window.setTimeout(() => {
|
||||
label.textContent = '复制地址';
|
||||
if (copyStatus) copyStatus.textContent = '';
|
||||
}, 2200);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.rss-page {
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.rss-subscribe-card,
|
||||
.rss-latest {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
background: color-mix(in srgb, var(--surface) 92%, transparent);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.rss-subscribe-card {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: clamp(20px, 4vw, 36px);
|
||||
align-items: start;
|
||||
padding: clamp(24px, 5vw, 44px);
|
||||
}
|
||||
|
||||
.rss-subscribe-icon {
|
||||
display: grid;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
place-items: center;
|
||||
border-radius: 18px;
|
||||
color: #fff;
|
||||
font-size: 2rem;
|
||||
background: linear-gradient(135deg, #f59e0b, #ea580c);
|
||||
box-shadow: 0 14px 30px rgba(234, 88, 12, 0.24);
|
||||
}
|
||||
|
||||
.rss-kicker {
|
||||
margin: 0 0 6px;
|
||||
color: var(--accent);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.rss-subscribe-copy h2,
|
||||
.rss-section-heading h2 {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.rss-subscribe-copy > p:not(.rss-kicker, .rss-copy-status) {
|
||||
margin: 10px 0 20px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.rss-url-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.rss-url-row input {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 11px 13px;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.rss-url-row button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
padding: 11px 16px;
|
||||
color: var(--surface);
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
background: var(--accent-strong);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rss-url-row button:focus-visible,
|
||||
.rss-raw-link:focus-visible,
|
||||
.rss-post-list a:focus-visible {
|
||||
outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.rss-raw-link {
|
||||
display: inline-flex;
|
||||
gap: 7px;
|
||||
align-items: center;
|
||||
margin-top: 14px;
|
||||
color: var(--accent-strong);
|
||||
font-size: 0.92rem;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.rss-copy-status {
|
||||
min-height: 1.6em;
|
||||
margin: 4px 0 -1.6em;
|
||||
color: var(--muted);
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.rss-latest {
|
||||
margin-top: 24px;
|
||||
padding: clamp(22px, 4vw, 36px);
|
||||
}
|
||||
|
||||
.rss-section-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
align-items: end;
|
||||
padding-bottom: 18px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.rss-section-heading > span {
|
||||
color: var(--muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.rss-post-list article {
|
||||
padding: 22px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.rss-post-list article:last-child {
|
||||
padding-bottom: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.rss-post-list time {
|
||||
color: var(--muted);
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.rss-post-list h3 {
|
||||
margin: 5px 0 7px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.rss-post-list h3 a {
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.rss-post-list h3 a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.rss-post-list p {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.rss-subscribe-card {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.rss-subscribe-icon {
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
border-radius: 15px;
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
.rss-url-row {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.rss-url-row button {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user