diff --git a/quartz/components/Head.tsx b/quartz/components/Head.tsx
index 4b82b426d1974..49f6f290252fc 100644
--- a/quartz/components/Head.tsx
+++ b/quartz/components/Head.tsx
@@ -1,6 +1,7 @@
import { i18n } from "../i18n";
import { FullSlug, joinSegments, pathToRoot, sluggify } from "../util/path";
import { JSResourceToScriptElement } from "../util/resources";
+import { getMetaImage } from "./scripts/util";
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types";
export default (() => {
@@ -15,13 +16,7 @@ export default (() => {
const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!);
const iconPath = joinSegments(baseDir, "static/icon.png");
- let ogImagePath = `https://${cfg.baseUrl}/static/og-image.png`;
- if (cfg.ogImageDir) {
- const contentDir = `https://${cfg.baseUrl}/${cfg.ogImageDir}/`;
- ogImagePath = fileData?.frontmatter?.image
- ? sluggify(`${contentDir}${(fileData.frontmatter.image as string).trim()}`)
- : `https://${cfg.baseUrl}/static/og-image.png`;
- }
+ const ogImagePath = getMetaImage(cfg, fileData);
return (
{title}
diff --git a/quartz/components/PageList.tsx b/quartz/components/PageList.tsx
index b086b89a503ad..26593a797646d 100644
--- a/quartz/components/PageList.tsx
+++ b/quartz/components/PageList.tsx
@@ -1,8 +1,9 @@
import { GlobalConfiguration } from "../cfg";
import { QuartzPluginData } from "../plugins/vfile";
-import { FullSlug, resolveRelative } from "../util/path";
+import { FullSlug, resolveRelative, sluggify } from "../util/path";
import { Date, getDate } from "./Date";
import { QuartzComponent, QuartzComponentProps } from "./types";
+import fs from 'fs';
export function byDateAndAlphabetical(
cfg: GlobalConfiguration,
@@ -38,9 +39,20 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
return (
{list.map((page) => {
- const title = page.frontmatter?.title;
+ let title = page.frontmatter?.title;
+ if (title === "index") {
+ const path = page.slug?.split("/");
+ title = path?.[path.length - 2].replace("-", " ") ?? "index";
+ }
const tags = page.frontmatter?.tags ?? [];
-
+ const description = page.frontmatter?.description;
+ let image : string | undefined = page.frontmatter?.image as string ?? undefined ;
+ if (cfg.ogImageDir) {
+ image = `${cfg.ogImageDir}/${image}`
+ image = resolveRelative(fileData.slug!, image as FullSlug);
+ //check if image exists
+ image = fs.existsSync(image) ? image : undefined;
+ }
return (
-
@@ -55,6 +67,19 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
{title}
+