mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 06:24:22 +02:00
doc(favicon): add documentation of favicon plugin (#1948)
Some checks failed
Build and Test / build-and-test (ubuntu-latest) (push) Has been skipped
Build and Test / publish-tag (push) Has been skipped
Build and Test / build-and-test (macos-latest) (push) Has been cancelled
Build and Test / build-and-test (windows-latest) (push) Has been cancelled
Some checks failed
Build and Test / build-and-test (ubuntu-latest) (push) Has been skipped
Build and Test / publish-tag (push) Has been skipped
Build and Test / build-and-test (macos-latest) (push) Has been cancelled
Build and Test / build-and-test (windows-latest) (push) Has been cancelled
* doc(favicon): add documentation of favicon plugin * doc(favicon): add missing link to configuration page * fix(favicon): build on public folder don't created
This commit is contained in:
parent
8d5b13ee03
commit
6ba9c7c02a
19
docs/plugins/Favicon.md
Normal file
19
docs/plugins/Favicon.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: Favicon
|
||||||
|
tags:
|
||||||
|
- plugin/emitter
|
||||||
|
---
|
||||||
|
|
||||||
|
This plugin emits a `favicon.ico` into the `public` folder. It creates the favicon from `icon.png` located in the `quartz/static` folder.
|
||||||
|
The plugin resizes `icon.png` to 48x48px to make it as small as possible.
|
||||||
|
|
||||||
|
> [!note]
|
||||||
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
- Category: Emitter
|
||||||
|
- Function name: `Plugin.Favicon()`.
|
||||||
|
- Source: [`quartz/plugins/emitters/favicon.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/favicon.ts).
|
@ -1,16 +1,22 @@
|
|||||||
import sharp from "sharp"
|
import sharp from "sharp"
|
||||||
import { joinSegments, QUARTZ, FilePath } from "../../util/path"
|
import { joinSegments, QUARTZ, FullSlug } from "../../util/path"
|
||||||
import { QuartzEmitterPlugin } from "../types"
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
|
import { write } from "./helpers"
|
||||||
|
import { BuildCtx } from "../../util/ctx"
|
||||||
|
|
||||||
export const Favicon: QuartzEmitterPlugin = () => ({
|
export const Favicon: QuartzEmitterPlugin = () => ({
|
||||||
name: "Favicon",
|
name: "Favicon",
|
||||||
async *emit({ argv }) {
|
async *emit({ argv }) {
|
||||||
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
|
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
|
||||||
const dest = joinSegments(argv.output, "favicon.ico") as FilePath
|
|
||||||
|
|
||||||
await sharp(iconPath).resize(48, 48).toFormat("png").toFile(dest)
|
const faviconContent = sharp(iconPath).resize(48, 48).toFormat("png")
|
||||||
|
|
||||||
yield dest
|
yield write({
|
||||||
|
ctx: { argv } as BuildCtx,
|
||||||
|
slug: "favicon" as FullSlug,
|
||||||
|
ext: ".ico",
|
||||||
|
content: faviconContent,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async *partialEmit() {},
|
async *partialEmit() {},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user