Eleventy 不会html
为从嵌套 index.md 文件生成的索引文件添加后缀。
例如,这是一个包含我的源内容的示例目录结构......
|
+- /src (input dir)
|
+- post
| |
| +- my-cool-post
| |
| +- /images
| |
| +- index.md
|
+- index.md
|
+- about.md
当我然后运行命令时,npx eleventy
我得到以下输出......
|
+- /public (output dir)
|
+- post
| |
| +- my-cool-post
| |
| +- /images
| |
| +- index <---- NOTE there is no ".html" suffix on this file
|
+- index.html <----- this file is ok however
|
+- about.html <----- and so is this file
这就是我.eleventy.js
设置配置文件的方式..
// Data Extensions
const yaml = require("js-yaml");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("_assets");
eleventyConfig.addWatchTarget("./src/_sass/");
eleventyConfig.addDataExtension("yaml", contents => yaml.safeLoad(contents));
eleventyConfig.setTemplateFormats([
"md",
"css",
"jpg",
"png",
"webp",
"svg",
"html"
]);
return {
jsDataFileSuffix: ".11ty",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk",
passthroughFileCopy: true,
dir: {
input: "src",
data: "_data",
includes: "_includes",
layouts: "_layouts",
output: "public"
}
}
}
没有*.html
后缀的 url 会http://../post/my-cool-post
返回 404 错误。如果我手动添加*.html
后缀,那么它可以工作。
知道我的设置有什么问题吗?