index.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { LlmsContainer, LlmsCopyButton, LlmsViewOptions } from '@rspress/plugin-llms/runtime';
  6. import {
  7. HomeLayout as BaseHomeLayout,
  8. getCustomMDXComponent as basicGetCustomMDXComponent,
  9. } from '@rspress/core/theme';
  10. import { NoSSR, useDark } from '@rspress/core/runtime';
  11. import { Background } from './components/background';
  12. import './theme.css';
  13. import { FlowGramLogo } from './components/logo';
  14. function getCustomMDXComponent() {
  15. const { h1: H1, ...components } = basicGetCustomMDXComponent();
  16. const MyH1 = ({ ...props }) => (
  17. <>
  18. <H1 {...props} />
  19. <LlmsContainer>
  20. <LlmsCopyButton />
  21. <LlmsViewOptions />
  22. </LlmsContainer>
  23. </>
  24. );
  25. return {
  26. ...components,
  27. h1: MyH1,
  28. };
  29. }
  30. function HomeLayout(props: Parameters<typeof BaseHomeLayout>[0]) {
  31. const isDark = useDark();
  32. return (
  33. <>
  34. <div className="home-layout-container">
  35. <NoSSR>
  36. {isDark && <Background />}
  37. <FlowGramLogo />
  38. </NoSSR>
  39. <BaseHomeLayout {...props} afterHero={null} afterHeroActions={null} />
  40. </div>
  41. </>
  42. );
  43. }
  44. export { getCustomMDXComponent, HomeLayout };
  45. export * from '@rspress/core/theme';