Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"preview": "rspress preview"
},
"dependencies": {
"rspress": "^2.0.0-beta.18",
"rspress": "^2.0.0-beta.21",
"@callstack/rspress-theme": "workspace:*"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The theme uses **Alliance No. 2** as the header font family. This is a licensed
3. **Link the styles in your Rspress config** by adding the `globalStyles` option:

```ts
import { defineConfig } from '@rspress/shared';
import { defineConfig } from 'rspress/core';
import { pluginCallstackTheme } from '@callstack/rspress-theme/plugin';

export default defineConfig({
Expand All @@ -63,7 +63,7 @@ To use the `rspress-theme` package, you need to add the plugin to the Rspress co
In your `rspress.config.ts` file, import `pluginCallstackTheme` from `@callstack/rspress-theme/plugin` and add it to the plugins array:

```ts
import { defineConfig } from '@rspress/shared';
import { defineConfig } from 'rspress/core';
import { pluginCallstackTheme } from '@callstack/rspress-theme/plugin';

export default defineConfig({
Expand Down
5 changes: 3 additions & 2 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"react": "^19.0.0"
"react": "^19.0.0",
"rspress": "^2.0.0-beta.21"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.52.8",
Expand All @@ -55,10 +56,10 @@
"@rsbuild/plugin-sass": "^1.3.3",
"@rsbuild/plugin-svgr": "^1.2.1",
"@rslib/core": "^0.10.5",
"@rspress/shared": "^2.0.0-beta.18",
"@types/node": "^22",
"@types/react": "^19",
"react": "^19",
"rspress": "^2.0.0-beta.21",
"typescript": "^5.8.3"
}
}
2 changes: 1 addition & 1 deletion packages/theme/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const themeConfig: LibConfig = {
},
output: {
distPath: { root: './dist' },
externals: ['@runtime', '@theme', '@shared'],
externals: ['@theme'],
target: 'web',
},
plugins: [pluginImageCompress(), pluginReact(), pluginSass(), pluginSvgr()],
Expand Down
11 changes: 1 addition & 10 deletions packages/theme/src/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { RspressPlugin, UserConfig } from '@rspress/shared';
import type { RspressPlugin, UserConfig } from 'rspress/core';

const dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -49,14 +49,5 @@ export function pluginCallstackTheme(): RspressPlugin {
},
// inject style overrides
globalStyles: path.join(path.dirname(dirname), 'styles/styles.css'),
// add aliases for runtime and shared
builderConfig: {
resolve: {
alias: {
'@runtime': '@rspress/core/runtime',
'@shared': '@rspress/shared',
},
},
},
};
}
2 changes: 1 addition & 1 deletion packages/theme/src/theme/components/announcement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NoSSR } from '@runtime';
import { useState } from 'react';
import { NoSSR } from 'rspress/runtime';
import IconClose from './close.svg?react';
import styles from './index.module.scss';

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/theme/components/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDark } from '@runtime';
import { Link } from '@theme';
import * as React from 'react';
import { useDark } from 'rspress/runtime';
import IconArrowBarRight from './arrow-bar-right.svg?react';
import IconCorner from './corner-down-right.svg?react';
import styles from './index.module.scss';
Expand Down
9 changes: 6 additions & 3 deletions packages/theme/src/theme/components/home-feature/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Feature, FrontMatterMeta } from '@rspress/shared';
import { normalizeHrefInRuntime, withBase } from '@runtime';
import { isExternalUrl } from '@shared';
import {
isExternalUrl,
normalizeHrefInRuntime,
withBase,
} from 'rspress/runtime';
import type { Feature, FrontMatterMeta } from '../../types';
import { renderHtmlOrText } from '../../utils';
import styles from './index.module.scss';

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/theme/components/home-footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePageData } from '@runtime';
import { Link, SocialLinks } from '@theme';
import { usePageData } from 'rspress/runtime';
import CKLogoDark from './ck-logo-dark.svg?react';
import CKLogoLight from './ck-logo-light.svg?react';
import styles from './index.module.scss';
Expand Down
15 changes: 9 additions & 6 deletions packages/theme/src/theme/components/home-hero/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { FrontMatterMeta } from '@rspress/shared';
import { normalizeHrefInRuntime, normalizeImagePath, withBase } from '@runtime';
import { isExternalUrl } from '@shared';
import {
isExternalUrl,
normalizeHrefInRuntime,
normalizeImagePath,
withBase,
} from 'rspress/runtime';
import type { FrontMatterMeta, Hero } from '../../types';
import { renderHtmlOrText } from '../../utils';
import { Button } from '../button';
import styles from './index.module.scss';
Expand All @@ -11,7 +15,7 @@ const DEFAULT_HERO = {
tagline: '',
actions: [],
image: undefined,
} satisfies FrontMatterMeta['hero'];
} satisfies Hero;

interface HomeHeroProps {
frontmatter: FrontMatterMeta;
Expand All @@ -24,7 +28,6 @@ function HomeHero({
beforeHeroActions,
afterHeroActions,
frontmatter,
routePath,
}: HomeHeroProps) {
const hero = frontmatter.hero ?? DEFAULT_HERO;
const imageSrc =
Expand Down Expand Up @@ -67,7 +70,7 @@ function HomeHero({
{hero.actions.map((action) => {
const link = isExternalUrl(action.link)
? action.link
: normalizeHrefInRuntime(withBase(action.link, routePath));
: normalizeHrefInRuntime(withBase(action.link));

return (
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePageData } from '@runtime';
import { Badge } from '@theme';
import { usePageData } from 'rspress/runtime';

interface VersionBadgeProps {
version?: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/theme/src/theme/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ declare module '*.avif' {

// rspress aliases
declare module '@theme';
declare module '@runtime';
declare module '@shared';
48 changes: 48 additions & 0 deletions packages/theme/src/theme/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export interface Hero {
name: string;
text: string;
tagline: string;
image?: {
src: string | { dark: string; light: string };
alt: string;
/**
* `srcset` and `sizes` are attributes of `<img>` tag. Please refer to https://mdn.io/srcset for the usage.
* When the value is an array, rspress will join array members with commas.
**/
sizes?: string | string[];
srcset?: string | string[];
};
actions: {
text: string;
link: string;
theme: 'brand' | 'alt';
}[];
}

export interface Feature {
icon: string;
title: string;
details: string;
span?: number;
link?: string;
}

export type PageType = 'home' | 'doc' | 'custom' | '404' | 'blank';

export interface FrontMatterMeta {
title?: string;
description?: string;
overview?: boolean;
pageType?: PageType;
features?: Feature[];
hero?: Hero;
sidebar?: boolean;
outline?: boolean;
lineNumbers?: boolean;
overviewHeaders?: number[];
titleSuffix?: string;
head?: [string, Record<string, string>][];
context?: string;
footer?: boolean;
[key: string]: unknown;
}
Loading