Skip to content

Commit 6ba9c7c

Browse files
authored
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
1 parent 8d5b13e commit 6ba9c7c

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

docs/plugins/Favicon.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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).

quartz/plugins/emitters/favicon.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import sharp from "sharp"
2-
import { joinSegments, QUARTZ, FilePath } from "../../util/path"
2+
import { joinSegments, QUARTZ, FullSlug } from "../../util/path"
33
import { QuartzEmitterPlugin } from "../types"
4+
import { write } from "./helpers"
5+
import { BuildCtx } from "../../util/ctx"
46

57
export const Favicon: QuartzEmitterPlugin = () => ({
68
name: "Favicon",
79
async *emit({ argv }) {
810
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
9-
const dest = joinSegments(argv.output, "favicon.ico") as FilePath
1011

11-
await sharp(iconPath).resize(48, 48).toFormat("png").toFile(dest)
12+
const faviconContent = sharp(iconPath).resize(48, 48).toFormat("png")
1213

13-
yield dest
14+
yield write({
15+
ctx: { argv } as BuildCtx,
16+
slug: "favicon" as FullSlug,
17+
ext: ".ico",
18+
content: faviconContent,
19+
})
1420
},
1521
async *partialEmit() {},
1622
})

0 commit comments

Comments
 (0)