fix: use fetchData global for path-prefixed deployments

- Update types/globals.d.ts with centralized type declarations
- Use fetchData global instead of hardcoded /static/contentIndex.json
- Revert @quartz-community/types from file:../types to github:quartz-community/types
- Add .prettierignore, update .eslintrc.json with triple-slash-reference override
- Remove duplicate scripts.d.ts/styles.d.ts
This commit is contained in:
saberzero1 2026-03-16 18:54:25 +01:00
parent 44d6b56e3e
commit 05487abbe0
No known key found for this signature in database
14 changed files with 753 additions and 633 deletions

View file

@ -22,5 +22,13 @@
"caughtErrorsIgnorePattern": "^_"
}
]
}
},
"overrides": [
{
"files": ["types/**/*.d.ts"],
"rules": {
"@typescript-eslint/triple-slash-reference": "off"
}
}
]
}

1
.prettierignore Normal file
View file

@ -0,0 +1 @@
dist

View file

@ -241,7 +241,7 @@ Component scripts run in the browser and must handle Quartz's SPA navigation. Ke
2. **Listen to `nav` event** - Fires after each page navigation (including initial load)
3. **Listen to `prenav` event** - Fires before navigation, use for saving state
4. **Use `window.addCleanup()`** - Register cleanup functions for event listeners
5. **Fetch `/static/contentIndex.json`** - Access page metadata for search, graph, etc.
5. **Use `fetchData` global** - Access page metadata via the `fetchData` promise (handles base path correctly)
See `src/components/scripts/example.inline.ts` for a complete example with all patterns.
@ -283,9 +283,8 @@ When migrating a v4 component to a standalone plugin:
1. **Replace Quartz imports** with `@quartz-community/types`
2. **Copy utility functions** (path helpers, DOM utils) into your plugin
3. **Use `@ts-nocheck`** for inline scripts that can't be type-checked
4. **Fetch data directly** from `/static/contentIndex.json` instead of using `fetchData`
5. **Handle both data formats**: `data.content || data` for contentIndex compatibility
6. **Test with both local and production builds**
4. **Use the `fetchData` global** to access `contentIndex.json` with the correct base path
5. **Test with both local and production builds**
## License

View file

@ -1,4 +1,4 @@
import { jsx } from "preact/jsx-runtime";
import { jsx } from 'preact/jsx-runtime';
// src/util/lang.ts
function classNames(...classes) {
@ -6,13 +6,11 @@ function classNames(...classes) {
}
// src/components/styles/example.scss
var example_default =
".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}";
var example_default = ".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}";
// src/components/scripts/example.inline.ts
var example_inline_default =
'function c(){let e=window.location.pathname;return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e||"index"}function r(){let e=document.querySelectorAll(".example-component");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()==="e"&&(n.preventDefault(),console.log("[ExampleComponent] Keyboard shortcut triggered!"))}document.addEventListener("keydown",o),t.push(()=>document.removeEventListener("keydown",o));for(let n of e){let i=()=>{console.log("[ExampleComponent] Clicked!")};n.addEventListener("click",i),t.push(()=>n.removeEventListener("click",i))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log("[ExampleComponent] Initialized with",e.length,"component(s)")}document.addEventListener("nav",e=>{let t=e.detail?.url||c();console.log("[ExampleComponent] Navigation to:",t),r()});document.addEventListener("render",()=>{console.log("[ExampleComponent] Render event - re-initializing"),r()});document.addEventListener("prenav",()=>{let e=document.querySelector(".example-component");e&&sessionStorage.setItem("exampleScrollTop",e.scrollTop?.toString()||"0")});\n';
var ExampleComponent_default = (opts) => {
var example_inline_default = 'function l(){let e=window.location.pathname;return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e||"index"}function r(){let e=document.querySelectorAll(".example-component");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()==="e"&&(n.preventDefault(),console.log("[ExampleComponent] Keyboard shortcut triggered!"))}document.addEventListener("keydown",o),t.push(()=>document.removeEventListener("keydown",o));for(let n of e){let i=()=>{console.log("[ExampleComponent] Clicked!")};n.addEventListener("click",i),t.push(()=>n.removeEventListener("click",i))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log("[ExampleComponent] Initialized with",e.length,"component(s)")}document.addEventListener("nav",e=>{let t=e.detail?.url||l();console.log("[ExampleComponent] Navigation to:",t),r()});document.addEventListener("render",()=>{console.log("[ExampleComponent] Render event - re-initializing"),r()});document.addEventListener("prenav",()=>{let e=document.querySelector(".example-component");e&&sessionStorage.setItem("exampleScrollTop",e.scrollTop?.toString()||"0")});\n';
var ExampleComponent_default = ((opts) => {
const { prefix = "", suffix = "", className = "example-component" } = opts ?? {};
const Component = (props) => {
const frontmatter = props.fileData?.frontmatter;
@ -23,8 +21,8 @@ var ExampleComponent_default = (opts) => {
Component.css = example_default;
Component.afterDOMLoaded = example_inline_default;
return Component;
};
});
export { ExampleComponent_default as ExampleComponent };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

View file

@ -1 +1 @@
{"version":3,"sources":["../../src/util/lang.ts","../../src/components/styles/example.scss","../../src/components/scripts/example.inline.ts","../../src/components/ExampleComponent.tsx"],"names":[],"mappings":";;;AAAO,SAAS,cAAc,OAAA,EAAwD;AACpF,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACzC;;;ACFA,IAAA,eAAA,GAAA,wMAAA;;;ACAA,IAAA,sBAAA,GAAA,mqCAAA;ACgBA,IAAO,wBAAA,IAAS,CAAC,IAAA,KAAmC;AAClD,EAAA,MAAM,EAAE,SAAS,EAAA,EAAI,MAAA,GAAS,IAAI,SAAA,GAAY,mBAAA,EAAoB,GAAI,IAAA,IAAQ,EAAC;AAE/E,EAAA,MAAM,SAAA,GAA6B,CAAC,KAAA,KAAgC;AAClE,IAAA,MAAM,WAAA,GAAc,MAAM,QAAA,EAAU,WAAA;AACpC,IAAA,MAAM,KAAA,GAAQ,aAAa,KAAA,IAAS,UAAA;AACpC,IAAA,MAAM,WAAW,CAAA,EAAG,MAAM,CAAA,EAAG,KAAK,GAAG,MAAM,CAAA,CAAA;AAE3C,IAAA,2BAAQ,KAAA,EAAA,EAAI,KAAA,EAAO,UAAA,CAAW,SAAS,GAAI,QAAA,EAAA,QAAA,EAAS,CAAA;AAAA,EACtD,CAAA;AAEA,EAAA,SAAA,CAAU,GAAA,GAAM,eAAA;AAChB,EAAA,SAAA,CAAU,cAAA,GAAiB,sBAAA;AAE3B,EAAA,OAAO,SAAA;AACT,CAAA","file":"index.js","sourcesContent":["export function classNames(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n",".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}","function c(){let e=window.location.pathname;return e.startsWith(\"/\")&&(e=e.slice(1)),e.endsWith(\"/\")&&(e=e.slice(0,-1)),e||\"index\"}function r(){let e=document.querySelectorAll(\".example-component\");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()===\"e\"&&(n.preventDefault(),console.log(\"[ExampleComponent] Keyboard shortcut triggered!\"))}document.addEventListener(\"keydown\",o),t.push(()=>document.removeEventListener(\"keydown\",o));for(let n of e){let i=()=>{console.log(\"[ExampleComponent] Clicked!\")};n.addEventListener(\"click\",i),t.push(()=>n.removeEventListener(\"click\",i))}typeof window<\"u\"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log(\"[ExampleComponent] Initialized with\",e.length,\"component(s)\")}document.addEventListener(\"nav\",e=>{let t=e.detail?.url||c();console.log(\"[ExampleComponent] Navigation to:\",t),r()});document.addEventListener(\"render\",()=>{console.log(\"[ExampleComponent] Render event - re-initializing\"),r()});document.addEventListener(\"prenav\",()=>{let e=document.querySelector(\".example-component\");e&&sessionStorage.setItem(\"exampleScrollTop\",e.scrollTop?.toString()||\"0\")});\n","import type {\n QuartzComponent,\n QuartzComponentProps,\n QuartzComponentConstructor,\n} from \"@quartz-community/types\";\nimport { classNames } from \"../util/lang\";\nimport style from \"./styles/example.scss\";\n// @ts-expect-error - inline script import handled by Quartz bundler\nimport script from \"./scripts/example.inline.ts\";\n\nexport interface ExampleComponentOptions {\n prefix?: string;\n suffix?: string;\n className?: string;\n}\n\nexport default ((opts?: ExampleComponentOptions) => {\n const { prefix = \"\", suffix = \"\", className = \"example-component\" } = opts ?? {};\n\n const Component: QuartzComponent = (props: QuartzComponentProps) => {\n const frontmatter = props.fileData?.frontmatter as { title?: string } | undefined;\n const title = frontmatter?.title ?? \"Untitled\";\n const fullText = `${prefix}${title}${suffix}`;\n\n return <div class={classNames(className)}>{fullText}</div>;\n };\n\n Component.css = style;\n Component.afterDOMLoaded = script;\n\n return Component;\n}) satisfies QuartzComponentConstructor;\n"]}
{"version":3,"sources":["../../src/util/lang.ts","../../src/components/styles/example.scss","../../src/components/scripts/example.inline.ts","../../src/components/ExampleComponent.tsx"],"names":[],"mappings":";;;AAAO,SAAS,cAAc,OAAA,EAAwD;AACpF,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACzC;;;ACFA,IAAA,eAAA,GAAA,wMAAA;;;ACAA,IAAA,sBAAA,GAAA,mqCAAA;ACgBA,IAAO,wBAAA,IAAS,CAAC,IAAA,KAAmC;AAClD,EAAA,MAAM,EAAE,SAAS,EAAA,EAAI,MAAA,GAAS,IAAI,SAAA,GAAY,mBAAA,EAAoB,GAAI,IAAA,IAAQ,EAAC;AAE/E,EAAA,MAAM,SAAA,GAA6B,CAAC,KAAA,KAAgC;AAClE,IAAA,MAAM,WAAA,GAAc,MAAM,QAAA,EAAU,WAAA;AACpC,IAAA,MAAM,KAAA,GAAQ,aAAa,KAAA,IAAS,UAAA;AACpC,IAAA,MAAM,WAAW,CAAA,EAAG,MAAM,CAAA,EAAG,KAAK,GAAG,MAAM,CAAA,CAAA;AAE3C,IAAA,2BAAQ,KAAA,EAAA,EAAI,KAAA,EAAO,UAAA,CAAW,SAAS,GAAI,QAAA,EAAA,QAAA,EAAS,CAAA;AAAA,EACtD,CAAA;AAEA,EAAA,SAAA,CAAU,GAAA,GAAM,eAAA;AAChB,EAAA,SAAA,CAAU,cAAA,GAAiB,sBAAA;AAE3B,EAAA,OAAO,SAAA;AACT,CAAA","file":"index.js","sourcesContent":["export function classNames(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n",".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}","function l(){let e=window.location.pathname;return e.startsWith(\"/\")&&(e=e.slice(1)),e.endsWith(\"/\")&&(e=e.slice(0,-1)),e||\"index\"}function r(){let e=document.querySelectorAll(\".example-component\");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()===\"e\"&&(n.preventDefault(),console.log(\"[ExampleComponent] Keyboard shortcut triggered!\"))}document.addEventListener(\"keydown\",o),t.push(()=>document.removeEventListener(\"keydown\",o));for(let n of e){let i=()=>{console.log(\"[ExampleComponent] Clicked!\")};n.addEventListener(\"click\",i),t.push(()=>n.removeEventListener(\"click\",i))}typeof window<\"u\"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log(\"[ExampleComponent] Initialized with\",e.length,\"component(s)\")}document.addEventListener(\"nav\",e=>{let t=e.detail?.url||l();console.log(\"[ExampleComponent] Navigation to:\",t),r()});document.addEventListener(\"render\",()=>{console.log(\"[ExampleComponent] Render event - re-initializing\"),r()});document.addEventListener(\"prenav\",()=>{let e=document.querySelector(\".example-component\");e&&sessionStorage.setItem(\"exampleScrollTop\",e.scrollTop?.toString()||\"0\")});\n","import type {\n QuartzComponent,\n QuartzComponentProps,\n QuartzComponentConstructor,\n} from \"@quartz-community/types\";\nimport { classNames } from \"../util/lang\";\nimport style from \"./styles/example.scss\";\n// @ts-expect-error - inline script import handled by Quartz bundler\nimport script from \"./scripts/example.inline.ts\";\n\nexport interface ExampleComponentOptions {\n prefix?: string;\n suffix?: string;\n className?: string;\n}\n\nexport default ((opts?: ExampleComponentOptions) => {\n const { prefix = \"\", suffix = \"\", className = \"example-component\" } = opts ?? {};\n\n const Component: QuartzComponent = (props: QuartzComponentProps) => {\n const frontmatter = props.fileData?.frontmatter as { title?: string } | undefined;\n const title = frontmatter?.title ?? \"Untitled\";\n const fullText = `${prefix}${title}${suffix}`;\n\n return <div class={classNames(className)}>{fullText}</div>;\n };\n\n Component.css = style;\n Component.afterDOMLoaded = script;\n\n return Component;\n}) satisfies QuartzComponentConstructor;\n"]}

103
dist/index.js vendored
View file

@ -1,35 +1,32 @@
import remarkGfm from "remark-gfm";
import rehypeSlug from "rehype-slug";
import { findAndReplace } from "mdast-util-find-and-replace";
import { visit } from "unist-util-visit";
import path from "path";
import fs from "fs/promises";
import { jsx } from "preact/jsx-runtime";
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
import { findAndReplace } from 'mdast-util-find-and-replace';
import { visit } from 'unist-util-visit';
import path from 'path';
import fs from 'fs/promises';
import { jsx } from 'preact/jsx-runtime';
// src/transformer.ts
var defaultOptions = {
highlightToken: "==",
headingClass: "example-plugin-heading",
enableGfm: true,
addHeadingSlugs: true,
addHeadingSlugs: true
};
var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
var remarkHighlightToken = (token) => {
const escapedToken = escapeRegExp(token);
const pattern = new RegExp(
`${escapedToken}([^
]+?)${escapedToken}`,
"g",
);
const pattern = new RegExp(`${escapedToken}([^
]+?)${escapedToken}`, "g");
return () => (tree, _file) => {
findAndReplace(tree, [
[
pattern,
(_match, value) => ({
type: "strong",
children: [{ type: "text", value }],
}),
],
children: [{ type: "text", value }]
})
]
]);
};
};
@ -40,14 +37,10 @@ var rehypeHeadingClass = (className) => {
return;
}
const existing = node.properties?.className;
const classes = Array.isArray(existing)
? existing.filter((value) => typeof value === "string")
: typeof existing === "string"
? [existing]
: [];
const classes = Array.isArray(existing) ? existing.filter((value) => typeof value === "string") : typeof existing === "string" ? [existing] : [];
node.properties = {
...node.properties,
className: [...classes, className],
className: [...classes, className]
};
});
};
@ -57,9 +50,7 @@ var ExampleTransformer = (userOptions) => {
return {
name: "ExampleTransformer",
textTransform(_ctx, src) {
return src.endsWith("\n")
? src
: `${src}
return src.endsWith("\n") ? src : `${src}
`;
},
markdownPlugins() {
@ -81,19 +72,19 @@ var ExampleTransformer = (userOptions) => {
css: [
{
content: `.${options.headingClass} { letter-spacing: 0.02em; }`,
inline: true,
},
inline: true
}
],
js: [
{
contentType: "inline",
loadTime: "afterDOMReady",
script: "document.documentElement.dataset.exampleTransformer = 'true'",
},
script: "document.documentElement.dataset.exampleTransformer = 'true'"
}
],
additionalHead: [],
additionalHead: []
};
},
}
};
};
@ -101,9 +92,9 @@ var ExampleTransformer = (userOptions) => {
var defaultOptions2 = {
allowDrafts: false,
excludeTags: ["private"],
excludePathPrefixes: ["_drafts/", "_private/"],
excludePathPrefixes: ["_drafts/", "_private/"]
};
var normalizeTag = (tag) => (typeof tag === "string" ? tag.trim().toLowerCase() : "");
var normalizeTag = (tag) => typeof tag === "string" ? tag.trim().toLowerCase() : "";
var includesTag = (tags, excludedTags) => {
if (!Array.isArray(tags)) {
return false;
@ -130,21 +121,17 @@ var ExampleFilter = (userOptions) => {
return false;
}
return true;
},
}
};
};
var defaultOptions3 = {
manifestSlug: "plugin-manifest",
includeFrontmatter: true,
metadata: {
generator: "Quartz Plugin Template",
},
generator: "Quartz Plugin Template"
}
};
var joinSegments = (...segments) =>
segments
.filter((segment) => segment.length > 0)
.join("/")
.replace(/\/+/g, "/");
var joinSegments = (...segments) => segments.filter((segment) => segment.length > 0).join("/").replace(/\/+/g, "/");
var writeFile = async (outputDir, slug, ext, content) => {
const outputPath = joinSegments(outputDir, `${slug}${ext}`);
await fs.mkdir(path.dirname(outputPath), { recursive: true });
@ -156,7 +143,7 @@ var ExampleEmitter = (userOptions) => {
const emitManifest = async (ctx, content) => {
const manifest = {
...options.metadata,
generatedAt: /* @__PURE__ */ new Date().toISOString(),
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
pages: content.map(([_tree, vfile]) => {
const frontmatter = vfile.data?.frontmatter ?? {};
return {
@ -164,16 +151,21 @@ var ExampleEmitter = (userOptions) => {
title: frontmatter.title ?? null,
tags: frontmatter.tags ?? null,
filePath: vfile.data?.filePath ?? null,
frontmatter: options.includeFrontmatter ? frontmatter : void 0,
frontmatter: options.includeFrontmatter ? frontmatter : void 0
};
}),
})
};
let json = `${JSON.stringify(manifest, null, 2)}
`;
if (options.transformManifest) {
json = options.transformManifest(json);
}
const output = await writeFile(ctx.argv.output, options.manifestSlug, ".json", json);
const output = await writeFile(
ctx.argv.output,
options.manifestSlug,
".json",
json
);
return [output];
};
return {
@ -186,7 +178,7 @@ var ExampleEmitter = (userOptions) => {
for (const outputPath of outputPaths) {
yield outputPath;
}
},
}
};
};
@ -196,13 +188,11 @@ function classNames(...classes) {
}
// src/components/styles/example.scss
var example_default =
".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}";
var example_default = ".example-component {\n padding: 8px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 4px;\n font-weight: 600;\n display: inline-block;\n}";
// src/components/scripts/example.inline.ts
var example_inline_default =
'function c(){let e=window.location.pathname;return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e||"index"}function r(){let e=document.querySelectorAll(".example-component");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()==="e"&&(n.preventDefault(),console.log("[ExampleComponent] Keyboard shortcut triggered!"))}document.addEventListener("keydown",o),t.push(()=>document.removeEventListener("keydown",o));for(let n of e){let i=()=>{console.log("[ExampleComponent] Clicked!")};n.addEventListener("click",i),t.push(()=>n.removeEventListener("click",i))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log("[ExampleComponent] Initialized with",e.length,"component(s)")}document.addEventListener("nav",e=>{let t=e.detail?.url||c();console.log("[ExampleComponent] Navigation to:",t),r()});document.addEventListener("render",()=>{console.log("[ExampleComponent] Render event - re-initializing"),r()});document.addEventListener("prenav",()=>{let e=document.querySelector(".example-component");e&&sessionStorage.setItem("exampleScrollTop",e.scrollTop?.toString()||"0")});\n';
var ExampleComponent_default = (opts) => {
var example_inline_default = 'function l(){let e=window.location.pathname;return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e||"index"}function r(){let e=document.querySelectorAll(".example-component");if(e.length===0)return;let t=[];function o(n){(n.ctrlKey||n.metaKey)&&n.shiftKey&&n.key.toLowerCase()==="e"&&(n.preventDefault(),console.log("[ExampleComponent] Keyboard shortcut triggered!"))}document.addEventListener("keydown",o),t.push(()=>document.removeEventListener("keydown",o));for(let n of e){let i=()=>{console.log("[ExampleComponent] Clicked!")};n.addEventListener("click",i),t.push(()=>n.removeEventListener("click",i))}typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{t.forEach(n=>n())}),console.log("[ExampleComponent] Initialized with",e.length,"component(s)")}document.addEventListener("nav",e=>{let t=e.detail?.url||l();console.log("[ExampleComponent] Navigation to:",t),r()});document.addEventListener("render",()=>{console.log("[ExampleComponent] Render event - re-initializing"),r()});document.addEventListener("prenav",()=>{let e=document.querySelector(".example-component");e&&sessionStorage.setItem("exampleScrollTop",e.scrollTop?.toString()||"0")});\n';
var ExampleComponent_default = ((opts) => {
const { prefix = "", suffix = "", className = "example-component" } = opts ?? {};
const Component = (props) => {
const frontmatter = props.fileData?.frontmatter;
@ -213,13 +203,8 @@ var ExampleComponent_default = (opts) => {
Component.css = example_default;
Component.afterDOMLoaded = example_inline_default;
return Component;
};
});
export {
ExampleComponent_default as ExampleComponent,
ExampleEmitter,
ExampleFilter,
ExampleTransformer,
};
//# sourceMappingURL=index.js.map
export { ExampleComponent_default as ExampleComponent, ExampleEmitter, ExampleFilter, ExampleTransformer };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

3
dist/types.js vendored
View file

@ -1,2 +1,3 @@
//# sourceMappingURL=types.js.map
//# sourceMappingURL=types.js.map
//# sourceMappingURL=types.js.map

1197
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -105,11 +105,18 @@
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"mdast-util-find-and-replace": "^3.0.2",
"preact": "^10.28.2",
"prettier": "^3.6.2",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.1",
"remark-parse": "^11.0.0",
"sass": "^1.97.3",
"tsup": "^8.5.0",
"typescript": "^5.9.3",
"unified": "^11.0.5",
"unist-util-visit": "^5.1.0",
"vfile": "^6.0.3",
"vitest": "^2.1.9"
},
"quartz": {

View file

@ -1,4 +0,0 @@
declare module "*.inline.ts" {
const content: string;
export default content;
}

View file

@ -39,10 +39,8 @@ function getCurrentSlug() {
// Helper: Fetch content index (commonly needed for search, graph, explorer)
async function _fetchContentIndex() {
try {
const response = await fetch("/static/contentIndex.json");
const data = await response.json();
// Handle both formats: { "slug": {...} } or { "content": { "slug": {...} } }
return data.content || data;
const data = await fetchData;
return data;
} catch (error) {
console.error("[Plugin] Error fetching content index:", error);
return null;

View file

@ -1,4 +0,0 @@
declare module "*.scss" {
const content: string;
export default content;
}

26
types/globals.d.ts vendored
View file

@ -1,21 +1,11 @@
interface CustomEventMap {
nav: CustomEvent<{ url: string }>;
prenav: CustomEvent<undefined>;
themechange: CustomEvent<{ theme: "light" | "dark" }>;
/// <reference path="../node_modules/@quartz-community/types/globals.d.ts" />
declare module "*.scss" {
const content: string;
export default content;
}
interface Document {
addEventListener<K extends keyof CustomEventMap>(
type: K,
listener: (this: Document, ev: CustomEventMap[K]) => void,
): void;
removeEventListener<K extends keyof CustomEventMap>(
type: K,
listener: (this: Document, ev: CustomEventMap[K]) => void,
): void;
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void;
}
interface Window {
addCleanup(fn: (...args: unknown[]) => void): void;
declare module "*.inline.ts" {
const content: string;
export default content;
}