Favicon
使用 SVG 文件作为源文件自动创建所有需要的 Favicon
配置参数
- input string
The input file to generate the favicons Accepted formats are SVG, PNG, JPG, GIF, BMP, TIFF, WEBP
Default:"/favicon.svg"
- cache string boolean
The cache folder
Default:true
- favicons object[]
The generated favicons By default it follows the recommendations from: https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs
Default:[ { url: "/favicon.ico", size: [ 48 ], rel: "icon", format: "ico" }, { url: "/apple-touch-icon.png", size: [ 180 ], rel: "apple-touch-icon", format: "png" } ]
Description
这个插件读取一个文件(默认是 /favicon.svg
)并生成以下文件:
/favicon.ico
/apple-touch-icon.png
它还会将 <link>
元素添加到所有 HTML 页面中,以正确配置 Favicon,并遵循 2023 年“如何制作 Favicon”的权威指南 文章,以优先考虑 SVG 格式。
Installation
在你的 _config.ts
文件中导入这个插件来使用它:
import lume from "lume/mod.ts";
import favicon from "lume/plugins/favicon.ts";
const site = lume();
site.use(favicon(/* Options */)); // 选项
export default site;
请注意,你的源文件夹中需要有一个 1/1 宽高比的 /favicon.svg
文件。你可以在配置中设置另一个文件名或图像格式:
site.use(favicon({
input: "/my-custom-favicon.png",
}));