The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

doc(favicon): add documentation of favicon plugin (#1948)

* doc(favicon): add documentation of favicon plugin

* doc(favicon): add missing link to configuration page

* fix(favicon): build on public folder don't created

authored by

dralagen and committed by
GitHub
6ba9c7c0 8d5b13ee

+29 -4
+19
docs/plugins/Favicon.md
··· 1 + --- 2 + title: Favicon 3 + tags: 4 + - plugin/emitter 5 + --- 6 + 7 + This plugin emits a `favicon.ico` into the `public` folder. It creates the favicon from `icon.png` located in the `quartz/static` folder. 8 + The plugin resizes `icon.png` to 48x48px to make it as small as possible. 9 + 10 + > [!note] 11 + > For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page. 12 + 13 + This plugin has no configuration options. 14 + 15 + ## API 16 + 17 + - Category: Emitter 18 + - Function name: `Plugin.Favicon()`. 19 + - Source: [`quartz/plugins/emitters/favicon.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/favicon.ts).
+10 -4
quartz/plugins/emitters/favicon.ts
··· 1 1 import sharp from "sharp" 2 - import { joinSegments, QUARTZ, FilePath } from "../../util/path" 2 + import { joinSegments, QUARTZ, FullSlug } from "../../util/path" 3 3 import { QuartzEmitterPlugin } from "../types" 4 + import { write } from "./helpers" 5 + import { BuildCtx } from "../../util/ctx" 4 6 5 7 export const Favicon: QuartzEmitterPlugin = () => ({ 6 8 name: "Favicon", 7 9 async *emit({ argv }) { 8 10 const iconPath = joinSegments(QUARTZ, "static", "icon.png") 9 - const dest = joinSegments(argv.output, "favicon.ico") as FilePath 10 11 11 - await sharp(iconPath).resize(48, 48).toFormat("png").toFile(dest) 12 + const faviconContent = sharp(iconPath).resize(48, 48).toFormat("png") 12 13 13 - yield dest 14 + yield write({ 15 + ctx: { argv } as BuildCtx, 16 + slug: "favicon" as FullSlug, 17 + ext: ".ico", 18 + content: faviconContent, 19 + }) 14 20 }, 15 21 async *partialEmit() {}, 16 22 })