From e9bbf39618e6af5ee13cbedfb6bd2bb71c294db8 Mon Sep 17 00:00:00 2001 From: Jakub Mieszczak <138759018+jakubmieszczak@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:51:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20feat:=20Markdown=20support=20for?= =?UTF-8?q?=20Custom=20Footer=20links=20(#2960)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add markdown support for custom footer links * fix: Update Footer component with revised ReactMarkdown props * fix: Adjusted footer links and pipe styles for consistent appearance * refactor: remove unused footer.tsx file --- client/src/components/Chat/Footer.tsx | 51 ++++++++++++++++++-------- client/src/components/Input/Footer.tsx | 23 ------------ 2 files changed, 35 insertions(+), 39 deletions(-) delete mode 100644 client/src/components/Input/Footer.tsx diff --git a/client/src/components/Chat/Footer.tsx b/client/src/components/Chat/Footer.tsx index cca7d9a7cf..0e62eb195d 100644 --- a/client/src/components/Chat/Footer.tsx +++ b/client/src/components/Chat/Footer.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import ReactMarkdown from 'react-markdown'; import { Constants } from 'librechat-data-provider'; import { useGetStartupConfig } from 'librechat-data-provider/react-query'; import { useLocalize } from '~/hooks'; @@ -32,22 +33,40 @@ export default function Footer({ className }: { className?: string }) { ); - const mainContentRender = ( - - {typeof config?.customFooter === 'string' ? ( - config.customFooter - ) : ( - <> - - {config?.appTitle || 'LibreChat'} {Constants.VERSION} - - {' - '} {localize('com_ui_new_footer')} - - )} - - ); + const mainContentParts = ( + typeof config?.customFooter === 'string' + ? config.customFooter + : '[](https://librechat.ai) - ' + + localize('com_ui_pay_per_call') + ).split('|'); - const footerElements = [mainContentRender, privacyPolicyRender, termsOfServiceRender].filter( + const mainContentRender = mainContentParts.map((text, index) => ( + + { + const { ['node']: _, href, ...otherProps } = props; + return ( + + ); + }, + p: ({ node, ...props }) => , + }} + > + {text.trim()} + + + )); + + const footerElements = [...mainContentRender, privacyPolicyRender, termsOfServiceRender].filter( Boolean, ); @@ -55,7 +74,7 @@ export default function Footer({ className }: { className?: string }) {
{footerElements.map((contentRender, index) => { diff --git a/client/src/components/Input/Footer.tsx b/client/src/components/Input/Footer.tsx deleted file mode 100644 index c5fabecc66..0000000000 --- a/client/src/components/Input/Footer.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Constants } from 'librechat-data-provider'; -import { useGetStartupConfig } from 'librechat-data-provider/react-query'; -import { useLocalize } from '~/hooks'; - -export default function Footer() { - const { data: config } = useGetStartupConfig(); - const localize = useLocalize(); - - return ( -
- {typeof config?.customFooter === 'string' ? ( - config.customFooter - ) : ( - <> - - {config?.appTitle || 'LibreChat'} {Constants.VERSION} - - {' - '}. {localize('com_ui_pay_per_call')} - - )} -
- ); -}