docFX菜单缺少"Articles","Api Documentation"从文件系统托管时,但显示在本地主机:8080



当我运行docfx docfx.json --serve并转到localhost:8080时,我在顶部菜单上看到了两个项目:" Articles"one_answers" API Documentation"。当我在文件系统中导航至_site并单击index.html以在Chrome中打开它时,这些菜单项丢失了。当我以静态网站运行时,如何确保将菜单正确设置?

我需要能够包装HTML文件,并将其发送给人们以供他们本地查看,而无需下载仓库并安装DocFx。

原因:该页面需要额外的JS文件到导航栏,但被Chrome阻止。您可以在Chrome Console(F12(中看到这些错误:

docfx.vendor.js:4 Access to XMLHttpRequest at 'file:///C:/git/docfx-seed/_site/toc.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
send @ docfx.vendor.js:4
docfx.vendor.js:4 Access to XMLHttpRequest at 'file:///C:/git/docfx-seed/_site/logo.svg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

解决方案:使用模板statictoc,它已经将所有必需的部分嵌入到HTML文件中:

docfx docfx.json -t statictoc

相关内容

最新更新