feat(favicon): add plugin to expose favicon from icon.png (#1942)
* feat(favicon): add plugin to expose favicon from icon.png * chore(favicon): clean up formatting and remove unnecessary line breaks
This commit is contained in:
		@@ -86,6 +86,7 @@ const config: QuartzConfig = {
 | 
				
			|||||||
      }),
 | 
					      }),
 | 
				
			||||||
      Plugin.Assets(),
 | 
					      Plugin.Assets(),
 | 
				
			||||||
      Plugin.Static(),
 | 
					      Plugin.Static(),
 | 
				
			||||||
 | 
					      Plugin.Favicon(),
 | 
				
			||||||
      Plugin.NotFoundPage(),
 | 
					      Plugin.NotFoundPage(),
 | 
				
			||||||
      // Comment out CustomOgImages to speed up build time
 | 
					      // Comment out CustomOgImages to speed up build time
 | 
				
			||||||
      Plugin.CustomOgImages(),
 | 
					      Plugin.CustomOgImages(),
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								quartz/plugins/emitters/favicon.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								quartz/plugins/emitters/favicon.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					import sharp from "sharp"
 | 
				
			||||||
 | 
					import { joinSegments, QUARTZ, FilePath } from "../../util/path"
 | 
				
			||||||
 | 
					import { QuartzEmitterPlugin } from "../types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const Favicon: QuartzEmitterPlugin = () => ({
 | 
				
			||||||
 | 
					  name: "Favicon",
 | 
				
			||||||
 | 
					  async *emit({ argv }) {
 | 
				
			||||||
 | 
					    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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    yield dest
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  async *partialEmit() {},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
@@ -5,6 +5,7 @@ export { ContentIndex as ContentIndex } from "./contentIndex"
 | 
				
			|||||||
export { AliasRedirects } from "./aliases"
 | 
					export { AliasRedirects } from "./aliases"
 | 
				
			||||||
export { Assets } from "./assets"
 | 
					export { Assets } from "./assets"
 | 
				
			||||||
export { Static } from "./static"
 | 
					export { Static } from "./static"
 | 
				
			||||||
 | 
					export { Favicon } from "./favicon"
 | 
				
			||||||
export { ComponentResources } from "./componentResources"
 | 
					export { ComponentResources } from "./componentResources"
 | 
				
			||||||
export { NotFoundPage } from "./404"
 | 
					export { NotFoundPage } from "./404"
 | 
				
			||||||
export { CNAME } from "./cname"
 | 
					export { CNAME } from "./cname"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user