UNPKG

@nolebase/vitepress-plugin-page-properties

Version:

A VitePress plugin that renders frontmatter as page properties, and makes them editable.

47 lines (46 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isDatetimeProperty = isDatetimeProperty; exports.isDynamicReadingTimeProperty = isDynamicReadingTimeProperty; exports.isDynamicWordsCountProperty = isDynamicWordsCountProperty; exports.isLinkProperty = isLinkProperty; exports.isPlainProperty = isPlainProperty; exports.isProgressProperty = isProgressProperty; exports.isTagsProperty = isTagsProperty; function isTagsProperty(value, property) { return value && typeof value === "object" && property && property.type && property.type === "tags"; } function isPlainProperty(_, property) { if (property && property.type && property.type === "plain") return true; return false; } function isDatetimeProperty(value, property) { try { const date = new Date(value); if (date.toString() === "Invalid Date") return false; } catch { return false; } if (property && property.type && property.type === "datetime") return true; return false; } function isProgressProperty(value, property) { const parsedValue = Number.parseFloat(value); if (Number.isNaN(parsedValue)) return false; if (property && property.type && property.type === "progress") return true; return false; } function isLinkProperty(_, property) { if (property && property.type && property.type === "link") return true; return false; } function isDynamicWordsCountProperty(_, property) { if (property && property.type && property.type === "dynamic" && property.options && property.options.type === "wordsCount") return true; return false; } function isDynamicReadingTimeProperty(_, property) { if (property && property.type && property.type === "dynamic" && property.options && property.options.type === "readingTime") return true; return false; }