- Implemented SharePanel component in `SharePanel.astro` for sharing content on social media platforms. - Integrated QR code generation for WeChat sharing using the `qrcode` library. - Added localization support for English and Chinese languages. - Created utility functions in `seo.ts` for building article summaries and FAQs. - Introduced API routes for serving IndexNow key and generating full LLM catalog and summaries. - Enhanced SEO capabilities with structured data for articles and pages.
85 lines
1.8 KiB
Markdown
85 lines
1.8 KiB
Markdown
# frontend
|
||
|
||
Astro 前台站点,当前运行模式为:
|
||
|
||
- `output: 'server'`
|
||
- `@astrojs/node` standalone
|
||
- 少量 Svelte 组件用于客户端激活
|
||
|
||
## 常用命令
|
||
|
||
```powershell
|
||
pnpm install
|
||
pnpm dev
|
||
pnpm build
|
||
```
|
||
|
||
默认本地开发端口:
|
||
|
||
- frontend: `4321`
|
||
|
||
## API 地址约定
|
||
|
||
前台现在区分两类 API 地址:
|
||
|
||
- `INTERNAL_API_BASE_URL`
|
||
- 给 Astro SSR / Node 服务端渲染访问 backend 用
|
||
- docker compose 默认推荐:`http://backend:5150/api`
|
||
- `PUBLIC_API_BASE_URL`
|
||
- 给浏览器里的评论、AI 问答、搜索等请求用
|
||
- 如果不设置,生产环境会回退到“当前访问主机 + `:5150/api`”
|
||
|
||
如果你走正式域名 / HTTPS / 反向代理,建议显式设置:
|
||
|
||
```env
|
||
PUBLIC_API_BASE_URL=https://api.blog.init.cool
|
||
```
|
||
|
||
## 图片处理链
|
||
|
||
前台现在额外带了一个 SSR 图片优化端点:
|
||
|
||
- `/_img`
|
||
|
||
它会对**同域图片**做:
|
||
|
||
- 响应式尺寸裁切/缩放
|
||
- `AVIF / WebP / JPEG|PNG` 输出
|
||
- 前台卡片 / 文章页封面的 `srcset` 生成
|
||
|
||
如果你的封面图来自额外 CDN / R2 公网域名,需要给 frontend 运行时增加:
|
||
|
||
```env
|
||
PUBLIC_IMAGE_ALLOWED_HOSTS=cdn.example.com,pub-xxxx.r2.dev
|
||
```
|
||
|
||
admin 侧上传封面时也会额外做:
|
||
|
||
- 上传前压缩
|
||
- 16:9 封面规范化
|
||
- 优先转为 `AVIF / WebP`
|
||
|
||
## GEO / AI 搜索补充
|
||
|
||
前台现在额外提供:
|
||
|
||
- `/llms.txt`
|
||
- `/llms-full.txt`
|
||
- `/indexnow-key.txt`(仅在配置 `INDEXNOW_KEY` 时可用)
|
||
|
||
如果你想在发布后主动推送 IndexNow,可以配置:
|
||
|
||
```env
|
||
INDEXNOW_KEY=your-indexnow-key
|
||
SITE_URL=https://your-frontend.example.com
|
||
PUBLIC_API_BASE_URL=https://your-frontend.example.com/api
|
||
```
|
||
|
||
然后运行:
|
||
|
||
```powershell
|
||
pnpm indexnow:submit
|
||
```
|
||
|
||
脚本会自动收集首页、文章、分类、标签、评测等 canonical URL 并提交到 IndexNow。
|