|
1 |
| -<script> |
2 |
| - export let data; |
| 1 | +<script lang="ts"> |
| 2 | + import Byline from './Byline.svelte'; |
| 3 | +
|
| 4 | + let { data } = $props(); |
| 5 | +
|
| 6 | + const featured = data.posts.filter((post) => !post.metadata.title.startsWith('What’s new')); |
| 7 | + const whats_new = data.posts.filter((post) => post.metadata.title.startsWith('What’s new')); |
| 8 | + const top = data.posts[0]; |
3 | 9 | </script>
|
4 | 10 |
|
5 | 11 | <svelte:head>
|
|
17 | 23 | </svelte:head>
|
18 | 24 |
|
19 | 25 | <h1 class="visually-hidden">Blog</h1>
|
20 |
| -<div class="posts stretch"> |
21 |
| - {#each data.posts as post} |
22 |
| - {#if !post.metadata.draft} |
23 |
| - <article class="post" data-pubdate={post.date}> |
24 |
| - <a href="/{post.slug}" title="Read the article »"> |
25 |
| - <h2>{post.metadata.title}</h2> |
26 |
| - <p>{post.metadata.description}</p> |
27 |
| - </a> |
28 |
| - </article> |
29 |
| - {/if} |
30 |
| - {/each} |
| 26 | + |
| 27 | +<div class="container"> |
| 28 | + <article class="top" data-pubdate={top.date}> |
| 29 | + <a href="/{top.slug}" title="Read the article »"> |
| 30 | + <h2>{top.metadata.title}</h2> |
| 31 | + <p>{top.metadata.description}</p> |
| 32 | + </a> |
| 33 | + |
| 34 | + <Byline post={top} /> |
| 35 | + </article> |
| 36 | + |
| 37 | + <div class="grid"> |
| 38 | + <div class="featured posts"> |
| 39 | + {#each data.posts.slice(1) as post} |
| 40 | + <article |
| 41 | + class:feature={!post.metadata.title.startsWith('What’s new')} |
| 42 | + data-pubdate={post.date} |
| 43 | + > |
| 44 | + <a href="/{post.slug}" title="Read the article »"> |
| 45 | + <h2>{post.metadata.title}</h2> |
| 46 | + <p>{post.metadata.description}</p> |
| 47 | + </a> |
| 48 | + |
| 49 | + <Byline {post} /> |
| 50 | + </article> |
| 51 | + {/each} |
| 52 | + </div> |
| 53 | + |
| 54 | + <ul class="feed"> |
| 55 | + {#each whats_new as post} |
| 56 | + <li> |
| 57 | + <a href="/{post.slug}" title="Read the article »"> |
| 58 | + {post.metadata.title.replace('What’s new in Svelte: ', '')} |
| 59 | + </a> |
| 60 | + </li> |
| 61 | + {/each} |
| 62 | + </ul> |
| 63 | + </div> |
31 | 64 | </div>
|
32 | 65 |
|
33 | 66 | <style>
|
34 |
| - .posts { |
35 |
| - grid-template-columns: 1fr 1fr; |
36 |
| - grid-gap: 1em; |
37 |
| - min-height: calc(100vh - var(--sk-nav-height) - var(--sk-banner-bottom-height)); |
38 |
| - padding: var(--sk-page-padding-top) var(--sk-page-padding-side) 6rem var(--sk-page-padding-side); |
| 67 | + .container { |
39 | 68 | max-width: var(--sk-page-content-width);
|
40 | 69 | box-sizing: content-box;
|
41 | 70 | margin: 0 auto;
|
42 | 71 | text-wrap: balance;
|
| 72 | + padding: var(--sk-page-padding-top) var(--sk-page-padding-side); |
43 | 73 | }
|
44 | 74 |
|
45 | 75 | h2 {
|
|
48 | 78 | font-size: var(--sk-font-size-h3);
|
49 | 79 | }
|
50 | 80 |
|
51 |
| - .post { |
| 81 | + article { |
52 | 82 | margin: 2em 0;
|
53 | 83 |
|
54 |
| - &:where(:first-child, :nth-child(2))::before { |
55 |
| - content: 'Latest post • ' attr(data-pubdate); |
56 |
| - color: var(--sk-text-4); |
57 |
| - font-family: var(--sk-font-ui); |
58 |
| - font-size: var(--sk-font-size-ui-small); |
59 |
| - text-transform: uppercase; |
60 |
| - } |
61 |
| -
|
62 |
| - &:nth-child(2)::before { |
63 |
| - content: 'Older posts'; |
64 |
| - } |
65 |
| -
|
66 |
| - &:first-child { |
| 84 | + /* we need to use :global because snippets don't currently cause a deopt */ |
| 85 | + &.top { |
67 | 86 | margin: 0 0 2rem 0;
|
68 | 87 | padding: 0 0 4rem 0;
|
69 | 88 |
|
|
76 | 95 | a {
|
77 | 96 | display: block;
|
78 | 97 | text-decoration: none;
|
| 98 | + color: var(--sk-text-2); |
| 99 | + font-size: var(--sk-font-size-body); |
79 | 100 |
|
80 | 101 | &:hover h2 {
|
81 | 102 | text-decoration: underline;
|
|
85 | 106 | p {
|
86 | 107 | font-size: var(--sk-font-size-body-small);
|
87 | 108 | color: var(--sk-text-3);
|
| 109 | + margin: 0 0 0.5em 0; |
| 110 | + } |
| 111 | + } |
| 112 | +
|
| 113 | + .feed { |
| 114 | + display: none; |
| 115 | + } |
| 116 | +
|
| 117 | + @media (min-width: 800px) { |
| 118 | + .grid { |
| 119 | + display: grid; |
| 120 | + grid-template-columns: 3fr 1fr; |
| 121 | + gap: 3em; |
| 122 | + } |
| 123 | +
|
| 124 | + .featured { |
| 125 | + display: block; |
| 126 | +
|
| 127 | + &::before { |
| 128 | + content: 'Featured posts'; |
| 129 | + font-family: var(--sk-font-ui); |
| 130 | + font-size: var(--sk-font-size-ui-medium); |
| 131 | + text-transform: uppercase; |
| 132 | + color: var(--sk-text-4); |
| 133 | + } |
| 134 | +
|
| 135 | + article { |
| 136 | + &:not(.feature) { |
| 137 | + display: none; |
| 138 | + } |
| 139 | +
|
| 140 | + h2 { |
| 141 | + font-size: var(--sk-font-size-h2); |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | +
|
| 146 | + .feed { |
| 147 | + position: relative; |
| 148 | + display: block; |
| 149 | + padding: 2em 0; |
88 | 150 | margin: 0;
|
| 151 | + list-style: none; |
| 152 | +
|
| 153 | + &::before { |
| 154 | + content: 'Monthly updates'; |
| 155 | + position: absolute; |
| 156 | + top: 0; |
| 157 | + font-family: var(--sk-font-ui); |
| 158 | + font-size: var(--sk-font-size-ui-medium); |
| 159 | + text-transform: uppercase; |
| 160 | + color: var(--sk-text-4); |
| 161 | + } |
| 162 | +
|
| 163 | + a { |
| 164 | + display: block; |
| 165 | + font-family: var(--sk-font-body); |
| 166 | + font-weight: 400; |
| 167 | + font-size: var(--sk-font-size-body); |
| 168 | + color: var(--sk-text-2); |
| 169 | + } |
89 | 170 | }
|
90 | 171 | }
|
91 | 172 | </style>
|
0 commit comments