首页 > 解决方案 > 在没有 Apache Server/ (.htaccess) 的情况下运行 Xcode DocC

问题描述

在 DocC 文档“向外部开发人员分发文档”中,Apple 提供了在您的网站上托管文档存档的文档。不幸的是,当我打开时.doccarchive/index.html,我只得到一个白页。他们只展示了 Apache 服务器的指南。他们指定了使用.htaccess文件,并RewriteRule .* SlothCreator.doccarchive/$0 [L]在用户访问文档页面时使用重写 URL。

有没有办法在不运行 Apache 服务器的情况下打开文档 Web 应用程序?(我不想做任何机器特定的配置,比如修改/etc/hosts)。能够将其托管为静态站点(例如在 Github 页面、Cloudflare 页面、Netlify 等)上将是理想的

编辑:使用@Ranoiaetep 的答案,我已经构建并将其推送到GitHub存储库,并且可以通过 Netlify 站点查看:https ://xcode-docc.netlify.app/documentation/

标签: xcodedocc

解决方案


截至目前,我认为没有任何选项可以将其托管为静态站点。

但是,通过设置 .toml 文件在 Netlify 上托管它非常容易:

[build]
publish = "ProjectName.doccarchive/"
###### Change it to your doccarchive file's name

[[redirects]]
from = "/documentation/*"
status = 200
to = "/index.html"

[[redirects]]
from = "/tutorials/*"
status = 200
to = "/index.html"

[[redirects]]
from = "/data/documentation.json"
status = 200
to = "/data/documentation/projectname.json"
###### Change it to name in ProjectName.doccarchive/data/documentation/...
# often just all lowercase of your project name

[[redirects]]
force = true
from = "/"
status = 302
to = "/documentation/"

[[redirects]]
force = true
from = "/documentation"
status = 302
to = "/documentation/"

[[redirects]]
force = true
from = "/tutorials"
status = 302
to = "/tutorials/"

推荐阅读