Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/friend-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 友链申请

- 博客名称:
- 博客地址:
- 一句话简介:

> 提交本 PR 即视为同意本站对上述博客进行静态镜像(保留署名与版权信息,功能引导回原站)。如不同意镜像,请在简介中注明"仅收录链接,不镜像"。
51 changes: 51 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Mirror friend blogs & deploy

on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages-mirror
cancel-in-progress: true

jobs:
mirror-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- run: npm ci

- name: Restore mirror cache
uses: actions/cache@v4
with:
path: .cache/mirror
key: mirror-${{ hashFiles('src/data/channels.json') }}-${{ github.run_id }}
restore-keys: |
mirror-${{ hashFiles('src/data/channels.json') }}-
mirror-

- name: Mirror and sanitize
run: node scripts/mirror.mjs

- name: Build Astro site
run: npm run build

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
19 changes: 19 additions & 0 deletions .github/workflows/validate-channels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Validate friend channels

on:
pull_request:
paths:
- 'src/data/channels.json'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 22

- name: Validate channels.json
run: node scripts/validate-channels.mjs
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
.astro/
.cache/
public/channels/
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# RedRock 友链电视

RedRockBlog 的 Astro 重构(进行中):整站静态输出,`/tv` 为友链电视板块——把友链博客的每日静态镜像以"电视调台"的方式展示。

## 本地使用

```bash
npm install
npm run mirror # 拉取并清洗友链镜像(需要 wget,产物在 public/channels/)
npm run build # Astro 构建(含镜像)
npm run dev # 本地预览
```

本地快速验证可加环境变量:`MIRROR_QUICK=1 npm run mirror`(只抓两层页面)。

镜像默认不下载 Halo 的 `?width=` 缩略图变体(静态托管下无收益),页面 `srcset` 会自动收敛到原图;多频道并发抓取(最多 3 路)。

## 友链申请(PR)

编辑 `src/data/channels.json`,在 `channels` 数组中新增一项:

```json
{
"id": "example",
"name": "博客名",
"url": "https://example.com/",
"description": "一句话简介",
"enabled": true
}
```

提交 PR 即视为同意本站对博客做静态镜像(保留署名、功能引导回原站)。CI 会自动校验格式。

## 部署

`mirror.yml` 每天 03:00 UTC 定时镜像并部署到 GitHub Pages,也支持 `workflow_dispatch` 手动触发。仓库需在 Settings → Pages 中启用 GitHub Actions 作为发布源。
8 changes: 8 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'astro/config';

// GitHub Pages 项目站点基路径;若以后配置自定义域名,改为 '/' 或对应路径。
export default defineConfig({
site: 'https://redrockteam.github.io',
base: '/RedRockBlog',
output: 'static',
});
Loading
Loading