eleventy webpack
1.0.0
准系统十一和 webpack 模板。叉子然后走。
.js
(ES6、Babel、Polyfill).css
(Sass、PostCSS、自动前缀器)noopener
和noreferrer
)现场演示 https://eleventy-webpack.netlify.app
首先安装依赖项:
npm install
然后你可以:
命令 | 描述 |
---|---|
npm run start | 在 http://localhost:8080 上运行您的网站 |
npm run build | 在/_site 内构建您的生产网站 |
npm run format | 在除/_site 之外的所有填充上运行 prettier |
npm run analyze | 输出有关捆绑包大小的信息 |
确保使用正确的 node.js 版本:
# with bash nvm
nvm use ` cat .nvmrc `
# with windows nvm
nvm use $( cat .nvmrc )
# or just install the version specified inside `.nvmrc`
包含一个非常简单的webpack.config.js
。请随意更改它。
所有短代码都可以在.md
或.njk
文件内使用。
icon
添加到src/assets/icons
的任何 SVG 都会捆绑到符号精灵文件中,并通过此短代码提供。
<!-- Assuming `src/assets/icons/github.svg` exist -->
{% icon "github" %} Github icon
<!-- Will be rendered as -->
< svg class =" icon icon--github " role =" img " aria-hidden =" true " >
< use xlink:href =" /assets/images/sprite.svg#github " > </ use >
</ svg >
image
创建图像的 WebP 版本和相应的优化 JPEG / PNG。图像将以多种尺寸创建。有关默认值,请参阅utils/shortcodes.js
。
<!-- Assuming `src/assets/images/image.jpeg` of width 330px exist -->
{% image "image.jpeg", "Image alt" %}
<!-- Will be rendered as -->
< picture >
< source type =" image/webp " srcset =" /assets/images/678868de-320.webp 320w, /assets/images/678868de.webp 330w " sizes =" 90vw " >
< source type =" image/png " srcset =" /assets/images/678868de-320.png 320w, /assets/images/678868de.png 330w " sizes =" 90vw " >
< img loading =" lazy " src =" /assets/images/678868de.png " alt =" Image alt " width =" 330 " height =" 580 " >
</ picture >
<!-- If a title is passed the shortcode will output a <figure> with <figcaption> -->
{% image "image.jpeg", "Image alt", "Image title" %}
<!-- Will be rendered as -->
< figure >
< picture >
< source type =" image/webp " srcset =" /assets/images/678868de-320.webp 320w, /assets/images/678868de.webp 330w " sizes =" 90vw " >
< source type =" image/png " srcset =" /assets/images/678868de-320.png 320w, /assets/images/678868de.png 330w " sizes =" 90vw " >
< img loading =" lazy " src =" /assets/images/678868de.png " alt =" Image alt " width =" 330 " height =" 580 " >
</ picture >
< figcaption > Image title </ figcaption >
</ figure >
<!-- Additional options -->
{% image [100,100], "image.jpeg", "Image alt", "Image title", "my-class", false, "90vw" %}
<!-- Will be rendered as -->
< figure class =" fig-my-class " >
< picture >
< source type =" image/webp " srcset =" ... " sizes =" 90vw " >
< source type =" image/png " srcset =" ... " sizes =" 90vw " >
< img class =" img-my-class " loading =" eager " src =" ... " alt =" Image alt " width =" 100 " height =" 100 " >
</ picture >
< figcaption > Image title </ figcaption >
</ figure >
markdown
轻松嵌入 Markdown。
{% markdown %}
Let's you use **Markdown** like _this_.
Or with includes {%- include 'content.md' -%}.
{% endmarkdown %}
所有过滤器都可以在.md
或.njk
文件内使用。
format
使用 date-fns 格式化传递的日期:
<!-- Assuming page.date is a javascript date -->
{{ page.date | format("yyyy") }}
<!-- Will be rendered as -->
2020
formatISO
根据 ISO 格式格式化传递的日期:
<!-- Assuming page.date is a javascript date -->
{{ page.date | formatISO }}
<!-- Will be rendered as -->
2020-09-18T19:00:52Z
markdown
用 markdown 解析传递的字符串:
<!-- Assuming page.title is `# My header` -->
{{ page.title | markdown }}
<!-- Will be rendered as -->
< h1 > My header </ h1 >