Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Post): Implement asset cover feature #124

Merged
merged 5 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demo/pages/_posts/my-first-post.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: My First Post
layout: post
assets:
cover: "./my-first-post.png"
date: 2019-05-26 20:23:00
tags:
- life
Expand Down
Binary file added demo/pages/_posts/my-first-post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 18 additions & 9 deletions packages/saber-theme-portfolio/src/components/PostCard.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<template>
<saber-link class="card post" :to="post.attributes.permalink">
<div class="post-title">
{{ post.attributes.title }}
<saber-link class="post post-card" :to="post.attributes.permalink">
<div v-if="post.attributes.assets.cover" class="post-cover">
<img
class="post-cover__image"
:src="post.attributes.assets.cover"
alt="cover"
/>
</div>
<div class="card">
<div class="post-title">
{{ post.attributes.title }}
</div>
<div
class="post-excerpt"
:class="{ 'fixed-height': fixedExcerptHeight }"
v-html="getExcerpt(post.excerpt)"
/>
<PostMeta :attributes="post.attributes" />
</div>
<div
class="post-excerpt"
:class="{ 'fixed-height': fixedExcerptHeight }"
v-html="getExcerpt(post.excerpt)"
/>
<PostMeta :attributes="post.attributes" />
</saber-link>
</template>

Expand Down
22 changes: 21 additions & 1 deletion packages/saber-theme-portfolio/src/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ a {
}
}

.post-cover {
overflow: hidden;
width: 100%;
margin-bottom: 30px;
border-radius: 3px;
align-content: center;
display: flex;
}

.post-card .post-cover {
height: 250px;
border-radius: 3px 3px 0 0;
margin-bottom: 0;
}

.post-cover .post-cover__image {
width: 100%;
object-fit: cover;
}

.page-title {
font-size: 3rem;
font-weight: 400;
Expand Down Expand Up @@ -150,4 +170,4 @@ a {
&:hover {
box-shadow: inset 0 0 0 1px var(--border-color);
}
}
}
73 changes: 45 additions & 28 deletions packages/saber-theme-portfolio/src/layouts/post.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
<template>
<div class="wrap">
<saber-link to="/" class="back-home"> <CornerUpLeftIcon />Home </saber-link>
<div class="container">
<div class="columns post-columns">
<div class="column is-6 is-offset-3">
<div class="page-title post-title">
{{ page.attributes.title }}
</div>
<PostMeta :attributes="page.attributes" />
<div class="page-content">
<slot name="default" />
</div>
<div v-if="page.tagsInfo" class="post-tags">
<saber-link
v-for="tag in page.tagsInfo"
:key="tag.permalink"
:to="tag.permalink"
class="post-tag"
<div>
<div class="wrap">
<saber-link to="/" class="back-home">
<CornerUpLeftIcon />Home
</saber-link>
<div class="container">
<div class="columns post-columns">
<div class="column is-6 is-offset-3">
<div
v-if="
page.attributes.assets.cover &&
$themeConfig.coverLayout === 'minimal'
"
class="post-cover post-cover-minimal"
>
<HashIcon />
{{ tag.name }}
</saber-link>
<img
class="post-cover__image"
:src="page.attributes.assets.cover"
alt="cover"
/>
</div>
<div class="page-title post-title">
{{ page.attributes.title }}
</div>
<PostMeta :attributes="page.attributes" />
<div class="page-content">
<slot name="default" />
</div>
<div v-if="page.tagsInfo" class="post-tags">
<saber-link
v-for="tag in page.tagsInfo"
:key="tag.permalink"
:to="tag.permalink"
class="post-tag"
>
<HashIcon />
{{ tag.name }}
</saber-link>
</div>
<Disqus
v-if="page.attributes.comments !== false && $themeConfig.disqus"
class="post-comments"
:url="$siteConfig.url"
:permalink="page.attributes.permalink"
:shortname="$themeConfig.disqus"
/>
</div>
<Disqus
v-if="page.attributes.comments !== false && $themeConfig.disqus"
class="post-comments"
:url="$siteConfig.url"
:permalink="page.attributes.permalink"
:shortname="$themeConfig.disqus"
/>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/saber-theme-portfolio/src/saber-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exports.beforePlugins = async function() {
)
this.config.themeConfig = Object.assign(
{
coverLayout: 'minimal',
hireable: userResult.data.hireable,
profilePicture: userResult.data.avatar_url
},
Expand Down