|
3 | 3 | import './toc.css'; |
4 | 4 | import './markdown.css'; |
5 | 5 |
|
6 | | - let { children } = $props(); |
| 6 | + let { children, data } = $props(); |
7 | 7 |
|
8 | 8 | function recalcActiveHeader(): void { |
9 | 9 | const headers = Array.from( |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
|
| 74 | + // function formatDate(dateStr: string): string { |
| 75 | + // const date = new Date(dateStr); |
| 76 | +
|
| 77 | + // return [ |
| 78 | + // String(date.getDate()).padStart(2, '0'), |
| 79 | + // String(date.getMonth() + 1).padStart(2, '0'), |
| 80 | + // date.getFullYear() |
| 81 | + // ].join('.'); |
| 82 | + // } |
| 83 | +
|
74 | 84 | onMount(() => { |
75 | 85 | recalcActiveHeader(); |
76 | 86 | }); |
|
98 | 108 | <span class="icon icon_telegram"></span> |
99 | 109 | Обсудить в Telegram |
100 | 110 | </a> |
| 111 | + |
| 112 | + {#if data?.relatedPosts?.length} |
| 113 | + <h4 class="article__related-title"> |
| 114 | + Почитать ещё посты |
| 115 | + </h4> |
| 116 | + |
| 117 | + <ul class="article__related"> |
| 118 | + {#each data.relatedPosts as post} |
| 119 | + <li class="article__related-post"> |
| 120 | + <a href="/posts/{post.name}" class="article__related-link"> |
| 121 | + <img |
| 122 | + class="article__related-image" |
| 123 | + alt={post.title} |
| 124 | + src={post.shareImage} |
| 125 | + > |
| 126 | + <!-- <div class="article__related-date"> |
| 127 | + {formatDate(post.date)} |
| 128 | + </div> --> |
| 129 | + </a> |
| 130 | + </li> |
| 131 | + {/each} |
| 132 | + </ul> |
| 133 | + {/if} |
101 | 134 | </div> |
102 | 135 |
|
103 | 136 | <style> |
|
178 | 211 | .icon_telegram { |
179 | 212 | mask-image: url(./telegram.svg); |
180 | 213 | } |
| 214 | +
|
| 215 | + .article__related-title { |
| 216 | + margin-top: 100px; |
| 217 | + } |
| 218 | +
|
| 219 | + .article__related { |
| 220 | + position: relative; |
| 221 | + z-index: 1; |
| 222 | + display: flex; |
| 223 | + flex-direction: row; |
| 224 | + gap: 12px; |
| 225 | + margin: 0 -20px; |
| 226 | + padding: 0 20px 20px; |
| 227 | + overflow-x: auto; |
| 228 | + list-style: none; |
| 229 | + } |
| 230 | +
|
| 231 | + @media (--desktop-window) { |
| 232 | + .article__related { |
| 233 | + --toc-width: 16rem; |
| 234 | +
|
| 235 | + margin-right: calc((20px + var(--toc-width)) * -1); |
| 236 | + } |
| 237 | + } |
| 238 | +
|
| 239 | + @media (--desktop-window-large) { |
| 240 | + .article__related { |
| 241 | + margin-right: 0; |
| 242 | + margin-left: 0; |
| 243 | + padding-right: 0; |
| 244 | + padding-left: 0; |
| 245 | + } |
| 246 | + } |
| 247 | +
|
| 248 | + .article__related-link { |
| 249 | + display: block; |
| 250 | + padding: 12px; |
| 251 | + border-radius: 12px; |
| 252 | + color: inherit; |
| 253 | + text-decoration: none; |
| 254 | + background-color: var(--bg-quaternary); |
| 255 | + transition: background-color .15s ease-in-out; |
| 256 | + } |
| 257 | +
|
| 258 | + .article__related-link:hover { |
| 259 | + background-color: var(--bg-tertiary); |
| 260 | + } |
| 261 | +
|
| 262 | + .article__related-image { |
| 263 | + display: block; |
| 264 | + width: 200px; |
| 265 | + max-width: none; |
| 266 | + margin: 0; |
| 267 | + aspect-ratio: 1200 / 630; |
| 268 | + pointer-events: none; |
| 269 | + } |
| 270 | +
|
| 271 | + /* .article__related-date { |
| 272 | + margin-top: 12px; |
| 273 | + text-align: center; |
| 274 | + } */ |
181 | 275 | </style> |
0 commit comments