diff --git a/src/components/Article.js b/src/components/Article.js index 3a3b1c59..0dcfbecd 100644 --- a/src/components/Article.js +++ b/src/components/Article.js @@ -2,13 +2,31 @@ const React = require('react') const getHtml = require('../lib/component').getHtml const dateFormat = require('../lib/date').dateFormat -const Head = ({date, children}) => ( +const Tag = ({children}) => ( +
  • + {children} +
  • +) + +const TagList = ({tags}) => ( + +) + +const Head = ({date, tags, children}) => (

    {children}

    {!date ? null : (

    {dateFormat(date)}

    )} + + {!tags.length ? null : ( + + )}
    ) @@ -21,14 +39,17 @@ const Share = () => ( ) -const Article = ({children, data, url, title, date, shareable}) => ( +const Article = ({children, article, shareable}) => (
    - - {title} + + {article.title}
    - {children || getHtml(data)} + {children || getHtml(article.post)}
    {!shareable ? null : ( diff --git a/src/core/Article.js b/src/core/Article.js index 3090a5a0..7336dc91 100644 --- a/src/core/Article.js +++ b/src/core/Article.js @@ -5,6 +5,10 @@ const {find, findOne, total} = require('../lib/store') const store = () => Data.getStore(Article) +function make(C) { + return x => new C(x) +} + class Article { static async find(query, options = {}) { const items = await find(store(), query, options) @@ -41,7 +45,7 @@ class Article { this.date = data.date this.title = data.title this.until = data.until - this.tags = data.tags + this.tags = (data.tags || []).map(make(Tag)) this.content = data.content this.hash = data.hash this.type = data.type @@ -75,6 +79,12 @@ class Article { } } +class Tag { + constructor(tag) { + this.name = tag; + } +} + const previewFromImage = (imgs = []) => imgs.length ? imgs[0] : null diff --git a/src/render/articles.js b/src/render/articles.js index 35bc7f08..85db6637 100644 --- a/src/render/articles.js +++ b/src/render/articles.js @@ -112,9 +112,7 @@ async function renderArticle(id) { const Component = (
    diff --git a/src/style/components/ArticleTags.scss b/src/style/components/ArticleTags.scss new file mode 100644 index 00000000..cebdb74f --- /dev/null +++ b/src/style/components/ArticleTags.scss @@ -0,0 +1,31 @@ +@import "../variables"; + +.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 c652ab9b..4a9f1a14 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -22,6 +22,7 @@ @import "components/ArticleCard"; @import "components/ArticleCardList"; +@import "components/ArticleTags"; @import "components/CollectiveImage"; @import "components/PersonCard"; @import "components/PersonCardList";