From c48b1ad08ea68a7eb97b687659ded3fe406a0091 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Mon, 9 Feb 2026 23:46:47 +0100 Subject: [PATCH] chore: updated plugins --- quartz.config.ts | 3 ++ quartz.layout.ts | 34 +++++++----- quartz.lock.json | 18 +++++++ quartz/plugins/loader/gitLoader.ts | 83 ++++++++++++++++++++++++++++++ tsconfig.json | 4 +- 5 files changed, 128 insertions(+), 14 deletions(-) diff --git a/quartz.config.ts b/quartz.config.ts index 420471f1b..95f7a8512 100644 --- a/quartz.config.ts +++ b/quartz.config.ts @@ -96,6 +96,9 @@ const config: QuartzConfig = { "github:quartz-community/explorer", "github:quartz-community/graph", "github:quartz-community/search", + "github:quartz-community/table-of-contents", + "github:quartz-community/backlinks", + "github:quartz-community/comments", ], } diff --git a/quartz.layout.ts b/quartz.layout.ts index ee38d0c47..2f3545333 100644 --- a/quartz.layout.ts +++ b/quartz.layout.ts @@ -1,18 +1,32 @@ import { PageLayout, SharedLayout } from "./quartz/cfg" import * as Component from "./quartz/components" -import Explorer from "./.quartz/plugins/explorer/src/components/Explorer" -import Graph from "./.quartz/plugins/graph/src/components/Graph" -import Search from "./.quartz/plugins/search/src/components/Search" +import { QuartzComponent } from "./quartz/components/types" +import { Explorer, Graph, Search, TableOfContents, Backlinks, Comments } from "./.quartz/plugins" -const explorerComponent = Explorer() -const graphComponent = Graph() -const searchComponent = Search() +const explorerComponent = Explorer() as QuartzComponent +const graphComponent = Graph() as QuartzComponent +const searchComponent = Search() as QuartzComponent +const tocComponent = TableOfContents() as QuartzComponent +const backlinksComponent = Backlinks() as QuartzComponent +const commentsComponent = Comments({ + provider: "giscus", + options: { + repo: "jackyzha0/quartz", + repoId: "MDEwOlJlcG9zaXRvcnkzODcyMTMyMDg", + category: "Announcements", + categoryId: "DIC_kwDOFxRnMM4CaYBe", + mapping: "pathname", + strict: false, + reactionsEnabled: true, + inputPosition: "top", + }, +}) as QuartzComponent // components shared across all pages export const sharedPageComponents: SharedLayout = { head: Component.Head(), header: [], - afterBody: [], + afterBody: [commentsComponent], footer: Component.Footer({ links: { GitHub: "https://github.com/jackyzha0/quartz", @@ -47,11 +61,7 @@ export const defaultContentPageLayout: PageLayout = { }), explorerComponent, ], - right: [ - graphComponent, - Component.DesktopOnly(Component.TableOfContents()), - Component.Backlinks(), - ], + right: [graphComponent, Component.DesktopOnly(tocComponent), backlinksComponent], } // components for pages that display lists of pages (e.g. tags or folders) diff --git a/quartz.lock.json b/quartz.lock.json index 2ead3fa75..ee1a07db5 100644 --- a/quartz.lock.json +++ b/quartz.lock.json @@ -18,6 +18,24 @@ "resolved": "https://github.com/quartz-community/search.git", "commit": "54b33d6fb493fe83c48f2a461217fd3fa962eedd", "installedAt": "2026-02-09T21:40:21.714Z" + }, + "backlinks": { + "source": "github:quartz-community/backlinks", + "resolved": "https://github.com/quartz-community/backlinks.git", + "commit": "8590be93126db3045ad46bd482437f0d30401f00", + "installedAt": "2026-02-09T22:21:12.217Z" + }, + "table-of-contents": { + "source": "github:quartz-community/table-of-contents", + "resolved": "https://github.com/quartz-community/table-of-contents.git", + "commit": "5274172a7cbe00556013a50c0543cd095cd911b3", + "installedAt": "2026-02-09T22:46:20.125Z" + }, + "comments": { + "source": "github:quartz-community/comments", + "resolved": "https://github.com/quartz-community/comments.git", + "commit": "265c635da1422da52dc2fa87bd4725b1ca0dc7ea", + "installedAt": "2026-02-09T22:21:30.065Z" } } } diff --git a/quartz/plugins/loader/gitLoader.ts b/quartz/plugins/loader/gitLoader.ts index 973bd1c64..cc0f3310f 100644 --- a/quartz/plugins/loader/gitLoader.ts +++ b/quartz/plugins/loader/gitLoader.ts @@ -148,6 +148,8 @@ export async function installPlugins( } } + await regeneratePluginIndex(options) + return installed } @@ -249,3 +251,84 @@ export function cleanPlugins(): void { console.log(styleText("green", `✓`), "Cleaned all plugins") } } + +export async function regeneratePluginIndex(options: { verbose?: boolean } = {}): Promise { + if (!fs.existsSync(PLUGINS_CACHE_DIR)) { + return + } + + const plugins = fs.readdirSync(PLUGINS_CACHE_DIR).filter((name) => { + const pluginPath = path.join(PLUGINS_CACHE_DIR, name) + return fs.statSync(pluginPath).isDirectory() + }) + + const exports: string[] = [] + + for (const pluginName of plugins) { + const pluginDir = path.join(PLUGINS_CACHE_DIR, pluginName) + const distIndex = path.join(pluginDir, "dist", "index.d.ts") + + if (!fs.existsSync(distIndex)) { + if (options.verbose) { + console.log(styleText("yellow", `⚠`), `Skipping ${pluginName}: no dist/index.d.ts found`) + } + continue + } + + const dtsContent = fs.readFileSync(distIndex, "utf-8") + const exportedNames = parseExportsFromDts(dtsContent) + + if (exportedNames.length > 0) { + const namedExports = exportedNames.filter((e) => !e.startsWith("type ")) + const typeExports = exportedNames.filter((e) => e.startsWith("type ")).map((e) => e.slice(5)) + + if (namedExports.length > 0) { + exports.push(`export { ${namedExports.join(", ")} } from "./${pluginName}"`) + } + if (typeExports.length > 0) { + exports.push(`export type { ${typeExports.join(", ")} } from "./${pluginName}"`) + } + } + } + + const indexContent = exports.join("\n") + "\n" + const indexPath = path.join(PLUGINS_CACHE_DIR, "index.ts") + + fs.writeFileSync(indexPath, indexContent) + + if (options.verbose) { + console.log(styleText("green", `✓`), `Regenerated plugin index with ${plugins.length} plugins`) + } +} + +const INTERNAL_EXPORTS = new Set(["manifest", "default"]) + +function parseExportsFromDts(content: string): string[] { + const exports: string[] = [] + + const exportMatches = content.matchAll(/export\s*{\s*([^}]+)\s*}(?:\s*from\s*['"]([^'"]+)['"])?/g) + for (const match of exportMatches) { + const fromModule = match[2] + if (fromModule?.startsWith("@")) { + continue + } + + const names = match[1] + .split(",") + .map((n) => n.trim()) + .filter(Boolean) + for (const name of names) { + const cleanName = name.split(" as ").pop()?.trim() || name.trim() + if (cleanName && !cleanName.startsWith("_") && !INTERNAL_EXPORTS.has(cleanName)) { + const finalName = cleanName.replace(/^type\s+/, "") + if (name.includes("type ")) { + exports.push(`type ${finalName}`) + } else { + exports.push(finalName) + } + } + } + } + + return exports +} diff --git a/tsconfig.json b/tsconfig.json index 637d09605..ec20577c7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,6 @@ "jsx": "react-jsx", "jsxImportSource": "preact" }, - "include": ["**/*.ts", "**/*.tsx", "./package.json"], - "exclude": ["build/**/*.d.ts"] + "include": ["quartz/**/*.ts", "quartz/**/*.tsx", "*.ts", "*.tsx", "./package.json"], + "exclude": ["build/**/*.d.ts", ".quartz/**", "node_modules/**"] }