From 5e23c201303ab77f387e1ca2942539386d4fa191 Mon Sep 17 00:00:00 2001 From: Ma Jun <64419837+leizzboy@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:58:49 +0800 Subject: [PATCH] fix bugs of #309 and #310 (#313) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- website/docusaurus.config.js | 2 +- website/src/theme/MDXComponents/Image.tsx | 28 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 0f6bd08a3..1df945993 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -63,7 +63,7 @@ const config = { if(locale !== 'en') { return `https://github.com/stoneatom/stonedb/edit/stonedb-5.7/website/i18n/${locale}/docusaurus-plugin-content-docs/current/${docPath}` } - return `https://github.com/stoneatom/stonedb/edit/stonedb-5.7/${versionDocsDirPath}/${docPath}` + return `https://github.com/stoneatom/stonedb/edit/stonedb-5.7/Docs/${docPath}` }, }, theme: { diff --git a/website/src/theme/MDXComponents/Image.tsx b/website/src/theme/MDXComponents/Image.tsx index 739716564..bae6ecc8e 100644 --- a/website/src/theme/MDXComponents/Image.tsx +++ b/website/src/theme/MDXComponents/Image.tsx @@ -1,18 +1,34 @@ import React from 'react'; -import {pipe, split, map, fromPairs, trim, isEmpty} from 'ramda'; +import {pipe, split, map, fromPairs, trim, isEmpty, is} from 'ramda'; import {Image, OmitText} from '@site/src/components'; import {modifyKeyName} from '@site/src/utils'; export default function MDXImage({className, alt, src, title, ...props}: any): JSX.Element { - const data = title && title.indexOf(':') >= 0 ? pipe( + const isCustomImg = title && title.indexOf(':') >= 0; + const data = isCustomImg ? pipe( split(','), map(split(':')), fromPairs, modifyKeyName(trim) )(title) : title ? {title} : {}; return ( - {alt} - {data.title} - + <> + { + isCustomImg ? ( + {alt} + {data.title} + + ) : ( + {alt} + ) + } + ) -} +} \ No newline at end of file