2
0

index.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import { useIsMobile } from './use-is-mobile';
  15. function getCustomMDXComponent() {
  16. const { h1: H1, ...components } = basicGetCustomMDXComponent();
  17. const MyH1 = ({ ...props }) => (
  18. <>
  19. <H1 {...props} />
  20. <LlmsContainer>
  21. <LlmsCopyButton />
  22. <LlmsViewOptions />
  23. </LlmsContainer>
  24. </>
  25. );
  26. return {
  27. ...components,
  28. h1: MyH1,
  29. };
  30. }
  31. function HomeLayout(props: Parameters<typeof BaseHomeLayout>[0]) {
  32. const isDark = useDark();
  33. const isMobile = useIsMobile();
  34. return (
  35. <>
  36. <div className="home-layout-container">
  37. <NoSSR>
  38. {isDark && !isMobile && <Background />}
  39. <FlowGramLogo />
  40. </NoSSR>
  41. <BaseHomeLayout {...props} afterHero={null} afterHeroActions={null} />
  42. </div>
  43. </>
  44. );
  45. }
  46. export { getCustomMDXComponent, HomeLayout };
  47. export * from '@rspress/core/theme';