简体   繁体   English

使用“ nanoc视图”更改预览网站的默认内容类型

[英]Change default content type for previewing site with “nanoc view”

I generate HTML files without any filetype extension with the following route in nanoc's Rules file: 我在nanoc的Rules文件中使用以下路由生成了没有任何文件类型扩展名的HTML文件:

route '/blog/*/' do
  item.identifier.chop
end

So the file /content/blog/hello-world.html gets generated as /output/blog/hello-world , leading to the URL path /blog/hello-world . 因此, /output/blog/hello-world /content/blog/hello-world.html /output/blog/hello-world /content/blog/hello-world.html文件将作为/output/blog/hello-world ,并指向URL路径/blog/hello-world

When using nanoc's built-in preview server ( nanoc view , which uses adsf and WEBrick, as far as I understand), these extension-less HTML files get interpreted as plain text. 使用nanoc的内置预览服务器(据我所知, nanoc view使用adsf和WEBrick)时,这些无扩展名的HTML文件将被解释为纯文本。

For previewing with nanoc view , how can I set the default content type (ie text/html ) for files without filetype extensions? 要使用nanoc view进行预览, 如何为不带文件类型扩展名的文件设置默认的内容类型(即text/html )?

(When publishing this site, I set the correct content type in Apache's .htaccess file so that the files get interpreted as HTML, but WEBrick/adsf don't seem to support .htaccess .) (发布此网站时,我在Apache的.htaccess文件中设置了正确的内容类型,以便将文件解释为HTML,但WEBrick / adsf似乎不支持.htaccess 。)

You should be writing those to /output/blog/hello-world/index.html instead. 您应该将它们写入/output/blog/hello-world/index.html That makes them work seamlessly in nanoc view , Apache (with no .htaccess ), even by just opening the site files in your browser (assuming you're using relativized links). 这使得它们即使在浏览器中打开站点文件(假设您正在使用相对链接),也可以在nanoc view (Apache(无.htaccess ))中无缝工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM