diff --git a/react/GettingStartedArticle.tsx b/react/GettingStartedArticle.tsx index 0c72287..046b2e4 100644 --- a/react/GettingStartedArticle.tsx +++ b/react/GettingStartedArticle.tsx @@ -7,11 +7,12 @@ import { useRuntime, withRuntimeContext, NoSSR, + Link, } from 'vtex.render-runtime' import Footer from './components/Footer' import SideBar from './components/SideBar' -import GettingStartedArticlesRenderer from './components/GettingStartedArticleRenderer' +import DocsRenderer from './components/DocsRenderer' import favicon from './images/favicon.png' import Skeleton from './components/Skeleton' import EmptyDocs from './components/EmptyDocs' @@ -28,6 +29,10 @@ const GettingStartedArticle: FunctionComponent = ({ const articles = GettingStartedArticlesQuery.gettingStartedArticles + const currentArticle: number = Number.parseInt( + useRuntime().route.params.article + ) + return ( @@ -68,11 +73,25 @@ const GettingStartedArticle: FunctionComponent = ({ } = data return ( - + + +
+ {hasPrevArticle(currentArticle) && ( + + Previous article + + )} + {hasNextArticle(articles, currentArticle) && ( + + Next article + + )} +
+
) }} @@ -91,6 +110,18 @@ interface MetaData { git: string } +function hasNextArticle( + articleList: Record, + currentArticle: number +) { + const numberOfArticles = Object.keys(articleList).length + return currentArticle < numberOfArticles +} + +function hasPrevArticle(currentArticle: number) { + return currentArticle > 1 +} + export default compose( withRuntimeContext, graphql(GettingStartedArticles.default, { diff --git a/react/components/GettingStartedArticleRenderer.tsx b/react/components/GettingStartedArticleRenderer.tsx deleted file mode 100644 index 4508b19..0000000 --- a/react/components/GettingStartedArticleRenderer.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import React, { FunctionComponent } from 'react' -import ReactMarkdown from 'react-markdown' -import { FormattedMessage } from 'react-intl' -import { Link, useRuntime } from 'vtex.render-runtime' - -import { CustomRenderers } from './CustomTags' - -const GettingStartedArticleRenderer: FunctionComponent = ({ - markdown, - meta, - articleList, -}) => { - const currentArticle: number = Number.parseInt( - useRuntime().route.params.article - ) - - return ( -
- - {meta.git && ( - - - - )} -
- {hasPrevArticle(currentArticle) && ( - - Previous article - - )} - {hasNextArticle(articleList, currentArticle) && ( - - Next article - - )} -
-
- ) -} - -interface MetaData { - title: string - description: string - tags: string[] - version: string - git: string -} - -interface Props { - markdown: string - meta: MetaData - articleList: Record -} - -function hasNextArticle( - articleList: Record, - currentArticle: number -) { - const numberOfArticles = Object.keys(articleList).length - return currentArticle < numberOfArticles -} - -function hasPrevArticle(currentArticle: number) { - return currentArticle > 1 -} - -export default GettingStartedArticleRenderer