mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-21 21:45:42 -05:00
chore: updated plugins
This commit is contained in:
parent
e1dac146b8
commit
c48b1ad08e
@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<void> {
|
||||
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
|
||||
}
|
||||
|
||||
@ -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/**"]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user