dumi 2.0.0 → 2.0.1

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.
@@ -21,6 +21,10 @@ export interface IPreviewerProps {
21
21
  * debug mark (will only render in dev by default)
22
22
  */
23
23
  debug?: boolean;
24
+ /**
25
+ * url for render current demo in a single page
26
+ */
27
+ demoUrl: string;
24
28
  /**
25
29
  * disable demo content padding
26
30
  */
@@ -55,6 +55,10 @@ function createMetadataSection(rawTitle, title, link, texts, tocIndex) {
55
55
  } : null;
56
56
  }
57
57
 
58
+ function generateRouteTitle(fm) {
59
+ return [fm.title, fm.subtitle].filter(Boolean).join(' ');
60
+ }
61
+
58
62
  function generateSearchMetadata(routes, demos, nav) {
59
63
  var metadata = []; // generate demos mapping by route.id
60
64
 
@@ -83,11 +87,11 @@ function generateSearchMetadata(routes, demos, nav) {
83
87
 
84
88
  return (_demo$asset = demo.asset) === null || _demo$asset === void 0 ? void 0 : _demo$asset.id;
85
89
  });
86
- var orphanSection = createMetadataSection('', routeMeta.frontmatter.title, routeAbsPath, routeMeta.texts);
90
+ var orphanSection = createMetadataSection('', generateRouteTitle(routeMeta.frontmatter), routeAbsPath, routeMeta.texts);
87
91
  var tocSections = routeMeta.toc.reduce(function (acc, toc, i) {
88
92
  // exclude demo id, to avoid duplicate
89
93
  if (!demoIds.includes(toc.id) && toc.depth > 1) {
90
- acc.push(createMetadataSection(toc.title, "".concat(routeMeta.frontmatter.title, " - ").concat(toc.title), "".concat(routeAbsPath, "#").concat(toc.id), routeMeta.texts, i));
94
+ acc.push(createMetadataSection(toc.title, "".concat(generateRouteTitle(routeMeta.frontmatter), " - ").concat(toc.title), "".concat(routeAbsPath, "#").concat(toc.id), routeMeta.texts, i));
91
95
  }
92
96
 
93
97
  return acc;
@@ -96,25 +100,25 @@ function generateSearchMetadata(routes, demos, nav) {
96
100
  var key = _ref.key,
97
101
  meta = _ref.meta;
98
102
  // collect orphan section that not in toc
99
- var tabOrphanSection = createMetadataSection('', "".concat(routeMeta.frontmatter.title, " - ").concat(meta.frontmatter.title), "".concat(routeAbsPath, "?").concat(TAB_QUERY_KEY, "=").concat(key), meta.texts);
103
+ var tabOrphanSection = createMetadataSection('', "".concat(generateRouteTitle(routeMeta.frontmatter), " - ").concat(meta.frontmatter.title), "".concat(routeAbsPath, "?").concat(TAB_QUERY_KEY, "=").concat(key), meta.texts);
100
104
  if (tabOrphanSection) acc.push(tabOrphanSection); // collect sections by toc
101
105
 
102
106
  acc.push.apply(acc, _toConsumableArray(meta.toc.map(function (toc, i) {
103
- return createMetadataSection(toc.title, "".concat(routeMeta.frontmatter.title, " - ").concat(meta.frontmatter.title, " - ").concat(toc.title), "".concat(routeAbsPath, "?").concat(TAB_QUERY_KEY, "=").concat(key, "#").concat(toc.id), meta.texts, i);
107
+ return createMetadataSection(toc.title, "".concat(generateRouteTitle(routeMeta.frontmatter), " - ").concat(meta.frontmatter.title, " - ").concat(toc.title), "".concat(routeAbsPath, "?").concat(TAB_QUERY_KEY, "=").concat(key, "#").concat(toc.id), meta.texts, i);
104
108
  })));
105
109
  return acc;
106
110
  }, []);
107
111
  metadata.push({
108
112
  navTitle: routeNav === null || routeNav === void 0 ? void 0 : routeNav.title,
109
113
  navOrder: routeNav ? nav.indexOf(routeNav) : Infinity,
110
- title: routeMeta.frontmatter.title,
114
+ title: generateRouteTitle(routeMeta.frontmatter),
111
115
  link: routeAbsPath,
112
116
  sections: [].concat(_toConsumableArray(orphanSection ? [orphanSection] : []), _toConsumableArray(tocSections), _toConsumableArray(tabSections)),
113
117
  demos: ((_demosMapping$route$i = demosMapping[route.id]) === null || _demosMapping$route$i === void 0 ? void 0 : _demosMapping$route$i.map(function (demo) {
114
118
  return {
115
119
  link: "".concat(routeAbsPath, "#").concat(demo.asset.id),
116
120
  rawTitle: demo.asset.title || '',
117
- title: demo.asset.title || routeMeta.frontmatter.title,
121
+ title: demo.asset.title || generateRouteTitle(routeMeta.frontmatter),
118
122
  description: demo.asset.description || '',
119
123
  keywords: demo.asset.keywords || []
120
124
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@ var Previewer = function Previewer(props) {
27
27
  style: ['string', 'number'].includes(_typeof(props.iframe)) ? {
28
28
  height: Number(props.iframe)
29
29
  } : {},
30
- src: "/~demos/".concat(props.asset.id)
30
+ src: props.demoUrl
31
31
  }) : props.children), /*#__PURE__*/React.createElement("div", {
32
32
  className: "dumi-default-previewer-meta"
33
33
  }, (props.title || props.debug) && /*#__PURE__*/React.createElement("div", {
@@ -1,5 +1,5 @@
1
1
  import { type Language } from 'prism-react-renderer';
2
- import 'prismjs/themes/prism.css';
2
+ import 'prismjs/themes/prism-coy.css';
3
3
  import { type FC } from 'react';
4
4
  import './index.less';
5
5
  declare const SourceCode: FC<{
@@ -15,7 +15,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import { ReactComponent as IconCheck } from '@ant-design/icons-svg/inline-svg/outlined/check.svg';
16
16
  import { ReactComponent as IconCopy } from '@ant-design/icons-svg/inline-svg/outlined/copy.svg';
17
17
  import Highlight, { defaultProps } from 'prism-react-renderer';
18
- import 'prismjs/themes/prism.css';
18
+ import 'prismjs/themes/prism-coy.css';
19
19
  import React, { useRef, useState } from 'react';
20
20
  import { CopyToClipboard } from 'react-copy-to-clipboard';
21
21
  import "./index.less";
@@ -4,17 +4,23 @@
4
4
  @bg-color: tint(@c-site-bg, 50%);
5
5
 
6
6
  position: relative;
7
- font-size: 14px;
8
7
  background-color: @bg-color;
9
8
  border-bottom-left-radius: 4px;
10
9
  border-bottom-right-radius: 4px;
11
10
 
12
11
  > pre.prism-code {
13
12
  margin: 0;
14
- padding-left: 24px;
15
- padding-right: 24px;
13
+ padding: 18px 24px;
14
+ font-size: 14px;
15
+ line-height: 1.58;
16
16
  direction: ltr;
17
17
  background: transparent;
18
+
19
+ // remove shadow from coy theme
20
+ &::before,
21
+ &::after {
22
+ content: none;
23
+ }
18
24
  }
19
25
 
20
26
  &-copy {