Skip to content

Commit 7349920

Browse files
committed
Code blocks
1 parent 0b7a052 commit 7349920

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

docs_headless/astro.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import starlight from '@astrojs/starlight';
44
import starlightSidebarTopics from 'starlight-sidebar-topics';
55
import tailwindcss from '@tailwindcss/vite';
66
import mdx from '@astrojs/mdx';
7+
import rehypeCodeGroup from 'rehype-code-group';
8+
import expressiveCode from 'astro-expressive-code';
79

810
// https://astro.build/config
911
export default defineConfig({
@@ -640,9 +642,12 @@ export default defineConfig({
640642
Sidebar: './src/components/CustomSidebar.astro',
641643
},
642644
}),
645+
expressiveCode(),
643646
mdx(),
644647
],
645-
648+
markdown: {
649+
rehypePlugins: [rehypeCodeGroup],
650+
},
646651
vite: {
647652
plugins: [tailwindcss()],
648653
},

docs_headless/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"@astrojs/starlight-tailwind": "^4.0.1",
1616
"@tailwindcss/vite": "^4.1.11",
1717
"astro": "^5.6.1",
18+
"astro-expressive-code": "^0.41.3",
19+
"rehype-code-group": "^0.2.4",
1820
"sharp": "^0.34.2",
1921
"starlight-package-managers": "^0.11.0",
2022
"starlight-sidebar-topics": "^0.6.0",

docs_headless/src/content/docs/mui/guides/Architecture.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ To achieve this, react-admin utilizes an internal router, powered by `react-rout
1717
For example, the following react-admin application:
1818

1919
```jsx
20+
// File name: src/App.tsx
2021
import { CoreAdminContext, CoreAdminUI, Resource, CustomRoutes } from 'ra-core';
2122
import { Route } from 'react-router-dom';
2223

@@ -139,6 +140,7 @@ React-admin avoids components that accept an overwhelming number of props, which
139140
For example, while you cannot directly pass a list of actions to the `<Edit>` component, you can achieve the same result by passing an `actions` component:
140141

141142
```jsx
143+
// File name: src/PostEdit.tsx
142144
import { Button } from '@mui/material';
143145
import { TopToolbar, ShowButton } from 'react-admin';
144146

@@ -160,8 +162,8 @@ This approach enables you to override specific parts of the logic of a component
160162

161163
The trade-off with this approach is that sometimes react-admin may require you to override several components just to enable one specific feature. For instance, to override the Menu, you must first create a custom layout using your menu as the `<Layout menu>` prop, then pass it as the `<Admin layout>` prop:
162164

163-
```jsx
164-
// in src/MyLayout.js
165+
::: code-group labels=[src/MyLayout.tsx, src/App.tsx]
166+
```tsx
165167
import { Layout } from 'react-admin';
166168
import { Menu } from './Menu';
167169

@@ -170,8 +172,8 @@ export const MyLayout = ({ children }) => (
170172
{children}
171173
</Layout>
172174
);
173-
174-
// in src/App.js
175+
```
176+
```tsx
175177
import { Admin } from 'react-admin';
176178
import { MyLayout } from './MyLayout';
177179

@@ -181,6 +183,7 @@ const App = () => (
181183
</Admin>
182184
);
183185
```
186+
:::
184187

185188
Although this drawback exists, we accept it because the use of composition in react-admin makes the components highly extensible, and it significantly improves the readability and maintainability of the code.
186189

docs_headless/src/styles/global.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ img.icon {
2727
display: inline-flex;
2828
top: 2px;
2929
position: relative;
30+
}
31+
32+
.rcg-tab {
33+
margin: 0;
3034
}

yarn.lock

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7493,7 +7493,7 @@ __metadata:
74937493
languageName: node
74947494
linkType: hard
74957495

7496-
"astro-expressive-code@npm:^0.41.1":
7496+
"astro-expressive-code@npm:^0.41.1, astro-expressive-code@npm:^0.41.3":
74977497
version: 0.41.3
74987498
resolution: "astro-expressive-code@npm:0.41.3"
74997499
dependencies:
@@ -12913,7 +12913,7 @@ __metadata:
1291312913
languageName: node
1291412914
linkType: hard
1291512915

12916-
"hast-util-to-string@npm:^3.0.0":
12916+
"hast-util-to-string@npm:^3.0.0, hast-util-to-string@npm:~3.0.1":
1291712917
version: 3.0.1
1291812918
resolution: "hast-util-to-string@npm:3.0.1"
1291912919
dependencies:
@@ -19161,8 +19161,10 @@ __metadata:
1916119161
"@astrojs/starlight-tailwind": "npm:^4.0.1"
1916219162
"@tailwindcss/vite": "npm:^4.1.11"
1916319163
astro: "npm:^5.6.1"
19164+
astro-expressive-code: "npm:^0.41.3"
1916419165
prettier: "npm:^3.2.5"
1916519166
prettier-plugin-astro: "npm:^0.14.1"
19167+
rehype-code-group: "npm:^0.2.4"
1916619168
sharp: "npm:^0.34.2"
1916719169
starlight-package-managers: "npm:^0.11.0"
1916819170
starlight-sidebar-topics: "npm:^0.6.0"
@@ -20330,6 +20332,23 @@ __metadata:
2033020332
languageName: node
2033120333
linkType: hard
2033220334

20335+
"rehype-code-group@npm:^0.2.4":
20336+
version: 0.2.4
20337+
resolution: "rehype-code-group@npm:0.2.4"
20338+
dependencies:
20339+
hast-util-to-string: "npm:~3.0.1"
20340+
rehype: "npm:~13.0.2"
20341+
unified: "npm:~11.0.5"
20342+
unist-util-visit: "npm:~5.0.0"
20343+
peerDependencies:
20344+
typescript: ">=5.0.4"
20345+
peerDependenciesMeta:
20346+
typescript:
20347+
optional: true
20348+
checksum: 7e0993e3ee961cd4ba392eb1708d45e348e7aee97f42707d0d985df3b40927dc889f1f2de03118a9f9bc06fb38967b17a8c05005a7ab94df280656edd05a3ecc
20349+
languageName: node
20350+
linkType: hard
20351+
2033320352
"rehype-expressive-code@npm:^0.41.3":
2033420353
version: 0.41.3
2033520354
resolution: "rehype-expressive-code@npm:0.41.3"
@@ -20393,7 +20412,7 @@ __metadata:
2039320412
languageName: node
2039420413
linkType: hard
2039520414

20396-
"rehype@npm:^13.0.1, rehype@npm:^13.0.2":
20415+
"rehype@npm:^13.0.1, rehype@npm:^13.0.2, rehype@npm:~13.0.2":
2039720416
version: 13.0.2
2039820417
resolution: "rehype@npm:13.0.2"
2039920418
dependencies:
@@ -23046,7 +23065,7 @@ __metadata:
2304623065
languageName: node
2304723066
linkType: hard
2304823067

23049-
"unified@npm:^11.0.0, unified@npm:^11.0.4, unified@npm:^11.0.5":
23068+
"unified@npm:^11.0.0, unified@npm:^11.0.4, unified@npm:^11.0.5, unified@npm:~11.0.5":
2305023069
version: 11.0.5
2305123070
resolution: "unified@npm:11.0.5"
2305223071
dependencies:
@@ -23193,7 +23212,7 @@ __metadata:
2319323212
languageName: node
2319423213
linkType: hard
2319523214

23196-
"unist-util-visit@npm:^5.0.0":
23215+
"unist-util-visit@npm:^5.0.0, unist-util-visit@npm:~5.0.0":
2319723216
version: 5.0.0
2319823217
resolution: "unist-util-visit@npm:5.0.0"
2319923218
dependencies:

0 commit comments

Comments
 (0)