Skip to content

Commit db3e00a

Browse files
fix: 关闭 baseUrl 提示横幅,保留 favicon 插件与 logo 绝对路径
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b9222fa commit db3e00a

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

docusaurus.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ const config = {
99
baseUrl: '/fcp-doc/',
1010
organizationName: 'quickmsg',
1111
projectName: 'fcp-doc',
12+
baseUrlIssueBanner: false,
1213
onBrokenLinks: 'throw',
1314
onBrokenMarkdownLinks: 'warn',
1415
i18n: {
1516
defaultLocale: 'zh-Hans',
1617
locales: ['zh-Hans'],
1718
},
19+
plugins: ['./plugins/favicon-plugin.js'],
1820
presets: [
1921
[
2022
'classic',
@@ -37,10 +39,11 @@ const config = {
3739
({
3840
navbar: {
3941
logo: {
40-
src: 'logo.svg',
41-
srcDark: 'logo.svg',
42+
src: '/fcp-doc/logo.svg',
43+
srcDark: '/fcp-doc/logo.svg',
4244
width: 36,
4345
height: 36,
46+
alt: 'FCP',
4447
},
4548
title: 'FCP',
4649
items: [],

plugins/favicon-plugin.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* 注入 favicon 绝对路径,解决 baseUrl 子路径部署时浏览器标签页图标不显示
3+
*/
4+
export default function faviconPlugin(context) {
5+
const { siteConfig } = context;
6+
const baseUrl = siteConfig.baseUrl || '/';
7+
const url = (siteConfig.url || '').replace(/\/$/, '');
8+
const faviconHref = `${url}${baseUrl}favicon.ico`;
9+
10+
return {
11+
name: 'favicon-plugin',
12+
injectHtmlTags() {
13+
return {
14+
headTags: [
15+
{
16+
tagName: 'link',
17+
attributes: {
18+
rel: 'icon',
19+
type: 'image/x-icon',
20+
href: faviconHref,
21+
},
22+
},
23+
],
24+
};
25+
},
26+
};
27+
}

0 commit comments

Comments
 (0)