@vuepress/theme-default 2.0.0-beta.40 → 2.0.0-beta.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,9 +52,8 @@ export default defineComponent({
52
52
  // NOTICE: here we put the `slots.default()` inside the render function to make
53
53
  // the slots reactive, otherwise the slot content won't be changed once the
54
54
  // `setup()` function of current component is called
55
- var _a;
56
55
  // get children code-group-item
57
- const items = (((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || [])
56
+ const items = (slots.default?.() || [])
58
57
  .filter((vnode) => vnode.type.name === 'CodeGroupItem')
59
58
  .map((vnode) => {
60
59
  if (vnode.props === null) {
@@ -47,8 +47,8 @@ export const setupDarkMode = () => {
47
47
  export const updateHtmlDarkClass = (isDarkMode) => {
48
48
  const update = (value = isDarkMode.value) => {
49
49
  // set `class="dark"` on `<html>` element
50
- const htmlEl = window === null || window === void 0 ? void 0 : window.document.querySelector('html');
51
- htmlEl === null || htmlEl === void 0 ? void 0 : htmlEl.classList.toggle('dark', value);
50
+ const htmlEl = window?.document.querySelector('html');
51
+ htmlEl?.classList.toggle('dark', value);
52
52
  };
53
53
  onMounted(() => {
54
54
  watch(isDarkMode, update, { immediate: true });
@@ -7,7 +7,7 @@ export const useResolveRouteWithRedirect = (...args) => {
7
7
  const router = useRouter();
8
8
  const route = router.resolve(...args);
9
9
  const lastMatched = route.matched[route.matched.length - 1];
10
- if (!(lastMatched === null || lastMatched === void 0 ? void 0 : lastMatched.redirect)) {
10
+ if (!lastMatched?.redirect) {
11
11
  return route;
12
12
  }
13
13
  const { redirect } = lastMatched;
@@ -6,7 +6,7 @@ const scrollPromise = {
6
6
  promise = new Promise((resolve) => (promiseResolve = resolve));
7
7
  },
8
8
  resolve: () => {
9
- promiseResolve === null || promiseResolve === void 0 ? void 0 : promiseResolve();
9
+ promiseResolve?.();
10
10
  promise = null;
11
11
  promiseResolve = null;
12
12
  },
@@ -29,10 +29,9 @@ export const setupSidebarItems = () => {
29
29
  * It should only be resolved and provided once
30
30
  */
31
31
  export const resolveSidebarItems = (frontmatter, themeLocale) => {
32
- var _a, _b, _c, _d;
33
32
  // get sidebar config from frontmatter > theme data
34
- const sidebarConfig = (_b = (_a = frontmatter.sidebar) !== null && _a !== void 0 ? _a : themeLocale.sidebar) !== null && _b !== void 0 ? _b : 'auto';
35
- const sidebarDepth = (_d = (_c = frontmatter.sidebarDepth) !== null && _c !== void 0 ? _c : themeLocale.sidebarDepth) !== null && _d !== void 0 ? _d : 2;
33
+ const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
34
+ const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
36
35
  // resolve sidebar items according to the config
37
36
  if (frontmatter.home || sidebarConfig === false) {
38
37
  return [];
@@ -78,7 +77,6 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
78
77
  const route = useRoute();
79
78
  const page = usePageData();
80
79
  const handleChildItem = (item) => {
81
- var _a;
82
80
  let childItem;
83
81
  if (isString(item)) {
84
82
  childItem = useNavLink(item);
@@ -96,7 +94,7 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
96
94
  // use headers of current page as children
97
95
  if (childItem.link === route.path) {
98
96
  // skip h1 header
99
- const headers = ((_a = page.value.headers[0]) === null || _a === void 0 ? void 0 : _a.level) === 1
97
+ const headers = page.value.headers[0]?.level === 1
100
98
  ? page.value.headers[0].children
101
99
  : page.value.headers;
102
100
  return {
@@ -112,9 +110,8 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
112
110
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
113
111
  */
114
112
  export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth) => {
115
- var _a;
116
113
  const route = useRoute();
117
114
  const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
118
- const matchedSidebarConfig = (_a = sidebarConfig[sidebarPath]) !== null && _a !== void 0 ? _a : [];
115
+ const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
119
116
  return resolveArraySidebarItems(matchedSidebarConfig, sidebarDepth);
120
117
  };
@@ -14,7 +14,6 @@ const plugin_theme_data_1 = require("@vuepress/plugin-theme-data");
14
14
  const utils_1 = require("@vuepress/utils");
15
15
  const utils_2 = require("./utils");
16
16
  const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
17
- var _a, _b, _c, _d, _e, _f;
18
17
  (0, utils_2.assignDefaultLocaleOptions)(localeOptions);
19
18
  return {
20
19
  name: '@vuepress/theme-default',
@@ -49,30 +48,30 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
49
48
  // @vuepress/plugin-back-to-top
50
49
  themePlugins.backToTop !== false ? (0, plugin_back_to_top_1.backToTopPlugin)() : [],
51
50
  // @vuepress/plugin-container
52
- ((_a = themePlugins.container) === null || _a === void 0 ? void 0 : _a.tip) !== false
51
+ themePlugins.container?.tip !== false
53
52
  ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'tip'))
54
53
  : [],
55
- ((_b = themePlugins.container) === null || _b === void 0 ? void 0 : _b.warning) !== false
54
+ themePlugins.container?.warning !== false
56
55
  ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'warning'))
57
56
  : [],
58
- ((_c = themePlugins.container) === null || _c === void 0 ? void 0 : _c.danger) !== false
57
+ themePlugins.container?.danger !== false
59
58
  ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'danger'))
60
59
  : [],
61
- ((_d = themePlugins.container) === null || _d === void 0 ? void 0 : _d.details) !== false
60
+ themePlugins.container?.details !== false
62
61
  ? (0, plugin_container_1.containerPlugin)({
63
62
  type: 'details',
64
63
  before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
65
64
  after: () => '</details>\n',
66
65
  })
67
66
  : [],
68
- ((_e = themePlugins.container) === null || _e === void 0 ? void 0 : _e.codeGroup) !== false
67
+ themePlugins.container?.codeGroup !== false
69
68
  ? (0, plugin_container_1.containerPlugin)({
70
69
  type: 'code-group',
71
70
  before: () => `<CodeGroup>\n`,
72
71
  after: () => '</CodeGroup>\n',
73
72
  })
74
73
  : [],
75
- ((_f = themePlugins.container) === null || _f === void 0 ? void 0 : _f.codeGroupItem) !== false
74
+ themePlugins.container?.codeGroupItem !== false
76
75
  ? (0, plugin_container_1.containerPlugin)({
77
76
  type: 'code-group-item',
78
77
  before: (info) => `<CodeGroupItem title="${info}">\n`,
@@ -83,9 +82,8 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
83
82
  themePlugins.externalLinkIcon !== false
84
83
  ? (0, plugin_external_link_icon_1.externalLinkIconPlugin)({
85
84
  locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
86
- var _a;
87
85
  result[key] = {
88
- openInNewWindow: (_a = value.openInNewWindow) !== null && _a !== void 0 ? _a : localeOptions.openInNewWindow,
86
+ openInNewWindow: value.openInNewWindow ?? localeOptions.openInNewWindow,
89
87
  };
90
88
  return result;
91
89
  }, {}),
@@ -8,9 +8,8 @@ exports.resolveContainerPluginOptions = void 0;
8
8
  */
9
9
  const resolveContainerPluginOptions = (localeOptions, type) => {
10
10
  const locales = Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
11
- var _a;
12
11
  result[key] = {
13
- defaultInfo: (_a = value === null || value === void 0 ? void 0 : value[type]) !== null && _a !== void 0 ? _a : localeOptions[type],
12
+ defaultInfo: value?.[type] ?? localeOptions[type],
14
13
  };
15
14
  return result;
16
15
  }, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.40",
3
+ "version": "2.0.0-beta.43",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -25,22 +25,22 @@
25
25
  "templates"
26
26
  ],
27
27
  "dependencies": {
28
- "@vuepress/client": "2.0.0-beta.40",
29
- "@vuepress/core": "2.0.0-beta.40",
30
- "@vuepress/plugin-active-header-links": "2.0.0-beta.40",
31
- "@vuepress/plugin-back-to-top": "2.0.0-beta.40",
32
- "@vuepress/plugin-container": "2.0.0-beta.40",
33
- "@vuepress/plugin-external-link-icon": "2.0.0-beta.40",
34
- "@vuepress/plugin-git": "2.0.0-beta.40",
35
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.40",
36
- "@vuepress/plugin-nprogress": "2.0.0-beta.40",
37
- "@vuepress/plugin-palette": "2.0.0-beta.40",
38
- "@vuepress/plugin-prismjs": "2.0.0-beta.40",
39
- "@vuepress/plugin-theme-data": "2.0.0-beta.40",
40
- "@vuepress/shared": "2.0.0-beta.40",
41
- "@vuepress/utils": "2.0.0-beta.40",
28
+ "@vuepress/client": "2.0.0-beta.43",
29
+ "@vuepress/core": "2.0.0-beta.43",
30
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.43",
31
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.43",
32
+ "@vuepress/plugin-container": "2.0.0-beta.43",
33
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.43",
34
+ "@vuepress/plugin-git": "2.0.0-beta.43",
35
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.43",
36
+ "@vuepress/plugin-nprogress": "2.0.0-beta.43",
37
+ "@vuepress/plugin-palette": "2.0.0-beta.43",
38
+ "@vuepress/plugin-prismjs": "2.0.0-beta.43",
39
+ "@vuepress/plugin-theme-data": "2.0.0-beta.43",
40
+ "@vuepress/shared": "2.0.0-beta.43",
41
+ "@vuepress/utils": "2.0.0-beta.43",
42
42
  "@vueuse/core": "^8.2.1",
43
- "sass": "^1.49.10",
43
+ "sass": "^1.51.0",
44
44
  "vue": "^3.2.33",
45
45
  "vue-router": "^4.0.14"
46
46
  },