style: format the repository with prettier
These files were already out of step with the project's Prettier config before this branch of work; running `pnpm format` finally swept them up. No semantic changes. Kept separate from the functional commits so the reformatting does not bury them in diff noise.
This commit is contained in:
50 files changed
+643
-678
No files matched your search
@@ -50,8 +50,8 @@ Ejected source is placed in `theme/components/<ComponentName>/`.
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
export * from '@rspress/core/theme-original';
|
||||
export { DocFooter } from './components/DocFooter';
|
||||
export * from "@rspress/core/theme-original"
|
||||
export { DocFooter } from "./components/DocFooter"
|
||||
```
|
||||
|
||||
The named export takes precedence over the wildcard re-export, so Rspress uses your custom version.
|
||||
@@ -64,21 +64,21 @@ The most common eject use case is wrapping the entire app in a context provider
|
||||
|
||||
```tsx
|
||||
// theme/components/Root/index.tsx
|
||||
import type { RootProps } from '@rspress/core/theme';
|
||||
import type { RootProps } from "@rspress/core/theme"
|
||||
|
||||
export function Root({ children }: RootProps) {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AnalyticsProvider>{children}</AnalyticsProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
export * from '@rspress/core/theme-original';
|
||||
export { Root } from './components/Root';
|
||||
export * from "@rspress/core/theme-original"
|
||||
export { Root } from "./components/Root"
|
||||
```
|
||||
|
||||
## Common Pattern: Custom Home Page (HomeLayout)
|
||||
@@ -87,12 +87,12 @@ When the default home page structure (Hero + Features) doesn't meet the design r
|
||||
|
||||
```tsx
|
||||
// theme/components/HomeLayout/index.tsx
|
||||
import { useSite, useLang } from '@rspress/core/runtime';
|
||||
import { useSite, useLang } from "@rspress/core/runtime"
|
||||
|
||||
export function HomeLayout() {
|
||||
const site = useSite();
|
||||
const lang = useLang();
|
||||
const { title, description } = site.siteData;
|
||||
const site = useSite()
|
||||
const lang = useLang()
|
||||
const { title, description } = site.siteData
|
||||
|
||||
return (
|
||||
<div className="custom-home">
|
||||
@@ -100,10 +100,7 @@ export function HomeLayout() {
|
||||
<h1>{title}</h1>
|
||||
<p>{description}</p>
|
||||
<div className="hero-actions">
|
||||
<a
|
||||
href={lang === 'zh' ? '/zh/guide/start' : '/guide/start'}
|
||||
className="primary-btn"
|
||||
>
|
||||
<a href={lang === "zh" ? "/zh/guide/start" : "/guide/start"} className="primary-btn">
|
||||
Get Started
|
||||
</a>
|
||||
<a href="https://github.com/..." className="secondary-btn">
|
||||
@@ -116,14 +113,14 @@ export function HomeLayout() {
|
||||
{/* Custom content: testimonials, stats, demos, etc. */}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
export * from '@rspress/core/theme-original';
|
||||
export { HomeLayout } from './components/HomeLayout';
|
||||
export * from "@rspress/core/theme-original"
|
||||
export { HomeLayout } from "./components/HomeLayout"
|
||||
```
|
||||
|
||||
The named export overrides the built-in `HomeLayout` from the wildcard re-export — no need to eject first.
|
||||
@@ -134,16 +131,16 @@ If you only need to add content before/after the Hero or Features sections (with
|
||||
|
||||
```tsx
|
||||
// theme/components/DocFooter/index.tsx
|
||||
import { useFrontmatter } from '@rspress/core/runtime';
|
||||
import { useFrontmatter } from "@rspress/core/runtime"
|
||||
|
||||
export function DocFooter() {
|
||||
const frontmatter = useFrontmatter();
|
||||
const frontmatter = useFrontmatter()
|
||||
return (
|
||||
<footer className="custom-doc-footer">
|
||||
{frontmatter.author && <span>Author: {frontmatter.author}</span>}
|
||||
<a href="https://github.com/...">Edit this page</a>
|
||||
</footer>
|
||||
);
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -71,11 +71,11 @@ All examples below follow the same structure in `theme/index.tsx`. The key parts
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
||||
export * from '@rspress/core/theme-original';
|
||||
import { Layout as OriginalLayout } from "@rspress/core/theme-original"
|
||||
export * from "@rspress/core/theme-original"
|
||||
|
||||
export function Layout() {
|
||||
return <OriginalLayout beforeNavTitle={<MyLogo />} />;
|
||||
return <OriginalLayout beforeNavTitle={<MyLogo />} />
|
||||
}
|
||||
```
|
||||
|
||||
@@ -83,8 +83,8 @@ export function Layout() {
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
||||
export * from '@rspress/core/theme-original';
|
||||
import { Layout as OriginalLayout } from "@rspress/core/theme-original"
|
||||
export * from "@rspress/core/theme-original"
|
||||
|
||||
export function Layout() {
|
||||
return (
|
||||
@@ -93,7 +93,7 @@ export function Layout() {
|
||||
bottom={<footer>© 2025 My Company</footer>}
|
||||
afterOutline={<div>Related resources</div>}
|
||||
/>
|
||||
);
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -101,17 +101,17 @@ export function Layout() {
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
||||
import { useLang } from '@rspress/core/runtime';
|
||||
export * from '@rspress/core/theme-original';
|
||||
import { Layout as OriginalLayout } from "@rspress/core/theme-original"
|
||||
import { useLang } from "@rspress/core/runtime"
|
||||
export * from "@rspress/core/theme-original"
|
||||
|
||||
function LocalizedBanner() {
|
||||
const lang = useLang();
|
||||
return <div>{lang === 'zh' ? '欢迎' : 'Welcome'}</div>;
|
||||
const lang = useLang()
|
||||
return <div>{lang === "zh" ? "欢迎" : "Welcome"}</div>
|
||||
}
|
||||
|
||||
export function Layout() {
|
||||
return <OriginalLayout top={<LocalizedBanner />} />;
|
||||
return <OriginalLayout top={<LocalizedBanner />} />
|
||||
}
|
||||
```
|
||||
|
||||
@@ -121,17 +121,15 @@ The `components` slot accepts a `Record<string, React.ComponentType>` to overrid
|
||||
|
||||
```tsx
|
||||
// theme/index.tsx
|
||||
import { Layout as OriginalLayout } from '@rspress/core/theme-original';
|
||||
export * from '@rspress/core/theme-original';
|
||||
import { Layout as OriginalLayout } from "@rspress/core/theme-original"
|
||||
export * from "@rspress/core/theme-original"
|
||||
|
||||
function CustomH1({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<h1 style={{ borderBottom: '2px solid var(--rp-c-brand)' }}>{children}</h1>
|
||||
);
|
||||
return <h1 style={{ borderBottom: "2px solid var(--rp-c-brand)" }}>{children}</h1>
|
||||
}
|
||||
|
||||
export function Layout() {
|
||||
return <OriginalLayout components={{ h1: CustomH1 }} />;
|
||||
return <OriginalLayout components={{ h1: CustomH1 }} />
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user