Skip to content

Commit

Permalink
feat: add image component, update article-list component
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Sep 4, 2018
1 parent e2e76bb commit f1112ef
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
33 changes: 27 additions & 6 deletions _includes/article-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,32 @@
{%- for _article in _sorted_list -%}

{%- include snippets/prepend-baseurl.html path=_article.url -%}
{%- assign _href = __return -%}
{%- assign _article_url = __return -%}

{%- include snippets/locale-to-string.html locale=site.data.locale.READMORE -%}
{%- assign _locale_readmore = __return -%}

{%- if include.type == 'common' -%}
<article class="item" itemscope itemtype="http://schema.org/BlogPosting">
{%- if include.article_type == 'BlogPosting' -%}
<article class="item" itemscope itemtype="http://schema.org/BlogPosting">
{%- else -%}
<article class="item">
{%- endif -%}
{%- if _article.cover and include.show_cover-%}
{%- include snippets/get-nav-url.html path=_article.cover -%}
{%- assign _article_cover = __return -%}
<div class="item__image">
{%- if include.cover_size == 'lg' -%}
<img class="image image--lg" src="{{ _article_cover }}" />
{%- elsif include.cover_size == 'sm' -%}
<img class="image image--sm" src="{{ _article_cover }}" />
{%- else -%}
<img class="image" src="{{ _article_cover }}" />
{%- endif -%}
</div>
{%- endif -%}
<div class="item__content">
<header><h2 itemprop="headline" class="item__header"><a href="{{ _href }}">{{ _article.title }}</a></h2></header>
<header><h2 itemprop="headline" class="item__header"><a href="{{ _article_url }}">{{ _article.title }}</a></h2></header>
<div class="item__description">
{%- if _article.excerpt and include.show_excerpt -%}
<div class="article__content" itemprop="description articleBody">
Expand All @@ -38,9 +55,13 @@
{%- endif -%}
</div>
{%- endif -%}
<p><a href="{{ _href }}">{{ _locale_readmore }}</a></p>
{%- if include.show_readmore -%}
<p><a href="{{ _article_url }}">{{ _locale_readmore }}</a></p>
{%- endif -%}
</div>
{%- include article-info.html article=_article show_pageview=true -%}
{%- if include.show_info -%}
{%- include article-info.html article=_article show_pageview=true -%}
{%- endif -%}
</div>
</article>

Expand All @@ -65,7 +86,7 @@
{%- endif -%}
{%- include snippets/locale-to-string.html locale=site.data.locale.ARTICLE_LIST_DATE_FORMAT -%}
<li class="item" itemscope itemtype="http://schema.org/BlogPosting" data-tags="{{ _tags }}">
<div class="item__content"><span class="item__meta">{{ _article.date | date: __return }}</span><a itemprop="headline" class="item__header" href="{{ _href }}">{{ _article.title }}</a></div>
<div class="item__content"><span class="item__meta">{{ _article.date | date: __return }}</span><a itemprop="headline" class="item__header" href="{{ _article_url }}">{{ _article.title }}</a></div>
</li>
{%- endif -%}

Expand Down
3 changes: 2 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
show_title: false
---
<div class="layout--home">
{%- include article-list.html articles=paginator.posts type='common' show_excerpt=true excerpt_type=site.excerpt_type -%}
{%- include article-list.html articles=paginator.posts type='common' article_type='BlogPosting'
show_excerpt=true excerpt_type=site.excerpt_type show_readmore=true show_info=true -%}
{%- include paginator.html -%}
</div>
<script>
Expand Down
8 changes: 8 additions & 0 deletions _sass/common/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ $button: (
transition: all .2s ease-in-out
);

$image: (
width-xl: 20em,
width-lg: 16rem,
width: 12rem,
width-sm: 8rem,
width-xs: 4rem
);

$menu: (
horizontal-spacer: 1,
horizontal-item-vertical-spacer: 1
Expand Down
19 changes: 19 additions & 0 deletions _sass/common/components/_image.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.image {
max-width: 100%;
@extend .image--md;
}
.image--xl {
width: map-get($image, width-xl);
}
.image--lg {
width: map-get($image, width-lg);
}
.image--md {
width: map-get($image, width);
}
.image--sm {
width: map-get($image, width-sm);
}
.image--xs {
width: map-get($image, width-xs);
}
4 changes: 2 additions & 2 deletions _sass/common/components/_item.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.item {
@include flexbox();
@include media-breakpoint-down(md) {
@include flex-direction(row);
@include flex-direction(column);
}
&:not(:last-child) {
margin-bottom: map-get($base, vertical-space);
Expand All @@ -18,7 +18,7 @@

.item__content {
@include flex(1);
max-width: 100%;
min-width: 0;
}

.item__header {
Expand Down
1 change: 1 addition & 0 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"common/classes",
"common/reset",
"common/components/button",
"common/components/image",
"common/components/card",
"common/components/hero",
"common/components/menu",
Expand Down

0 comments on commit f1112ef

Please sign in to comment.