FullTextSearchNotCoverAlert.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { JSX } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useSWRxCurrentPage } from '~/stores/page';
  4. import { useElasticsearchMaxBodyLengthToIndex } from '~/stores-universal/context';
  5. export const FullTextSearchNotCoverAlert = (): JSX.Element => {
  6. const { t } = useTranslation();
  7. const { data: elasticsearchMaxBodyLengthToIndex } =
  8. useElasticsearchMaxBodyLengthToIndex();
  9. const { data } = useSWRxCurrentPage();
  10. const markdownLength = data?.revision?.body?.length;
  11. if (
  12. markdownLength == null ||
  13. elasticsearchMaxBodyLengthToIndex == null ||
  14. markdownLength <= elasticsearchMaxBodyLengthToIndex
  15. ) {
  16. return <></>;
  17. }
  18. return (
  19. <div className="alert alert-warning">
  20. <strong>
  21. {t('Warning')}: {t('page_page.notice.not_indexed1')}
  22. </strong>
  23. <br />
  24. <small
  25. // biome-ignore lint/security/noDangerouslySetInnerHtml: ignore
  26. dangerouslySetInnerHTML={{
  27. __html: t('page_page.notice.not_indexed2', {
  28. threshold: `<code>ELASTICSEARCH_MAX_BODY_LENGTH_TO_INDEX=${elasticsearchMaxBodyLengthToIndex}</code>`,
  29. }),
  30. }}
  31. />
  32. </div>
  33. );
  34. };