From 65507c5d800cf402d301fc8a0349a6f1a044435f Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 21 Feb 2020 04:26:48 +0300 Subject: [PATCH] article tags refactoring --- pages/article/[slug].tsx | 5 +++-- src/components/Article/index.tsx | 32 +++++++++++++-------------- src/components/TagList/index.tsx | 27 ++++++++++++++++++++++ src/components/TagList/styles.css | 17 ++++++++++++++ src/style/components/ArticleTags.scss | 29 ------------------------ src/style/style.scss | 1 - src/types.ts | 7 ++++++ 7 files changed, 70 insertions(+), 48 deletions(-) create mode 100644 src/components/TagList/index.tsx create mode 100644 src/components/TagList/styles.css delete mode 100644 src/style/components/ArticleTags.scss diff --git a/pages/article/[slug].tsx b/pages/article/[slug].tsx index b713f1c6..81bc1e11 100644 --- a/pages/article/[slug].tsx +++ b/pages/article/[slug].tsx @@ -1,7 +1,7 @@ import Head from 'next/head' import { get } from 'lodash' import { App } from 'src/components/App' -import Article from 'src/components/Article' +import { Article } from 'src/components/Article' import { Html } from 'src/components/Html' import menuModel from 'src/models/menu' import { buildMenu } from 'src/lib/menu' @@ -9,11 +9,12 @@ import { Meta } from 'src/components/Meta' import { meta } from 'src/lib/meta' import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib' import { NextPage } from 'next' +import { IArticle } from 'src/types' type Props = { pageUrl: string meta: any - data: any //(article) + data: IArticle } const Page: NextPage = props => { diff --git a/src/components/Article/index.tsx b/src/components/Article/index.tsx index 0be499cc..92259602 100644 --- a/src/components/Article/index.tsx +++ b/src/components/Article/index.tsx @@ -1,21 +1,21 @@ import { dateFormat } from 'src/lib/date' import { Share } from '../Share' +import { TagList } from '../TagList' +import { ITag } from 'src/types' -const Tag = ({ children }) => ( -
  • - {children} -
  • -) +export type ArticleProps = { + date: string + title: string + tags: ITag[] + shareable: boolean +} -const TagList = ({ tags }) => ( - -) +type HeadProps = { + date: string + tags: ITag[] +} -const Head = ({ date, tags = [], children }) => ( +const Head: React.FC = ({ date, tags = [], children }) => (