|
1 | 1 | <script lang="ts"> |
2 | 2 | import { onMount } from 'svelte'; |
| 3 | + import { page } from '$app/stores'; |
3 | 4 |
|
4 | 5 | import Button from '$lib/components/atoms/Button.svelte'; |
5 | | - import RelatedPostCard from '$lib/components/molecules/RelatedPostCard.svelte'; |
6 | 6 | import ContentSection from '$lib/components/organisms/ContentSection.svelte'; |
7 | 7 | import type { BlogPost } from '$lib/utils/types'; |
| 8 | + import BlogPreview from '$lib/components/molecules/BlogPreview.svelte'; |
8 | 9 |
|
9 | 10 | export let data: { |
10 | 11 | posts: BlogPost[]; |
|
17 | 18 | let numberOfPosts: number | undefined; |
18 | 19 |
|
19 | 20 | onMount(() => { |
20 | | - currentUrl = window.location.href; |
| 21 | + currentUrl = $page.url.pathname; |
21 | 22 | splitUrl = currentUrl.split('/').pop(); |
22 | 23 |
|
23 | | - numberOfPosts = posts.filter((post) => post.contributorSlug === splitUrl).length; |
| 24 | + numberOfPosts = posts.filter((post) => post.meta.contributorSlug === splitUrl).length; |
24 | 25 | }); |
25 | 26 | </script> |
26 | 27 |
|
|
31 | 32 | <ContentSection title="All Blog Posts"> |
32 | 33 | <div class="grid"> |
33 | 34 | {#each posts as post} |
34 | | - {#if post.contributorSlug === splitUrl} |
35 | | - <RelatedPostCard |
36 | | - title={post.title} |
37 | | - excerpt={post.excerpt} |
38 | | - readingTime={post.readingTime} |
39 | | - slug={post.slug} |
40 | | - tags={post.tags} |
41 | | - date={post.date} |
42 | | - /> |
43 | | - {/if} |
| 35 | + <a href={post.path}> |
| 36 | + <BlogPreview post_data={post.meta} /> |
| 37 | + </a> |
44 | 38 | {/each} |
45 | 39 | </div> |
46 | 40 | </ContentSection> |
|
61 | 55 |
|
62 | 56 | <style lang="scss"> |
63 | 57 | @import '$lib/scss/_mixins.scss'; |
| 58 | + @import '$lib/scss/_breakpoints.scss'; |
64 | 59 |
|
65 | 60 | .container { |
66 | 61 | background: rgba(26, 26, 26, 1); |
67 | 62 | color: rgba(245, 245, 245, 0.96); |
68 | 63 | } |
69 | 64 |
|
70 | 65 | .grid { |
71 | | - width: 100%; |
| 66 | + padding-top: 3rem; |
72 | 67 | display: grid; |
73 | | - grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; |
74 | | - grid-gap: 20px; |
| 68 | + grid-template-columns: 1fr 1fr; |
| 69 | + grid-gap: 24px; |
| 70 | + max-width: 1200px; |
| 71 | + margin: 0 auto; |
75 | 72 |
|
76 | | - @include for-tablet-portrait-down { |
| 73 | + @include for-phone-only { |
77 | 74 | grid-template-columns: 1fr; |
78 | 75 | } |
79 | 76 |
|
80 | 77 | @include for-tablet-landscape-up { |
81 | | - // Select every 6 elements, starting from position 1 |
82 | | - // And make it take up 6 columns |
83 | | - > :global(:nth-child(6n + 1)) { |
84 | | - grid-column: span 6; |
85 | | - } |
86 | | - // Select every 6 elements, starting from position 2 |
87 | | - // And make it take up 3 columns |
88 | | - > :global(:nth-child(6n + 2)) { |
89 | | - grid-column: span 3; |
90 | | - } |
91 | | - // Select every 6 elements, starting from position 3 |
92 | | - // And make it take up 3 columns |
93 | | - > :global(:nth-child(6n + 3)) { |
94 | | - grid-column: span 3; |
95 | | - } |
96 | | - // Select every 6 elements, starting from position 4, 5 and 6 |
97 | | - // And make it take up 2 columns |
98 | | - > :global(:nth-child(6n + 4)), |
99 | | - :global(:nth-child(6n + 5)), |
100 | | - :global(:nth-child(6n + 6)) { |
101 | | - grid-column: span 2; |
102 | | - } |
| 78 | + grid-template-columns: 1fr 1fr; |
| 79 | + } |
| 80 | +
|
| 81 | + @include for-desktop-up { |
| 82 | + grid-template-columns: 1fr 1fr 1fr; |
103 | 83 | } |
104 | 84 | } |
105 | 85 |
|
|
0 commit comments