UNPKG

@callstack/rspress-theme

Version:
181 lines (180 loc) 10.3 kB
"use strict"; const __rslib_import_meta_url__ = /*#__PURE__*/ function() { return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href; }(); var __webpack_require__ = {}; (()=>{ __webpack_require__.n = (module)=>{ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module; __webpack_require__.d(getter, { a: getter }); return getter; }; })(); (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { pluginCallstackTheme: ()=>pluginCallstackTheme }); const external_node_module_namespaceObject = require("node:module"); const external_node_path_namespaceObject = require("node:path"); var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject); const external_node_url_namespaceObject = require("node:url"); const OUTLINE_TITLE = 'Contents'; const SEARCH_NO_RESULTS_TEXT = 'No results found, try something different than'; const SEARCH_SUGGESTED_QUERY_TEXT = ' '; const OVERVIEW_FILTER_NAME_TEXT = ' '; const OUTLINE_CTA_BUTTON_TEXT = "Let's talk"; const OUTLINE_CTA_DESCRIPTION = 'We support teams building scalable apps with React and React Native.'; const OUTLINE_CTA_HEADLINE = 'Need help with React or React Native projects?'; const OUTLINE_CTA_LINK = 'https://www.callstack.com/contact'; const DOC_FOOTER_CTA_BUTTON_TEXT = "Let's talk"; const DOC_FOOTER_CTA_HEADLINE = 'Need React or React Native\nexpertise you can count on?'; const DOC_FOOTER_CTA_LINK = 'https://www.callstack.com/contact'; const HOME_BANNER_HEADLINE = 'Need React or React Native\nexpertise you can count on?'; const HOME_BANNER_DESCRIPTION = "We've spent years building full-stack, cross-platform apps and solving tough technical challenges."; const HOME_BANNER_BUTTON_TEXT = "Let's talk"; const HOME_BANNER_LINK = 'https://www.callstack.com/contact'; const HOME_FOOTER_LINK = 'https://callstack.com'; const EDIT_LINK_TEXT = 'Edit this page on GitHub'; const dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)); function excludeFalse(value) { return false !== value; } function getThemeAliases(existingThemeAlias) { const ckThemeExportsPath = external_node_path_default().join(dirname, 'theme'); const { resolve } = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__); const rspressCoreThemePath = resolve('@rspress/core/theme', { paths: [ resolve('@rspress/core/package.json') ] }); const aliases = {}; if (Array.isArray(existingThemeAlias)) { const index = existingThemeAlias.indexOf(rspressCoreThemePath); if (-1 !== index) { aliases['@theme'] = existingThemeAlias.filter(excludeFalse).slice(); aliases['@theme'].splice(index, 0, ckThemeExportsPath); } else aliases['@theme'] = existingThemeAlias.filter(excludeFalse).concat(ckThemeExportsPath); } else aliases['@theme'] = ckThemeExportsPath; aliases['@default-theme'] = rspressCoreThemePath; aliases['@rspress/core/theme'] = ckThemeExportsPath; aliases['@theme-original'] = ckThemeExportsPath; aliases['@rspress/core/theme-original'] = ckThemeExportsPath; return aliases; } function getBuilderConfig(options) { var _options_content, _options_content1, _options_links, _options_links1, _options_content2, _options_content3, _options_content4, _options_links2, _options_content5, _options_content6, _options_content7, _options_links3; return { source: { define: { DOC_FOOTER_CTA_BUTTON_TEXT: JSON.stringify(null == (_options_content = options.content) ? void 0 : _options_content.docFooterCTAButtonText), DOC_FOOTER_CTA_HEADLINE: JSON.stringify(null == (_options_content1 = options.content) ? void 0 : _options_content1.docFooterCTAHeadline), DOC_FOOTER_CTA_LINK: JSON.stringify(null == (_options_links = options.links) ? void 0 : _options_links.docFooterCTA), HOME_BANNER_LINK: JSON.stringify(null == (_options_links1 = options.links) ? void 0 : _options_links1.homeBanner), HOME_BANNER_BUTTON_TEXT: JSON.stringify(null == (_options_content2 = options.content) ? void 0 : _options_content2.homeBannerButtonText), HOME_BANNER_DESCRIPTION: JSON.stringify(null == (_options_content3 = options.content) ? void 0 : _options_content3.homeBannerDescription), HOME_BANNER_HEADLINE: JSON.stringify(null == (_options_content4 = options.content) ? void 0 : _options_content4.homeBannerHeadline), HOME_FOOTER_LINK: JSON.stringify(null == (_options_links2 = options.links) ? void 0 : _options_links2.homeFooter), OUTLINE_CTA_BUTTON_TEXT: JSON.stringify(null == (_options_content5 = options.content) ? void 0 : _options_content5.outlineCTAButtonText), OUTLINE_CTA_DESCRIPTION: JSON.stringify(null == (_options_content6 = options.content) ? void 0 : _options_content6.outlineCTADescription), OUTLINE_CTA_HEADLINE: JSON.stringify(null == (_options_content7 = options.content) ? void 0 : _options_content7.outlineCTAHeadline), OUTLINE_CTA_LINK: JSON.stringify(null == (_options_links3 = options.links) ? void 0 : _options_links3.outlineCTA) } }, resolve: { alias: (alias)=>{ const themeAliases = getThemeAliases(alias['@theme']); Object.assign(alias, themeAliases); } } }; } function getI18nSourceOverrides(existingI18nSource = {}) { const i18nSource = { ...existingI18nSource }; if (!i18nSource['overview.filterNameText']) i18nSource['overview.filterNameText'] = { en: OVERVIEW_FILTER_NAME_TEXT, zh: OVERVIEW_FILTER_NAME_TEXT }; if (!i18nSource.outlineTitle) i18nSource.outlineTitle = { en: OUTLINE_TITLE, zh: OUTLINE_TITLE }; if (!i18nSource.searchNoResultsText) i18nSource.searchNoResultsText = { en: SEARCH_NO_RESULTS_TEXT, zh: SEARCH_NO_RESULTS_TEXT }; if (!i18nSource.searchSuggestedQueryText) i18nSource.searchSuggestedQueryText = { en: SEARCH_SUGGESTED_QUERY_TEXT, zh: SEARCH_SUGGESTED_QUERY_TEXT }; if (!i18nSource.editLinkText) i18nSource.editLinkText = { en: EDIT_LINK_TEXT, zh: EDIT_LINK_TEXT }; return i18nSource; } function normalizeOptions(options) { var _options_content, _options_content1, _options_content2, _options_content3, _options_content4, _options_content5, _options_content6, _options_content7, _options_links, _options_links1, _options_links2, _options_links3; return { content: { docFooterCTAButtonText: (null == (_options_content = options.content) ? void 0 : _options_content.docFooterCTAButtonText) ?? DOC_FOOTER_CTA_BUTTON_TEXT, docFooterCTAHeadline: (null == (_options_content1 = options.content) ? void 0 : _options_content1.docFooterCTAHeadline) ?? DOC_FOOTER_CTA_HEADLINE, homeBannerButtonText: (null == (_options_content2 = options.content) ? void 0 : _options_content2.homeBannerButtonText) ?? HOME_BANNER_BUTTON_TEXT, homeBannerDescription: (null == (_options_content3 = options.content) ? void 0 : _options_content3.homeBannerDescription) ?? HOME_BANNER_DESCRIPTION, homeBannerHeadline: (null == (_options_content4 = options.content) ? void 0 : _options_content4.homeBannerHeadline) ?? HOME_BANNER_HEADLINE, outlineCTAButtonText: (null == (_options_content5 = options.content) ? void 0 : _options_content5.outlineCTAButtonText) ?? OUTLINE_CTA_BUTTON_TEXT, outlineCTADescription: (null == (_options_content6 = options.content) ? void 0 : _options_content6.outlineCTADescription) ?? OUTLINE_CTA_DESCRIPTION, outlineCTAHeadline: (null == (_options_content7 = options.content) ? void 0 : _options_content7.outlineCTAHeadline) ?? OUTLINE_CTA_HEADLINE }, links: { docFooterCTA: (null == (_options_links = options.links) ? void 0 : _options_links.docFooterCTA) ?? DOC_FOOTER_CTA_LINK, homeBanner: (null == (_options_links1 = options.links) ? void 0 : _options_links1.homeBanner) ?? HOME_BANNER_LINK, homeFooter: (null == (_options_links2 = options.links) ? void 0 : _options_links2.homeFooter) ?? HOME_FOOTER_LINK, outlineCTA: (null == (_options_links3 = options.links) ? void 0 : _options_links3.outlineCTA) ?? OUTLINE_CTA_LINK } }; } function pluginCallstackTheme(options = {}) { const normalizedOptions = normalizeOptions(options); return { name: 'plugin-callstack-theme', builderConfig: getBuilderConfig(normalizedOptions), config: (config)=>{ config.i18nSource = getI18nSourceOverrides(config.i18nSource); return config; }, globalStyles: external_node_path_default().join(external_node_path_default().dirname(dirname), 'styles/styles.css') }; } exports.pluginCallstackTheme = __webpack_exports__.pluginCallstackTheme; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "pluginCallstackTheme" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true });