You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`[Rspress] Theme breaking change: The theme/index is now using namedExports instead of defaultExports, please update your config file in ${useDefaultExportFilePath}`,
27
+
picocolors.red(`
28
+
- import Theme from '@rspress/theme-default';
29
+
- export default {
30
+
- ...Theme,
31
+
- Layout,
32
+
- };
33
+
- export * from 'rspress/theme';`)+
34
+
picocolors.green(`+ import { Layout } from '@rspress/theme-default';
On the one hand, you need to export a theme configuration object through `export default`, on the other hand, you need to export all named exported content through `export * from 'rspress/theme'` so as to ensure your theme works fine.
34
+
On the one hand, you need to export a theme configuration object through `export`, on the other hand, you need to export all named exported content through `export * from 'rspress/theme'` so as to ensure your theme works fine.
38
35
39
36
### 2. Use slot
40
37
41
38
It is worth noting that the `Layout` component has designed a series of props to support slot elements. You can use these props to extend the layout of the default theme. For example, change the above `Layout` component to the following form:
42
39
43
40
```tsx title="theme/index.tsx"
44
-
importThemefrom'rspress/theme';
41
+
import{ LayoutasBasicLayout }from'rspress/theme';
45
42
46
43
// Show all props below
47
44
const Layout = () => (
48
-
<Theme.Layout
45
+
<BasicLayout
49
46
/* Before home hero */
50
47
beforeHero={<div>beforeHero</div>}
51
48
/* After home hero */
@@ -93,11 +90,8 @@ const Layout = () => (
93
90
/>
94
91
);
95
92
96
-
exportdefault {
97
-
...Theme,
98
-
Layout,
99
-
};
100
-
93
+
export { Layout };
94
+
// re-export
101
95
export*from'rspress/theme';
102
96
```
103
97
@@ -107,29 +101,28 @@ In addition to the slot method, if you want to extend the default theme componen
107
101
as well as other Rspress [built-in components](https://github.com/web-infra-dev/rspress/tree/main/packages/theme-default/src/components)
// The setup function will be called when the page is initialized. It is generally used to monitor global events, and it can be an empty function
173
166
const setup = () => {};
174
167
168
+
// Export Layout component and setup function
169
+
export { Layout, setup };
175
170
// Export all content of the default theme to ensure that your theme configuration can work properly
176
171
export*from'rspress/theme';
177
-
178
-
// Export Layout component and setup function
179
-
// Note: both must export
180
-
exportdefault { Layout, setup };
181
172
```
182
173
183
174
Layout component will be used to render the layout of the entire document site, you can introduce your custom components in this component, for example:
0 commit comments