mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-26 06:14:06 -06:00
Update Head.tsx
This commit is contained in:
parent
8108c72a9d
commit
7428905926
@ -2,7 +2,7 @@ import { i18n } from "../i18n"
|
|||||||
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
||||||
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
||||||
import { getFontSpecificationName, googleFontHref } from "../util/theme"
|
import { getFontSpecificationName, googleFontHref } from "../util/theme"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import satori, { SatoriOptions } from "satori"
|
import satori, { SatoriOptions } from "satori"
|
||||||
import { loadEmoji, getIconCode } from "../util/emoji"
|
import { loadEmoji, getIconCode } from "../util/emoji"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
@ -15,7 +15,7 @@ import { unescapeHTML } from "../util/escape"
|
|||||||
* @param opts options for generating image
|
* @param opts options for generating image
|
||||||
*/
|
*/
|
||||||
async function generateSocialImage(
|
async function generateSocialImage(
|
||||||
{ cfg, description, fileName, fontsPromise, title, fileData }: ImageOptions,
|
{ cfg, description, fileName, fontsPromise, title, fileData }: ImageOptions,
|
||||||
userOpts: SocialImageOptions,
|
userOpts: SocialImageOptions,
|
||||||
imageDir: string,
|
imageDir: string,
|
||||||
) {
|
) {
|
||||||
@ -25,7 +25,7 @@ async function generateSocialImage(
|
|||||||
// JSX that will be used to generate satori svg
|
// JSX that will be used to generate satori svg
|
||||||
const imageComponent = userOpts.imageStructure(cfg, userOpts, title, description, fonts, fileData)
|
const imageComponent = userOpts.imageStructure(cfg, userOpts, title, description, fonts, fileData)
|
||||||
|
|
||||||
const svg = await satori(imageComponent, {
|
const svg = await satori(imageComponent, {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
fonts,
|
fonts,
|
||||||
@ -66,7 +66,7 @@ export default (() => {
|
|||||||
externalResources,
|
externalResources,
|
||||||
ctx,
|
ctx,
|
||||||
}: QuartzComponentProps) => {
|
}: QuartzComponentProps) => {
|
||||||
// Initialize options if not set
|
// Initialize options if not set
|
||||||
if (!fullOptions) {
|
if (!fullOptions) {
|
||||||
if (typeof cfg.generateSocialImages !== "boolean") {
|
if (typeof cfg.generateSocialImages !== "boolean") {
|
||||||
fullOptions = { ...defaultOptions, ...cfg.generateSocialImages }
|
fullOptions = { ...defaultOptions, ...cfg.generateSocialImages }
|
||||||
@ -147,7 +147,7 @@ export default (() => {
|
|||||||
// Use default og image if filePath doesnt exist (for autogenerated paths with no .md file)
|
// Use default og image if filePath doesnt exist (for autogenerated paths with no .md file)
|
||||||
const useDefaultOgImage = fileName === undefined || !cfg.generateSocialImages
|
const useDefaultOgImage = fileName === undefined || !cfg.generateSocialImages
|
||||||
|
|
||||||
// Path to og/social image (priority: frontmatter > generated image (if enabled) > default image)
|
// Path to og/social image (priority: frontmatter > generated image (if enabled) > default image)
|
||||||
let ogImagePath = useDefaultOgImage ? ogImageDefaultPath : ogImageGeneratedPath
|
let ogImagePath = useDefaultOgImage ? ogImageDefaultPath : ogImageGeneratedPath
|
||||||
|
|
||||||
// TODO: could be improved to support external images in the future
|
// TODO: could be improved to support external images in the future
|
||||||
@ -171,20 +171,9 @@ export default (() => {
|
|||||||
return (
|
return (
|
||||||
<head>
|
<head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
{cfg.theme.cdnCaching && cfg.theme.fontOrigin === "local" ? (
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.1.0/style.css" />
|
||||||
<>
|
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />
|
||||||
<link rel="preconnect" href="https://cdn.staticfile.org" />
|
|
||||||
<link rel="stylesheet" href="https://cdn.staticfile.org/lxgw-wenkai-webfont/1.7.0/style.css" />
|
|
||||||
</>
|
|
||||||
) : cfg.theme.fontOrigin === "googleFonts" ? (
|
|
||||||
<>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
|
|
||||||
<link rel="stylesheet" href={googleFontHref(cfg.theme)} />
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
{/* OG/Twitter meta tags */}
|
{/* OG/Twitter meta tags */}
|
||||||
<meta name="og:site_name" content={cfg.pageTitle}></meta>
|
<meta name="og:site_name" content={cfg.pageTitle}></meta>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user