index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { useCallback, useEffect, useMemo, useState } from 'react';
  6. import { LlmsContainer, LlmsCopyButton, LlmsViewOptions } from '@rspress/plugin-llms/runtime';
  7. import {
  8. HomeLayout as BaseHomeLayout,
  9. getCustomMDXComponent as basicGetCustomMDXComponent,
  10. } from '@rspress/core/theme';
  11. import { NoSSR, removeBase, useLocation, usePageData } from '@rspress/core/runtime';
  12. import { Background } from './components/background';
  13. import './theme.css';
  14. import { FlowGramLogo } from './components/logo';
  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 { pathname } = useLocation();
  33. const isZh = pathname.startsWith('/zh/');
  34. const { page } = usePageData();
  35. return (
  36. <>
  37. <div className="home-layout-container">
  38. <NoSSR>
  39. <Background />
  40. <FlowGramLogo />
  41. </NoSSR>
  42. <BaseHomeLayout {...props} afterHero={null} afterHeroActions={null} />
  43. </div>
  44. </>
  45. );
  46. }
  47. export { getCustomMDXComponent, HomeLayout };
  48. export * from '@rspress/core/theme';