chore: commit dist/ and remove prepare script

Pre-built output is now committed to the repository so that
Quartz can skip the build step during plugin installation.
The prepare script is removed to prevent redundant builds
when installing from npm/git.
This commit is contained in:
saberzero1 2026-03-14 22:00:25 +01:00
parent 0eaf5ae7f9
commit 8ac59ae70d
No known key found for this signature in database
9 changed files with 637 additions and 103 deletions

1
.gitignore vendored
View file

@ -4,7 +4,6 @@ node_modules/
.pnp.js
# Build output
dist/
build/
*.tsbuildinfo

199
dist/components/index.js vendored Normal file
View file

@ -0,0 +1,199 @@
import { joinSegments, simplifySlug as simplifySlug$1 } from '@quartz-community/utils';
import { jsxs, jsx, Fragment } from 'preact/jsx-runtime';
// src/util/lang.ts
function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}
function simplifySlug(fp) {
return simplifySlug$1(fp);
}
function resolveRelative(current, target) {
const simplified = simplifySlug(target);
const rootPath = pathToRoot(current);
return joinSegments(rootPath, simplified);
}
function pathToRoot(slug) {
let rootPath = slug.split("/").filter((x) => x !== "").slice(0, -1).map((_) => "..").join("/");
if (rootPath.length === 0) {
rootPath = ".";
}
return rootPath;
}
// src/i18n/locales/en-US.ts
var en_US_default = {
components: {
noteProperties: {
title: "Properties"
}
}
};
// src/i18n/index.ts
var locales = {
"en-US": en_US_default
};
function i18n(locale) {
return locales[locale] || en_US_default;
}
// src/components/styles/noteProperties.scss
var noteProperties_default = '.note-properties {\n margin: 0.5rem 0 1rem;\n border: 1px solid var(--lightgray);\n border-radius: 5px;\n font-size: 0.9rem;\n}\n.note-properties[open] > .note-properties-header {\n border-bottom: 1px solid var(--lightgray);\n}\n.note-properties .note-properties-header {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.4rem 0.8rem;\n cursor: pointer;\n user-select: none;\n list-style: none;\n color: var(--darkgray);\n font-weight: 600;\n}\n.note-properties .note-properties-header::-webkit-details-marker {\n display: none;\n}\n.note-properties .note-properties-header::before {\n content: "";\n display: inline-block;\n width: 0.5em;\n height: 0.5em;\n border-right: 2px solid var(--darkgray);\n border-bottom: 2px solid var(--darkgray);\n transform: rotate(-45deg);\n transition: transform 0.2s ease;\n}\n.note-properties[open] > .note-properties-header::before {\n transform: rotate(45deg);\n}\n.note-properties .note-properties-count {\n margin-left: auto;\n font-size: 0.75rem;\n color: var(--gray);\n font-weight: 400;\n}\n.note-properties .note-properties-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.note-properties .note-properties-row {\n border-bottom: 1px solid var(--lightgray);\n}\n.note-properties .note-properties-row:last-child {\n border-bottom: none;\n}\n.note-properties .note-properties-key {\n width: 35%;\n padding: 0.35rem 0.8rem;\n color: var(--gray);\n font-size: 0.85rem;\n vertical-align: top;\n word-break: break-word;\n}\n.note-properties .note-properties-value {\n padding: 0.35rem 0.8rem;\n vertical-align: top;\n word-break: break-word;\n}\n.note-properties .note-properties-empty {\n color: var(--gray);\n font-style: italic;\n}\n.note-properties .note-properties-boolean input[type=checkbox] {\n pointer-events: none;\n margin: 0;\n vertical-align: middle;\n}\n.note-properties .note-properties-number {\n font-family: var(--codeFont);\n font-size: 0.85em;\n}\n.note-properties .note-properties-link {\n text-decoration: none;\n color: var(--secondary);\n}\n.note-properties .note-properties-link:hover {\n text-decoration: underline;\n}\n.note-properties .note-properties-separator {\n color: var(--gray);\n}\n.note-properties .note-properties-list {\n display: inline;\n}\n.note-properties .note-properties-tags {\n display: inline;\n}\n.note-properties .note-properties-tags .tag-link {\n display: inline-block;\n padding: 0.1rem 0.4rem;\n border-radius: 3px;\n background: var(--highlight);\n color: var(--secondary);\n font-size: 0.85em;\n text-decoration: none;\n}\n.note-properties .note-properties-tags .tag-link:hover {\n background: var(--secondary);\n color: var(--light);\n}\n.note-properties .note-properties-object code {\n font-size: 0.85em;\n padding: 0.1rem 0.3rem;\n border-radius: 3px;\n background: var(--highlight);\n word-break: break-all;\n}';
// src/components/scripts/noteProperties.inline.ts
var noteProperties_inline_default = 'var o="note-properties-collapsed";function d(){let e=document.querySelector("details.note-properties");if(!e)return;let t=localStorage.getItem(o);if(t!==null){let i=t==="true";e.open=!i}let n=()=>{localStorage.setItem(o,String(!e.open))};e.addEventListener("toggle",n),typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{e.removeEventListener("toggle",n)})}document.addEventListener("nav",()=>{d()});document.addEventListener("render",()=>{d()});\n';
var WIKILINK_RE = /\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g;
var MDLINK_RE = /\[([^\]]*)\]\(([^)]+)\)/g;
var URL_RE = /https?:\/\/[^\s<>]+/g;
function renderTextWithLinks(text, ctx) {
const segments = [];
for (const match of text.matchAll(WIKILINK_RE)) {
const target = match[1];
const display = match[2] ?? target;
const href = resolveRelative(ctx.slug, target);
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx("a", { href, class: "internal note-properties-link", children: display })
});
}
for (const match of text.matchAll(MDLINK_RE)) {
const overlaps = segments.some(
(s) => match.index < s.end && match.index + match[0].length > s.start
);
if (overlaps) continue;
const display = match[1];
const href = match[2];
const isExternal = href.startsWith("http://") || href.startsWith("https://");
const resolvedHref = isExternal ? href : resolveRelative(ctx.slug, href);
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx(
"a",
{
href: resolvedHref,
class: classNames(isExternal ? "external" : "internal", "note-properties-link"),
...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
children: display || href
}
)
});
}
for (const match of text.matchAll(URL_RE)) {
const overlaps = segments.some(
(s) => match.index < s.end && match.index + match[0].length > s.start
);
if (overlaps) continue;
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx(
"a",
{
href: match[0],
class: "external note-properties-link",
target: "_blank",
rel: "noopener noreferrer",
children: match[0]
}
)
});
}
if (segments.length === 0) return [text];
segments.sort((a, b) => a.start - b.start);
const result = [];
let cursor = 0;
for (const seg of segments) {
if (seg.start > cursor) {
result.push(text.slice(cursor, seg.start));
}
result.push(seg.node);
cursor = seg.end;
}
if (cursor < text.length) {
result.push(text.slice(cursor));
}
return result;
}
function renderValue(value, ctx) {
if (value === null || value === void 0) {
return /* @__PURE__ */ jsx("span", { class: "note-properties-empty", children: "\u2014" });
}
if (typeof value === "boolean") {
return /* @__PURE__ */ jsx("span", { class: classNames("note-properties-boolean", value ? "is-true" : "is-false"), children: /* @__PURE__ */ jsx("input", { type: "checkbox", checked: value, disabled: true }) });
}
if (typeof value === "number") {
return /* @__PURE__ */ jsx("span", { class: "note-properties-number", children: value });
}
if (typeof value === "string") {
const parts = renderTextWithLinks(value, ctx);
return /* @__PURE__ */ jsx("span", { class: "note-properties-text", children: parts });
}
if (Array.isArray(value)) {
const items = value.map((item, idx) => {
const rendered = renderValue(item, ctx);
return /* @__PURE__ */ jsxs(Fragment, { children: [
idx > 0 && /* @__PURE__ */ jsx("span", { class: "note-properties-separator", children: ", " }),
rendered
] });
});
return /* @__PURE__ */ jsx("span", { class: "note-properties-list", children: items });
}
if (typeof value === "object") {
return /* @__PURE__ */ jsx("span", { class: "note-properties-object", children: /* @__PURE__ */ jsx("code", { children: JSON.stringify(value) }) });
}
return String(value);
}
function renderTagList(tags, ctx) {
const items = tags.map((tag, idx) => {
const href = resolveRelative(ctx.slug, `tags/${tag}`);
return /* @__PURE__ */ jsxs(Fragment, { children: [
idx > 0 && /* @__PURE__ */ jsx("span", { class: "note-properties-separator", children: ", " }),
/* @__PURE__ */ jsx("a", { href, class: "internal tag-link", children: tag })
] });
});
return /* @__PURE__ */ jsx("span", { class: "note-properties-tags", children: items });
}
var NoteProperties_default = ((opts) => {
const { collapsed = false } = opts ?? {};
const Component = (props) => {
const noteProps = props.fileData?.noteProperties;
if (!noteProps) return null;
if (noteProps.showProperties === false) return null;
if (noteProps.showProperties !== true && noteProps.hideView) return null;
const properties = noteProps.properties;
const entries = Object.entries(properties);
if (entries.length === 0) return null;
const locale = props.cfg?.locale || "en-US";
const i18nData = i18n(locale);
const ctx = { slug: props.fileData?.slug ?? "" };
const isCollapsed = noteProps.collapseProperties ?? collapsed;
return /* @__PURE__ */ jsxs(
"details",
{
class: classNames(props.displayClass, "note-properties"),
open: !isCollapsed,
"data-collapsed": isCollapsed,
children: [
/* @__PURE__ */ jsxs("summary", { class: "note-properties-header", children: [
/* @__PURE__ */ jsx("span", { class: "note-properties-title", children: i18nData.components.noteProperties.title }),
/* @__PURE__ */ jsx("span", { class: "note-properties-count", children: entries.length })
] }),
/* @__PURE__ */ jsx("table", { class: "note-properties-table", children: /* @__PURE__ */ jsx("tbody", { children: entries.map(([key, value]) => /* @__PURE__ */ jsxs("tr", { class: "note-properties-row", children: [
/* @__PURE__ */ jsx("td", { class: "note-properties-key", children: key }),
/* @__PURE__ */ jsx("td", { class: "note-properties-value", children: key === "tags" && Array.isArray(value) ? renderTagList(value, ctx) : renderValue(value, ctx) })
] }, key)) }) })
]
}
);
};
Component.css = noteProperties_default;
Component.afterDOMLoaded = noteProperties_inline_default;
return Component;
});
export { NoteProperties_default as NotePropertiesComponent };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

1
dist/components/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

391
dist/index.js vendored Normal file
View file

@ -0,0 +1,391 @@
import matter from 'gray-matter';
import remarkFrontmatter from 'remark-frontmatter';
import yaml from 'js-yaml';
import toml from 'toml';
import { joinSegments, simplifySlug as simplifySlug$1 } from '@quartz-community/utils';
import { jsxs, jsx, Fragment } from 'preact/jsx-runtime';
// src/transformer.ts
var defaultOptions = {
includeAll: false,
includedProperties: ["description", "tags", "aliases"],
excludedProperties: [],
hidePropertiesView: false,
delimiters: "---",
language: "yaml"
};
function coalesceAliases(data, aliases) {
for (const alias of aliases) {
if (data[alias] !== void 0 && data[alias] !== null) return data[alias];
}
}
function coerceToArray(input) {
if (input === void 0 || input === null) return void 0;
if (!Array.isArray(input)) {
return String(input).split(",").map((s) => s.trim());
}
return input.filter((v) => typeof v === "string" || typeof v === "number").map((v) => v.toString());
}
function slugTag(tag) {
return tag.split("/").map(
(segment) => segment.replace(/\s+/g, "-").replace(/[^\w\p{L}\p{M}\p{N}/-]/gu, "").toLowerCase()
).join("/");
}
function getFileExtension(fp) {
return fp.split(".").pop() ?? "";
}
function slugifyFilePath(fp) {
fp = fp.replace(/\\/g, "/");
fp = fp.replace(/\.md$/, "");
let slug = fp.split("/").map((segment) => segment.replace(/\s+/g, "-").replace(/[^\w\p{L}\p{M}\p{N}/-]/gu, "")).join("/");
slug = slug.replace(/\/$/, "");
return slug;
}
function getAliasSlugs(aliases) {
return aliases.map((alias) => {
const isMd = getFileExtension(alias) === "md";
const mockFp = isMd ? alias : alias + ".md";
return slugifyFilePath(mockFp);
});
}
var WIKILINK_PATTERN = /\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g;
var MDLINK_PATTERN = /\[(?:[^\]]*)\]\(([^)]+)\)/g;
function extractLinksFromValue(value) {
if (typeof value === "string") {
const links = [];
let match;
WIKILINK_PATTERN.lastIndex = 0;
while ((match = WIKILINK_PATTERN.exec(value)) !== null) {
links.push(match[1]);
}
MDLINK_PATTERN.lastIndex = 0;
while ((match = MDLINK_PATTERN.exec(value)) !== null) {
links.push(match[1]);
}
return links;
}
if (Array.isArray(value)) {
return value.flatMap((item) => extractLinksFromValue(item));
}
if (value !== null && typeof value === "object") {
return Object.values(value).flatMap((v) => extractLinksFromValue(v));
}
return [];
}
var QUARTZ_INTERNAL_KEYS = /* @__PURE__ */ new Set([
"quartz-properties",
"quartzProperties",
"quartz-properties-collapse",
"quartzPropertiesCollapse"
]);
function coerceToBool(value) {
if (value === void 0 || value === null) return void 0;
if (typeof value === "boolean") return value;
if (typeof value === "string") {
const lower = value.toLowerCase();
if (lower === "true") return true;
if (lower === "false") return false;
}
return void 0;
}
function getVisibleProperties(data, opts) {
const excluded = new Set(opts.excludedProperties);
for (const key of QUARTZ_INTERNAL_KEYS) {
excluded.add(key);
}
if (opts.includeAll) {
const result2 = {};
for (const [key, value] of Object.entries(data)) {
if (!excluded.has(key)) {
result2[key] = value;
}
}
return result2;
}
const result = {};
for (const key of opts.includedProperties) {
if (!excluded.has(key) && data[key] !== void 0) {
result[key] = data[key];
}
}
return result;
}
var NoteProperties = (userOpts) => {
const opts = { ...defaultOptions, ...userOpts };
return {
name: "NoteProperties",
markdownPlugins(_ctx) {
const { allSlugs } = _ctx;
return [
[remarkFrontmatter, ["yaml", "toml"]],
() => {
return (_, file) => {
const fileData = Buffer.from(file.value);
const { data } = matter(fileData, {
delimiters: opts.delimiters,
language: opts.language,
engines: {
yaml: (s) => yaml.load(s, { schema: yaml.JSON_SCHEMA }),
toml: (s) => toml.parse(s)
}
});
if (data.title != null && data.title.toString() !== "") {
data.title = data.title.toString();
} else {
data.title = file.stem ?? "Untitled";
}
const tags = coerceToArray(coalesceAliases(data, ["tags", "tag"]));
if (tags) data.tags = [...new Set(tags.map((tag) => slugTag(tag)))];
const aliases = coerceToArray(coalesceAliases(data, ["aliases", "alias"]));
if (aliases) {
data.aliases = aliases;
file.data.aliases = getAliasSlugs(aliases);
allSlugs.push(...file.data.aliases);
}
if (data.permalink != null && data.permalink.toString() !== "") {
data.permalink = data.permalink.toString();
const fileAliases = file.data.aliases ?? [];
fileAliases.push(data.permalink);
file.data.aliases = fileAliases;
allSlugs.push(data.permalink);
}
const cssclasses = coerceToArray(coalesceAliases(data, ["cssclasses", "cssclass"]));
if (cssclasses) data.cssclasses = cssclasses;
const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"]);
const created = coalesceAliases(data, ["created", "date"]);
if (created) data.created = created;
const modified = coalesceAliases(data, [
"modified",
"lastmod",
"updated",
"last-modified"
]);
if (modified) data.modified = modified;
data.modified ||= created;
const published = coalesceAliases(data, ["published", "publishDate", "date"]);
if (published) data.published = published;
if (socialImage) data.socialImage = socialImage;
const uniqueSlugs = [...new Set(allSlugs)];
allSlugs.splice(0, allSlugs.length, ...uniqueSlugs);
const frontmatterLinks = extractLinksFromValue(data);
if (frontmatterLinks.length > 0) {
const existingLinks = file.data.frontmatterLinks ?? [];
file.data.frontmatterLinks = [...existingLinks, ...frontmatterLinks];
}
const showProperties = coerceToBool(
coalesceAliases(data, ["quartz-properties", "quartzProperties"])
);
const collapseProperties = coerceToBool(
coalesceAliases(data, ["quartz-properties-collapse", "quartzPropertiesCollapse"])
);
const visibleProps = getVisibleProperties(data, opts);
file.data.noteProperties = {
properties: visibleProps,
hideView: opts.hidePropertiesView,
showProperties,
collapseProperties
};
file.data.frontmatter = data;
};
}
];
}
};
};
// src/util/lang.ts
function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}
function simplifySlug(fp) {
return simplifySlug$1(fp);
}
function resolveRelative(current, target) {
const simplified = simplifySlug(target);
const rootPath = pathToRoot(current);
return joinSegments(rootPath, simplified);
}
function pathToRoot(slug) {
let rootPath = slug.split("/").filter((x) => x !== "").slice(0, -1).map((_) => "..").join("/");
if (rootPath.length === 0) {
rootPath = ".";
}
return rootPath;
}
// src/i18n/locales/en-US.ts
var en_US_default = {
components: {
noteProperties: {
title: "Properties"
}
}
};
// src/i18n/index.ts
var locales = {
"en-US": en_US_default
};
function i18n(locale) {
return locales[locale] || en_US_default;
}
// src/components/styles/noteProperties.scss
var noteProperties_default = '.note-properties {\n margin: 0.5rem 0 1rem;\n border: 1px solid var(--lightgray);\n border-radius: 5px;\n font-size: 0.9rem;\n}\n.note-properties[open] > .note-properties-header {\n border-bottom: 1px solid var(--lightgray);\n}\n.note-properties .note-properties-header {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.4rem 0.8rem;\n cursor: pointer;\n user-select: none;\n list-style: none;\n color: var(--darkgray);\n font-weight: 600;\n}\n.note-properties .note-properties-header::-webkit-details-marker {\n display: none;\n}\n.note-properties .note-properties-header::before {\n content: "";\n display: inline-block;\n width: 0.5em;\n height: 0.5em;\n border-right: 2px solid var(--darkgray);\n border-bottom: 2px solid var(--darkgray);\n transform: rotate(-45deg);\n transition: transform 0.2s ease;\n}\n.note-properties[open] > .note-properties-header::before {\n transform: rotate(45deg);\n}\n.note-properties .note-properties-count {\n margin-left: auto;\n font-size: 0.75rem;\n color: var(--gray);\n font-weight: 400;\n}\n.note-properties .note-properties-table {\n width: 100%;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.note-properties .note-properties-row {\n border-bottom: 1px solid var(--lightgray);\n}\n.note-properties .note-properties-row:last-child {\n border-bottom: none;\n}\n.note-properties .note-properties-key {\n width: 35%;\n padding: 0.35rem 0.8rem;\n color: var(--gray);\n font-size: 0.85rem;\n vertical-align: top;\n word-break: break-word;\n}\n.note-properties .note-properties-value {\n padding: 0.35rem 0.8rem;\n vertical-align: top;\n word-break: break-word;\n}\n.note-properties .note-properties-empty {\n color: var(--gray);\n font-style: italic;\n}\n.note-properties .note-properties-boolean input[type=checkbox] {\n pointer-events: none;\n margin: 0;\n vertical-align: middle;\n}\n.note-properties .note-properties-number {\n font-family: var(--codeFont);\n font-size: 0.85em;\n}\n.note-properties .note-properties-link {\n text-decoration: none;\n color: var(--secondary);\n}\n.note-properties .note-properties-link:hover {\n text-decoration: underline;\n}\n.note-properties .note-properties-separator {\n color: var(--gray);\n}\n.note-properties .note-properties-list {\n display: inline;\n}\n.note-properties .note-properties-tags {\n display: inline;\n}\n.note-properties .note-properties-tags .tag-link {\n display: inline-block;\n padding: 0.1rem 0.4rem;\n border-radius: 3px;\n background: var(--highlight);\n color: var(--secondary);\n font-size: 0.85em;\n text-decoration: none;\n}\n.note-properties .note-properties-tags .tag-link:hover {\n background: var(--secondary);\n color: var(--light);\n}\n.note-properties .note-properties-object code {\n font-size: 0.85em;\n padding: 0.1rem 0.3rem;\n border-radius: 3px;\n background: var(--highlight);\n word-break: break-all;\n}';
// src/components/scripts/noteProperties.inline.ts
var noteProperties_inline_default = 'var o="note-properties-collapsed";function d(){let e=document.querySelector("details.note-properties");if(!e)return;let t=localStorage.getItem(o);if(t!==null){let i=t==="true";e.open=!i}let n=()=>{localStorage.setItem(o,String(!e.open))};e.addEventListener("toggle",n),typeof window<"u"&&window.addCleanup&&window.addCleanup(()=>{e.removeEventListener("toggle",n)})}document.addEventListener("nav",()=>{d()});document.addEventListener("render",()=>{d()});\n';
var WIKILINK_RE = /\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g;
var MDLINK_RE = /\[([^\]]*)\]\(([^)]+)\)/g;
var URL_RE = /https?:\/\/[^\s<>]+/g;
function renderTextWithLinks(text, ctx) {
const segments = [];
for (const match of text.matchAll(WIKILINK_RE)) {
const target = match[1];
const display = match[2] ?? target;
const href = resolveRelative(ctx.slug, target);
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx("a", { href, class: "internal note-properties-link", children: display })
});
}
for (const match of text.matchAll(MDLINK_RE)) {
const overlaps = segments.some(
(s) => match.index < s.end && match.index + match[0].length > s.start
);
if (overlaps) continue;
const display = match[1];
const href = match[2];
const isExternal = href.startsWith("http://") || href.startsWith("https://");
const resolvedHref = isExternal ? href : resolveRelative(ctx.slug, href);
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx(
"a",
{
href: resolvedHref,
class: classNames(isExternal ? "external" : "internal", "note-properties-link"),
...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
children: display || href
}
)
});
}
for (const match of text.matchAll(URL_RE)) {
const overlaps = segments.some(
(s) => match.index < s.end && match.index + match[0].length > s.start
);
if (overlaps) continue;
segments.push({
start: match.index,
end: match.index + match[0].length,
node: /* @__PURE__ */ jsx(
"a",
{
href: match[0],
class: "external note-properties-link",
target: "_blank",
rel: "noopener noreferrer",
children: match[0]
}
)
});
}
if (segments.length === 0) return [text];
segments.sort((a, b) => a.start - b.start);
const result = [];
let cursor = 0;
for (const seg of segments) {
if (seg.start > cursor) {
result.push(text.slice(cursor, seg.start));
}
result.push(seg.node);
cursor = seg.end;
}
if (cursor < text.length) {
result.push(text.slice(cursor));
}
return result;
}
function renderValue(value, ctx) {
if (value === null || value === void 0) {
return /* @__PURE__ */ jsx("span", { class: "note-properties-empty", children: "\u2014" });
}
if (typeof value === "boolean") {
return /* @__PURE__ */ jsx("span", { class: classNames("note-properties-boolean", value ? "is-true" : "is-false"), children: /* @__PURE__ */ jsx("input", { type: "checkbox", checked: value, disabled: true }) });
}
if (typeof value === "number") {
return /* @__PURE__ */ jsx("span", { class: "note-properties-number", children: value });
}
if (typeof value === "string") {
const parts = renderTextWithLinks(value, ctx);
return /* @__PURE__ */ jsx("span", { class: "note-properties-text", children: parts });
}
if (Array.isArray(value)) {
const items = value.map((item, idx) => {
const rendered = renderValue(item, ctx);
return /* @__PURE__ */ jsxs(Fragment, { children: [
idx > 0 && /* @__PURE__ */ jsx("span", { class: "note-properties-separator", children: ", " }),
rendered
] });
});
return /* @__PURE__ */ jsx("span", { class: "note-properties-list", children: items });
}
if (typeof value === "object") {
return /* @__PURE__ */ jsx("span", { class: "note-properties-object", children: /* @__PURE__ */ jsx("code", { children: JSON.stringify(value) }) });
}
return String(value);
}
function renderTagList(tags, ctx) {
const items = tags.map((tag, idx) => {
const href = resolveRelative(ctx.slug, `tags/${tag}`);
return /* @__PURE__ */ jsxs(Fragment, { children: [
idx > 0 && /* @__PURE__ */ jsx("span", { class: "note-properties-separator", children: ", " }),
/* @__PURE__ */ jsx("a", { href, class: "internal tag-link", children: tag })
] });
});
return /* @__PURE__ */ jsx("span", { class: "note-properties-tags", children: items });
}
var NoteProperties_default = ((opts) => {
const { collapsed = false } = opts ?? {};
const Component = (props) => {
const noteProps = props.fileData?.noteProperties;
if (!noteProps) return null;
if (noteProps.showProperties === false) return null;
if (noteProps.showProperties !== true && noteProps.hideView) return null;
const properties = noteProps.properties;
const entries = Object.entries(properties);
if (entries.length === 0) return null;
const locale = props.cfg?.locale || "en-US";
const i18nData = i18n(locale);
const ctx = { slug: props.fileData?.slug ?? "" };
const isCollapsed = noteProps.collapseProperties ?? collapsed;
return /* @__PURE__ */ jsxs(
"details",
{
class: classNames(props.displayClass, "note-properties"),
open: !isCollapsed,
"data-collapsed": isCollapsed,
children: [
/* @__PURE__ */ jsxs("summary", { class: "note-properties-header", children: [
/* @__PURE__ */ jsx("span", { class: "note-properties-title", children: i18nData.components.noteProperties.title }),
/* @__PURE__ */ jsx("span", { class: "note-properties-count", children: entries.length })
] }),
/* @__PURE__ */ jsx("table", { class: "note-properties-table", children: /* @__PURE__ */ jsx("tbody", { children: entries.map(([key, value]) => /* @__PURE__ */ jsxs("tr", { class: "note-properties-row", children: [
/* @__PURE__ */ jsx("td", { class: "note-properties-key", children: key }),
/* @__PURE__ */ jsx("td", { class: "note-properties-value", children: key === "tags" && Array.isArray(value) ? renderTagList(value, ctx) : renderValue(value, ctx) })
] }, key)) }) })
]
}
);
};
Component.css = noteProperties_default;
Component.afterDOMLoaded = noteProperties_inline_default;
return Component;
});
export { NoteProperties, NoteProperties_default as NotePropertiesComponent };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

1
dist/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

3
dist/types.js vendored Normal file
View file

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

1
dist/types.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}

142
package-lock.json generated
View file

@ -10,15 +10,7 @@
"license": "MIT",
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"@quartz-community/utils": "github:quartz-community/utils",
"gray-matter": "^4.0.3",
"js-yaml": "^4.1.0",
"remark-frontmatter": "^5.0.0",
"toml": "^3.0.0",
"tsup": "^8.5.0",
"typescript": "^5.9.3",
"unified": "^11.0.5",
"vfile": "^6.0.3"
"@quartz-community/utils": "github:quartz-community/utils"
},
"devDependencies": {
"@types/hast": "^3.0.4",
@ -32,6 +24,8 @@
"preact": "^10.28.2",
"prettier": "^3.6.2",
"sass": "^1.97.3",
"tsup": "^8.5.0",
"typescript": "^5.9.3",
"vitest": "^2.1.9"
},
"engines": {
@ -40,14 +34,38 @@
},
"peerDependencies": {
"@jackyzha0/quartz": "^4.5.2",
"preact": "^10.0.0"
"gray-matter": "^4.0.3",
"js-yaml": "^4.1.0",
"preact": "^10.0.0",
"remark-frontmatter": "^5.0.0",
"toml": "^3.0.0",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
"peerDependenciesMeta": {
"@jackyzha0/quartz": {
"optional": true
},
"gray-matter": {
"optional": true
},
"js-yaml": {
"optional": true
},
"preact": {
"optional": false
},
"remark-frontmatter": {
"optional": true
},
"toml": {
"optional": true
},
"unified": {
"optional": true
},
"vfile": {
"optional": true
}
}
},
@ -1850,6 +1868,7 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"devOptional": true,
"license": "Python-2.0"
},
"node_modules/array-union": {
@ -2447,6 +2466,7 @@
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"license": "BSD-2-Clause",
"optional": true,
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
@ -2542,6 +2562,7 @@
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
"license": "MIT",
"optional": true,
"dependencies": {
"is-extendable": "^0.1.0"
},
@ -2610,19 +2631,6 @@
"reusify": "^1.0.4"
}
},
"node_modules/fault": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz",
"integrity": "sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==",
"license": "MIT",
"dependencies": {
"format": "^0.2.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/file-entry-cache": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@ -2699,14 +2707,6 @@
"dev": true,
"license": "ISC"
},
"node_modules/format": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
"integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==",
"engines": {
"node": ">=0.4.x"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -2842,6 +2842,7 @@
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz",
"integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==",
"license": "MIT",
"optional": true,
"dependencies": {
"js-yaml": "^3.13.1",
"kind-of": "^6.0.2",
@ -2857,6 +2858,7 @@
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"license": "MIT",
"optional": true,
"dependencies": {
"sprintf-js": "~1.0.2"
}
@ -2866,6 +2868,7 @@
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz",
"integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==",
"license": "MIT",
"optional": true,
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
@ -3032,6 +3035,7 @@
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
@ -3121,6 +3125,7 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@ -3165,6 +3170,7 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
@ -3283,36 +3289,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-frontmatter": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-frontmatter/-/mdast-util-frontmatter-2.0.1.tgz",
"integrity": "sha512-LRqI9+wdgC25P0URIJY9vwocIzCcksduHQ9OF2joxQoyTNVduwLAFUzjoopuRJbJAReaKrNQKAZKL3uCMugWJA==",
"license": "MIT",
"dependencies": {
"@types/mdast": "^4.0.0",
"devlop": "^1.0.0",
"escape-string-regexp": "^5.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.0.0",
"micromark-extension-frontmatter": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-frontmatter/node_modules/escape-string-regexp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/mdast-util-mdx-expression": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz",
@ -3500,22 +3476,6 @@
"micromark-util-types": "^2.0.0"
}
},
"node_modules/micromark-extension-frontmatter": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/micromark-extension-frontmatter/-/micromark-extension-frontmatter-2.0.0.tgz",
"integrity": "sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==",
"license": "MIT",
"dependencies": {
"fault": "^2.0.0",
"micromark-util-character": "^2.0.0",
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/micromark-factory-destination": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
@ -4204,7 +4164,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@ -4347,22 +4306,6 @@
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/remark-frontmatter": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-5.0.0.tgz",
"integrity": "sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==",
"license": "MIT",
"dependencies": {
"@types/mdast": "^4.0.0",
"mdast-util-frontmatter": "^2.0.0",
"micromark-extension-frontmatter": "^2.0.0",
"unified": "^11.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@ -4496,6 +4439,7 @@
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
"license": "MIT",
"optional": true,
"dependencies": {
"extend-shallow": "^2.0.1",
"kind-of": "^6.0.0"
@ -4590,7 +4534,8 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"license": "BSD-3-Clause"
"license": "BSD-3-Clause",
"optional": true
},
"node_modules/stackback": {
"version": "0.0.2",
@ -4638,6 +4583,7 @@
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
@ -4838,12 +4784,6 @@
"node": ">=8.0"
}
},
"node_modules/toml": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
"license": "MIT"
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",

View file

@ -44,7 +44,6 @@
"sideEffects": false,
"scripts": {
"build": "tsup",
"prepare": "npm run build",
"dev": "tsup --watch",
"lint": "eslint . --max-warnings=0",
"format": "prettier . --check",