Skip to content

Commit

Permalink
Add PGC navbar items plugin (#5045)
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Dec 24, 2024
1 parent 16bd4cf commit 5be4fab
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"Fullscreen",
"githubusercontent",
"Greasemonkey",
"guochuang",
"haruna",
"hdslb",
"HEVC",
Expand Down
46 changes: 46 additions & 0 deletions registry/lib/plugins/style/custom-navbar-pgc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { PluginMetadata } from '@/plugins/plugin'
import type { CustomNavbarItemInit } from '../../../components/style/custom-navbar/custom-navbar-item'

export const plugin: PluginMetadata = {
name: 'customNavbar.items.pgc',
displayName: '自定义顶栏 - 版权内容',
description: '为自定义顶栏扩充版权内容相关的快速入口, 包括国创 / 电影 / 电视剧 /综艺 / 纪录片',
async setup({ addData }) {
addData('customNavbar.items', (items: CustomNavbarItemInit[]) => {
const pgcItems = [
{
name: 'guochuang',
displayName: '国创',
href: 'https://www.bilibili.com/guochuang/',
},
{
name: 'movie',
displayName: '电影',
href: 'https://www.bilibili.com/movie/',
},
{
name: 'tv',
displayName: '电视剧',
href: 'https://www.bilibili.com/tv/',
},
{
name: 'variety',
displayName: '综艺',
href: 'https://www.bilibili.com/variety/',
},
{
name: 'documentary',
displayName: '纪录片',
href: 'https://www.bilibili.com/documentary/',
},
]
items.push(
...pgcItems.map(item => ({
...item,
content: item.displayName,
active: document.URL.startsWith(item.href),
})),
)
})
},
}

0 comments on commit 5be4fab

Please sign in to comment.