UNPKG

dumi-theme-lobehub

Version:

dumi-theme-lobehub is a documentation site theme package designed for dumi2. It provides a more beautiful and user-friendly development and reading experience based on @lobehub/ui

66 lines (62 loc) 2.9 kB
var isHeroPage = function isHeroPage(s) { return s.location.pathname === '/'; }; var localeValue = function localeValue(s, value) { if (!value) return; if (value[s.locale.id]) return value[s.locale.id]; return value; }; /** * Hero Title 选择器 * 选择逻辑:优先使用 hero 配置的 title, 再兜底到 themeConfig 中的 name */ var heroTitle = function heroTitle(s) { var _s$routeMeta$frontmat, _localeValue; return ((_s$routeMeta$frontmat = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat === void 0 ? void 0 : _s$routeMeta$frontmat.title) || ( // 从 hero 的 title 中选择 (_localeValue = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue === void 0 ? void 0 : _localeValue.title) || // @deprecated 1.0 正式版本移除 // 从 hero 的 title 中选择 localeValue(s, s.siteData.themeConfig.title) || s.siteData.themeConfig.name; }; /** * Hero description 选择器 * 选择逻辑:优先使用 hero 配置的 description, 再兜底到 themeConfig 中的 name */ var heroDesc = function heroDesc(s) { var _s$routeMeta$frontmat2, _localeValue2; return ((_s$routeMeta$frontmat2 = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat2 === void 0 ? void 0 : _s$routeMeta$frontmat2.description) || ( // 从 hero 的 description 中选择 (_localeValue2 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue2 === void 0 ? void 0 : _localeValue2.description) || // @deprecated 1.0 正式版本移除 // 从 hero 的 description 中选择 localeValue(s, s.siteData.themeConfig.description); }; /** * Hero Action 选择器 * 选择逻辑:优先使用 hero 配置的 actions, 再兜底到 themeConfig 中的 actions */ var heroActions = function heroActions(s) { var _s$routeMeta$frontmat3, _localeValue3; return ((_s$routeMeta$frontmat3 = s.routeMeta.frontmatter.hero) === null || _s$routeMeta$frontmat3 === void 0 ? void 0 : _s$routeMeta$frontmat3.actions) || ( // 从 hero 的 actions 中选择 (_localeValue3 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue3 === void 0 ? void 0 : _localeValue3.actions) || // @deprecated 1.0 正式版本移除 localeValue(s, s.siteData.themeConfig.actions); }; /** * Features 选择器 */ var features = function features(s) { var _localeValue4; if (!isHeroPage(s)) return []; return ((_localeValue4 = localeValue(s, s.siteData.themeConfig.hero)) === null || _localeValue4 === void 0 ? void 0 : _localeValue4.features) || // @deprecated 1.0 正式版本移除 localeValue(s, s.siteData.themeConfig.features) || // 在themeConfig 没有配置的话,尝试兜底到 frontmatter 中的配置 s.routeMeta.frontmatter.features || []; }; export var heroSelectors = { features: features, heroActions: heroActions, heroDesc: heroDesc, heroTitle: heroTitle, isHeroPage: isHeroPage };