mirror of
https://github.com/quartz-community/content-meta.git
synced 2026-07-22 02:50:23 +00:00
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:
parent
2fa96b3707
commit
b6a89c9954
7 changed files with 186 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,7 +4,6 @@ node_modules/
|
|||
.pnp.js
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
build/
|
||||
*.tsbuildinfo
|
||||
|
||||
|
|
|
|||
88
dist/components/index.js
vendored
Normal file
88
dist/components/index.js
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import readingTime from 'reading-time';
|
||||
import { jsx } from 'preact/jsx-runtime';
|
||||
|
||||
// src/components/ContentMeta.tsx
|
||||
|
||||
// src/util/lang.ts
|
||||
function classNames(...classes) {
|
||||
return classes.filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
// src/i18n/locales/en-US.ts
|
||||
var en_US_default = {
|
||||
components: {
|
||||
contentMeta: {
|
||||
readingTime: ({ minutes }) => {
|
||||
if (minutes === 1) {
|
||||
return "1 min read";
|
||||
}
|
||||
return `${minutes} min read`;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// src/i18n/index.ts
|
||||
var locales = {
|
||||
"en-US": en_US_default
|
||||
};
|
||||
function i18n(locale) {
|
||||
return locales[locale] || en_US_default;
|
||||
}
|
||||
function getDate(cfg, data) {
|
||||
if (!cfg.defaultDateType) {
|
||||
throw new Error(
|
||||
`Field 'defaultDateType' was not set in the configuration object of quartz.config.ts. See https://quartz.jzhao.xyz/configuration#general-configuration for more details.`
|
||||
);
|
||||
}
|
||||
const dates = data.dates;
|
||||
return dates?.[cfg.defaultDateType];
|
||||
}
|
||||
function formatDate(d, locale = "en-US") {
|
||||
return d.toLocaleDateString(locale, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "2-digit"
|
||||
});
|
||||
}
|
||||
function DateComponent({ date, locale }) {
|
||||
return /* @__PURE__ */ jsx("time", { datetime: date.toISOString(), children: formatDate(date, locale) });
|
||||
}
|
||||
|
||||
// src/components/styles/contentMeta.scss
|
||||
var contentMeta_default = '.content-meta {\n margin-top: 0;\n color: var(--darkgray);\n}\n.content-meta[show-comma=true] > *:not(:last-child) {\n margin-right: 8px;\n}\n.content-meta[show-comma=true] > *:not(:last-child)::after {\n content: ",";\n}';
|
||||
var defaultOptions = {
|
||||
showReadingTime: true,
|
||||
showComma: true
|
||||
};
|
||||
var ContentMeta_default = ((opts) => {
|
||||
const options = { ...defaultOptions, ...opts };
|
||||
function ContentMetadata({ cfg, fileData, displayClass }) {
|
||||
const text = fileData.text;
|
||||
if (text) {
|
||||
const segments = [];
|
||||
if (fileData.dates) {
|
||||
const locale = cfg.locale || "en-US";
|
||||
segments.push(/* @__PURE__ */ jsx(DateComponent, { date: getDate(cfg, fileData), locale }));
|
||||
}
|
||||
if (options.showReadingTime) {
|
||||
const { minutes, words: _words } = readingTime(text);
|
||||
const locale = cfg.locale || "en-US";
|
||||
const i18nData = i18n(locale);
|
||||
const displayedTime = i18nData.components.contentMeta.readingTime({
|
||||
minutes: Math.ceil(minutes)
|
||||
});
|
||||
segments.push(/* @__PURE__ */ jsx("span", { children: displayedTime }));
|
||||
}
|
||||
return /* @__PURE__ */ jsx("p", { "show-comma": options.showComma, class: classNames(displayClass, "content-meta"), children: segments });
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
ContentMetadata.css = contentMeta_default;
|
||||
return ContentMetadata;
|
||||
});
|
||||
|
||||
export { ContentMeta_default as ContentMeta };
|
||||
//# sourceMappingURL=index.js.map
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/components/index.js.map
vendored
Normal file
1
dist/components/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
88
dist/index.js
vendored
Normal file
88
dist/index.js
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import readingTime from 'reading-time';
|
||||
import { jsx } from 'preact/jsx-runtime';
|
||||
|
||||
// src/components/ContentMeta.tsx
|
||||
|
||||
// src/util/lang.ts
|
||||
function classNames(...classes) {
|
||||
return classes.filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
// src/i18n/locales/en-US.ts
|
||||
var en_US_default = {
|
||||
components: {
|
||||
contentMeta: {
|
||||
readingTime: ({ minutes }) => {
|
||||
if (minutes === 1) {
|
||||
return "1 min read";
|
||||
}
|
||||
return `${minutes} min read`;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// src/i18n/index.ts
|
||||
var locales = {
|
||||
"en-US": en_US_default
|
||||
};
|
||||
function i18n(locale) {
|
||||
return locales[locale] || en_US_default;
|
||||
}
|
||||
function getDate(cfg, data) {
|
||||
if (!cfg.defaultDateType) {
|
||||
throw new Error(
|
||||
`Field 'defaultDateType' was not set in the configuration object of quartz.config.ts. See https://quartz.jzhao.xyz/configuration#general-configuration for more details.`
|
||||
);
|
||||
}
|
||||
const dates = data.dates;
|
||||
return dates?.[cfg.defaultDateType];
|
||||
}
|
||||
function formatDate(d, locale = "en-US") {
|
||||
return d.toLocaleDateString(locale, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "2-digit"
|
||||
});
|
||||
}
|
||||
function DateComponent({ date, locale }) {
|
||||
return /* @__PURE__ */ jsx("time", { datetime: date.toISOString(), children: formatDate(date, locale) });
|
||||
}
|
||||
|
||||
// src/components/styles/contentMeta.scss
|
||||
var contentMeta_default = '.content-meta {\n margin-top: 0;\n color: var(--darkgray);\n}\n.content-meta[show-comma=true] > *:not(:last-child) {\n margin-right: 8px;\n}\n.content-meta[show-comma=true] > *:not(:last-child)::after {\n content: ",";\n}';
|
||||
var defaultOptions = {
|
||||
showReadingTime: true,
|
||||
showComma: true
|
||||
};
|
||||
var ContentMeta_default = ((opts) => {
|
||||
const options = { ...defaultOptions, ...opts };
|
||||
function ContentMetadata({ cfg, fileData, displayClass }) {
|
||||
const text = fileData.text;
|
||||
if (text) {
|
||||
const segments = [];
|
||||
if (fileData.dates) {
|
||||
const locale = cfg.locale || "en-US";
|
||||
segments.push(/* @__PURE__ */ jsx(DateComponent, { date: getDate(cfg, fileData), locale }));
|
||||
}
|
||||
if (options.showReadingTime) {
|
||||
const { minutes, words: _words } = readingTime(text);
|
||||
const locale = cfg.locale || "en-US";
|
||||
const i18nData = i18n(locale);
|
||||
const displayedTime = i18nData.components.contentMeta.readingTime({
|
||||
minutes: Math.ceil(minutes)
|
||||
});
|
||||
segments.push(/* @__PURE__ */ jsx("span", { children: displayedTime }));
|
||||
}
|
||||
return /* @__PURE__ */ jsx("p", { "show-comma": options.showComma, class: classNames(displayClass, "content-meta"), children: segments });
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
ContentMetadata.css = contentMeta_default;
|
||||
return ContentMetadata;
|
||||
});
|
||||
|
||||
export { ContentMeta_default as ContentMeta };
|
||||
//# sourceMappingURL=index.js.map
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
20
package-lock.json
generated
20
package-lock.json
generated
|
|
@ -9,10 +9,7 @@
|
|||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "github:quartz-community/types",
|
||||
"reading-time": "^1.5.0",
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.9.3"
|
||||
"@quartz-community/types": "github:quartz-community/types"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/hast": "^3.0.4",
|
||||
|
|
@ -25,6 +22,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": {
|
||||
|
|
@ -33,7 +32,8 @@
|
|||
},
|
||||
"peerDependencies": {
|
||||
"@jackyzha0/quartz": "^4.5.2",
|
||||
"preact": "^10.0.0"
|
||||
"preact": "^10.0.0",
|
||||
"reading-time": "^1.5.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@jackyzha0/quartz": {
|
||||
|
|
@ -41,6 +41,9 @@
|
|||
},
|
||||
"preact": {
|
||||
"optional": false
|
||||
},
|
||||
"reading-time": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -3214,7 +3217,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.11",
|
||||
"picocolors": "^1.1.1",
|
||||
|
|
@ -3347,12 +3349,6 @@
|
|||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/reading-time": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/reading-time/-/reading-time-1.5.0.tgz",
|
||||
"integrity": "sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/resolve-from": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"prepare": "npm run build",
|
||||
"dev": "tsup --watch",
|
||||
"lint": "eslint . --max-warnings=0",
|
||||
"format": "prettier . --check",
|
||||
|
|
|
|||
Loading…
Reference in a new issue