diff --git a/.gitignore b/.gitignore index 657842b..ef88793 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ node_modules/ .pnp.js # Build output -dist/ build/ *.tsbuildinfo diff --git a/dist/components/index.d.ts b/dist/components/index.d.ts new file mode 100644 index 0000000..5a861c3 --- /dev/null +++ b/dist/components/index.d.ts @@ -0,0 +1,2 @@ +export { PageTitle } from '../index.js'; +import '@quartz-community/types'; diff --git a/dist/components/index.js b/dist/components/index.js new file mode 100644 index 0000000..dc57ab8 --- /dev/null +++ b/dist/components/index.js @@ -0,0 +1,48 @@ +import { jsx } from 'preact/jsx-runtime'; + +// src/util/lang.ts +function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} + +// src/util/path.ts +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 = { + propertyDefaults: { + title: "Untitled" + } +}; + +// src/i18n/index.ts +var locales = { + "en-US": en_US_default +}; +function i18n(locale) { + return locales[locale] || en_US_default; +} +var PageTitle = ({ fileData, cfg, displayClass }) => { + const locale = cfg?.locale ?? "en-US"; + const title = cfg?.pageTitle ?? i18n(locale).propertyDefaults.title; + const baseDir = pathToRoot(fileData.slug); + return /* @__PURE__ */ jsx("h2", { class: classNames(displayClass, "page-title"), children: /* @__PURE__ */ jsx("a", { href: baseDir, children: title }) }); +}; +PageTitle.css = ` +.page-title { + font-size: 1.75rem; + margin: 0; + font-family: var(--titleFont); +} +`; +var PageTitle_default = (() => PageTitle); + +export { PageTitle_default as PageTitle }; +//# sourceMappingURL=index.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/components/index.js.map b/dist/components/index.js.map new file mode 100644 index 0000000..f461cd7 --- /dev/null +++ b/dist/components/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/util/lang.ts","../../src/util/path.ts","../../src/i18n/locales/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AE,IAAA,EAAM,OAAA,EAAU,QAAA,EAAA,KAAA,EAAM,CAAA,EAC3B,CAAA;AAEJ,CAAA;AAEA,SAAA,CAAU,GAAA,GAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQhB,IAAO,qBAAS,MAAM,SAAA","file":"index.js","sourcesContent":["export function classNames(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n","/**\n * Gets the path to root from a given slug.\n * For example, \"a/b/c\" becomes \"../..\"\n */\nexport function pathToRoot(slug: string): string {\n let rootPath = slug\n .split(\"/\")\n .filter((x) => x !== \"\")\n .slice(0, -1)\n .map((_) => \"..\")\n .join(\"/\");\n\n if (rootPath.length === 0) {\n rootPath = \".\";\n }\n\n return rootPath;\n}\n","export default {\n propertyDefaults: {\n title: \"Untitled\",\n },\n};\n","import enUS from \"./locales/en-US\";\n\nconst locales: Record = {\n \"en-US\": enUS,\n};\n\nexport function i18n(locale: string) {\n return locales[locale] || enUS;\n}\n","import type {\n QuartzComponent,\n QuartzComponentProps,\n QuartzComponentConstructor,\n} from \"@quartz-community/types\";\nimport { classNames } from \"../util/lang\";\nimport { pathToRoot } from \"../util/path\";\nimport { i18n } from \"../i18n\";\n\nconst PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {\n const locale = cfg?.locale ?? \"en-US\";\n const title = cfg?.pageTitle ?? i18n(locale).propertyDefaults.title;\n const baseDir = pathToRoot(fileData.slug as string);\n return (\n

\n {title}\n

\n );\n};\n\nPageTitle.css = `\n.page-title {\n font-size: 1.75rem;\n margin: 0;\n font-family: var(--titleFont);\n}\n`;\n\nexport default (() => PageTitle) satisfies QuartzComponentConstructor;\n"]} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..7b2ccee --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,6 @@ +import { QuartzComponent } from '@quartz-community/types'; +export { QuartzComponent, QuartzComponentProps, StringResource } from '@quartz-community/types'; + +declare const _default: () => QuartzComponent; + +export { _default as PageTitle }; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..dc57ab8 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,48 @@ +import { jsx } from 'preact/jsx-runtime'; + +// src/util/lang.ts +function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} + +// src/util/path.ts +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 = { + propertyDefaults: { + title: "Untitled" + } +}; + +// src/i18n/index.ts +var locales = { + "en-US": en_US_default +}; +function i18n(locale) { + return locales[locale] || en_US_default; +} +var PageTitle = ({ fileData, cfg, displayClass }) => { + const locale = cfg?.locale ?? "en-US"; + const title = cfg?.pageTitle ?? i18n(locale).propertyDefaults.title; + const baseDir = pathToRoot(fileData.slug); + return /* @__PURE__ */ jsx("h2", { class: classNames(displayClass, "page-title"), children: /* @__PURE__ */ jsx("a", { href: baseDir, children: title }) }); +}; +PageTitle.css = ` +.page-title { + font-size: 1.75rem; + margin: 0; + font-family: var(--titleFont); +} +`; +var PageTitle_default = (() => PageTitle); + +export { PageTitle_default as PageTitle }; +//# sourceMappingURL=index.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..ace97d7 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/util/lang.ts","../src/util/path.ts","../src/i18n/locales/en-US.ts","../src/i18n/index.ts","../src/components/PageTitle.tsx"],"names":[],"mappings":";;;AAAO,SAAS,cAAc,OAAA,EAAwD;AACpF,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACzC;;;ACEO,SAAS,WAAW,IAAA,EAAsB;AAC/C,EAAA,IAAI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| false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n","/**\n * Gets the path to root from a given slug.\n * For example, \"a/b/c\" becomes \"../..\"\n */\nexport function pathToRoot(slug: string): string {\n let rootPath = slug\n .split(\"/\")\n .filter((x) => x !== \"\")\n .slice(0, -1)\n .map((_) => \"..\")\n .join(\"/\");\n\n if (rootPath.length === 0) {\n rootPath = \".\";\n }\n\n return rootPath;\n}\n","export default {\n propertyDefaults: {\n title: \"Untitled\",\n },\n};\n","import enUS from \"./locales/en-US\";\n\nconst locales: Record = {\n \"en-US\": enUS,\n};\n\nexport function i18n(locale: string) {\n return locales[locale] || enUS;\n}\n","import type {\n QuartzComponent,\n QuartzComponentProps,\n QuartzComponentConstructor,\n} from \"@quartz-community/types\";\nimport { classNames } from \"../util/lang\";\nimport { pathToRoot } from \"../util/path\";\nimport { i18n } from \"../i18n\";\n\nconst PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {\n const locale = cfg?.locale ?? \"en-US\";\n const title = cfg?.pageTitle ?? i18n(locale).propertyDefaults.title;\n const baseDir = pathToRoot(fileData.slug as string);\n return (\n

\n {title}\n

\n );\n};\n\nPageTitle.css = `\n.page-title {\n font-size: 1.75rem;\n margin: 0;\n font-family: var(--titleFont);\n}\n`;\n\nexport default (() => PageTitle) satisfies QuartzComponentConstructor;\n"]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e6edf2b..b3dd117 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,7 @@ "version": "0.1.0", "license": "MIT", "dependencies": { - "@quartz-community/types": "github:quartz-community/types", - "tsup": "^8.5.0", - "typescript": "^5.9.3" + "@quartz-community/types": "github:quartz-community/types" }, "devDependencies": { "@types/hast": "^3.0.4", @@ -23,6 +21,8 @@ "eslint-config-prettier": "^9.1.0", "preact": "^10.28.2", "prettier": "^3.6.2", + "tsup": "^8.5.0", + "typescript": "^5.9.3", "vitest": "^2.1.9" }, "engines": { @@ -2862,7 +2862,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", diff --git a/package.json b/package.json index cc53e5d..0109492 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "sideEffects": false, "scripts": { "build": "tsup", - "prepare": "npm run build", "dev": "tsup --watch", "lint": "eslint . --max-warnings=0", "format": "prettier . --check",