Skip to content
Closed
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
15 changes: 15 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@ waline:
recaptchaV3Key: # reCAPTCHA v3密钥
turnstileKey: # Turnstile密钥

# giscus 评论系统配置(基于 GitHub Discussions)
# 使用方法:在 https://giscus.app/ 填写配置并复制对应字段到下面,启用后主题会在文章底部渲染评论。
giscus:
enable: false # 是否启用 giscus
repo: "" # 仓库,格式:owner/repo
repoId: "" # 可选:仓库 id(从 giscus 或 GitHub 获取)
category: "" # Discussions 分类名称,例如 General
categoryId: "" # 可选:分类 id
mapping: "" # mapping 策略:url | pathname | title | og:title | specific
reactionsEnabled: true # 是否启用表情反应
emitMetadata: false # 是否发送元数据
inputPosition: "top" # 评论输入框位置:top | bottom
lang: "zh-CN" # 语言
theme: "preferred_color_scheme" # giscus 主题,可设为 light/dark/transparent 或 preferred_color_scheme

summary:
enable: false
introduce: "" # AI自我介绍
Expand Down
23 changes: 23 additions & 0 deletions layout/comment.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
mixin CommentRender()
!= shokax_inject('comment')
if page.comment !== false
div(class="wrap" id="comments")
// giscus 评论区(如果在主题配置中启用)
if theme && theme.giscus && theme.giscus.enable
// giscus 容器
.giscus-container
//- 请在站点配置中填写下列字段(repo、repoId、category、categoryId 等)
script(async crossorigin="anonymous" src="https://giscus.app/client.js"
'data-repo'=theme.giscus.repo
'data-repo-id'=theme.giscus.repoId
'data-category'=theme.giscus.category
'data-category-id'=theme.giscus.categoryId
'data-mapping'=(theme.giscus.mapping || 'pathname')
'data-reactions-enabled'=(theme.giscus.reactionsEnabled ? '1' : '0')
'data-emit-metadata'=(theme.giscus.emitMetadata ? '1' : '0')
'data-input-position'=(theme.giscus.inputPosition || 'bottom')
'data-lang'=(theme.giscus && theme.giscus.lang ? theme.giscus.lang : 'zh-CN')
'data-theme'=(theme.giscus.theme || 'preferred_color_scheme'))
// 如果需要其他评论系统(如 Twikoo/Waline),主题已内置对应配置,可按需启用


32 changes: 32 additions & 0 deletions source/js/_app/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,38 @@ export const initAudioPlayer = async function () {
url: item.list[0]
})
})
// Limit concurrent requests to the external meting API to avoid hitting
// browser / server limits when many playlists are loaded at once.
// nyx-player uses `fetch()` internally; we patch `window.fetch` for
// requests to api.injahow.cn so that they are executed with limited
// concurrency (serialised or small pool) to avoid Promise.all failing.
if (typeof window !== 'undefined' && window.fetch) {
const _origFetch = window.fetch.bind(window)
const HOST = 'api.injahow.cn'
const CONCURRENCY = 3
let active = 0
const queue: Array<any> = []
const next = () => {
if (active >= CONCURRENCY || queue.length === 0) return
active++
const item = queue.shift()
_origFetch(item.input, item.init)
.then(item.resolve)
.catch(item.reject)
.finally(() => { active--; next() })
}
window.fetch = (input: RequestInfo, init?: RequestInit) => {
const url = typeof input === 'string' ? input : (input as Request).url
if (typeof url === 'string' && url.includes(HOST)) {
return new Promise((resolve, reject) => {
queue.push({ input, init, resolve, reject })
next()
})
}
return _origFetch(input, init)
}
}

const { initPlayer } = await import('nyx-player')
initPlayer("#player","#showBtn", urls, "#playBtn", "html[data-theme=&quot;dark&quot;]", "shokax")
}