diff --git a/pages/album/[slug].tsx b/pages/album/[slug].tsx index 66abe008..216cd1b9 100644 --- a/pages/album/[slug].tsx +++ b/pages/album/[slug].tsx @@ -1,6 +1,6 @@ import Head from 'next/head' 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' 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/pages/teacher/[person].tsx b/pages/teacher/[person].tsx index 8393ae9f..5ae2e39c 100644 --- a/pages/teacher/[person].tsx +++ b/pages/teacher/[person].tsx @@ -1,12 +1,12 @@ import Head from 'next/head' import { App } from 'src/components/App' -import Article from 'src/components/Article' +import { Article } from 'src/components/Article' import { Meta } from 'src/components/Meta' import menuModel from 'src/models/menu' import { buildMenu } from 'src/lib/menu' import { meta } from 'src/lib/meta' import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib' -import { NextPage, NextPageContext } from 'next' +import { NextPage } from 'next' import { IMeta } from 'src/types' import { Html } from 'src/components/Html' diff --git a/src/components/Article.js b/src/components/Article.js deleted file mode 100644 index 7e71c0bb..00000000 --- a/src/components/Article.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react' -import { dateFormat } from '../lib/date' -import { Share } from './Share' - -const Tag = ({ children }) => ( -
  • - {children} -
  • -) - -const TagList = ({ tags }) => ( - -) - -const Head = ({ date, tags = [], children }) => ( -
    -

    {children}

    - - {!date ? null : ( -

    {dateFormat(date)}

    - )} - - {!(tags.length) ? null : ( - - )} -
    -) - -const Article = ({ children, date, tags, title, shareable }) => ( -
    - - {title} - - -
    - {children} -
    - - {!shareable ? null : ( - - )} -
    -) - -export default Article diff --git a/src/components/Article/index.tsx b/src/components/Article/index.tsx new file mode 100644 index 00000000..92259602 --- /dev/null +++ b/src/components/Article/index.tsx @@ -0,0 +1,55 @@ +import { dateFormat } from 'src/lib/date' +import { Share } from '../Share' +import { TagList } from '../TagList' +import { ITag } from 'src/types' + +export type ArticleProps = { + date: string + title: string + tags: ITag[] + shareable: boolean +} + +type HeadProps = { + date: string + tags: ITag[] +} + +const Head: React.FC = ({ date, tags = [], children }) => ( +
    + + +

    {children}

    + + {!date ? null : ( +

    {dateFormat(date)}

    + )} + + {!tags.length ? null : ( + + )} +
    +) + +export const Article: React.FC = ({ children, date, tags, title, shareable }) => ( +
    + + {title} + + +
    + {children} +
    + + {!shareable ? null : ( + + )} +
    +) diff --git a/src/components/TagList/index.tsx b/src/components/TagList/index.tsx new file mode 100644 index 00000000..644ed604 --- /dev/null +++ b/src/components/TagList/index.tsx @@ -0,0 +1,27 @@ +import './styles.css' + +import { ITag } from 'src/types' +import { Button } from '../Button' + +export const Tag: React.FC<{ href: string }> = props => ( +
  • + +
  • +) + +export type TagListProps = { + items: ITag[] +} + +export const TagList: React.FC = props => ( +
      + {props.items.map(x => ( + + # {x.name} + + ))} +
    +) diff --git a/src/components/TagList/styles.css b/src/components/TagList/styles.css new file mode 100644 index 00000000..ba7c65ab --- /dev/null +++ b/src/components/TagList/styles.css @@ -0,0 +1,17 @@ +/* ELEMENTS */ + +.tags { + display: flex; + flex-direction: row; + /* justify-content: center; */ + + list-style: none; +} + +.tagsItem { + margin-right: var(--size-s); +} + +.tagsItem:last-child { + margin-right: 0; +} diff --git a/src/style/components/Article.scss b/src/style/components/Article.scss index 12fa83c1..f172e585 100644 --- a/src/style/components/Article.scss +++ b/src/style/components/Article.scss @@ -15,13 +15,7 @@ margin-bottom: var(--article-head-margin-bottom); } - .date { - text-align: center; - color: #aaa; - - margin-bottom: 1.25em; - } - } + } &-Body { --text-margin: 10px; diff --git a/src/style/components/ArticleTags.scss b/src/style/components/ArticleTags.scss deleted file mode 100644 index 9bdd2b65..00000000 --- a/src/style/components/ArticleTags.scss +++ /dev/null @@ -1,29 +0,0 @@ -.ArticleTags { - --article-card-width: 30%; - --article-card-margin: var(--single-margin) var(--half-margin); - - display: flex; - flex-direction: row; - justify-content: center; - - list-style: none; - - &-Item { - background: #99bde1; - padding: 3px 9px; - - font-size: 14px; - color: #393939; - - border-radius: 3px; - } - - &-Item { - margin-right: 0.5em; - - &:last-child { - margin-right: 0; - - } - } -} diff --git a/src/style/style.scss b/src/style/style.scss index 2e430ed0..b07dbb79 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -7,7 +7,6 @@ @import "components/footer-links"; @import "components/Article"; @import "components/album"; -@import "components/ArticleTags"; @import "content"; diff --git a/src/types.ts b/src/types.ts index b781be23..18df95f9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -31,8 +31,17 @@ export interface IImage { set: any // TODO } +export interface ITag { + name: string + slug: string + href: string +} + export interface IArticle { id: string + date: string + tags: ITag[] + post:string featured: boolean url: string title: string