Skip to content

Commit 6c78abc

Browse files
committed
Merge #125: contributor articles not appearing on contributor page
d4458bd fix check error (Graeme Byrne) 270b368 fix lint error (Graeme Byrne) 59b8ec9 contributor articles not appearing on contributor page (Graeme Byrne) Pull request description: * `routes/contributor/+layout.server.ts` wasn't accessing data from `routes/api` which had been set up to facilitate the change from `routes/(blog)` to `routes/blog`. This was causing the contributor's articles not to be shown on their page as detailed [here](#123). I made this data accesible to `routes/contributor` by adding the code below to `routes/contributor/+layout.server.ts` ``` export const load = async ({ fetch }) => { const response = await fetch(`/api`); const posts = await response.json(); return { posts }; }; ``` * Replaced deprecated [Shijiki](https://github.com/antfu/shikiji) and [shiki-es](https://github.com/pi0/shiki-es) with [Shiki](https://github.com/shikijs/shiki) as mentioned [here](#76). ACKs for top commit: josecelano: ACK d4458bd Tree-SHA512: 5d2a6b089827349489e3cb944a49ee6258d12c834e2af3e007e36150ba97f8ab82b49ee19fd7756cc1dae9a52104247c0630470ee85c1ceacb29affd242bd963
2 parents fa1efe1 + d4458bd commit 6c78abc

File tree

12 files changed

+465
-85
lines changed

12 files changed

+465
-85
lines changed

package-lock.json

Lines changed: 398 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"@iconify/svelte": "^4.0.2",
2323
"@melt-ui/pp": "^0.3.2",
2424
"@melt-ui/svelte": "^0.86.0",
25+
"@skeletonlabs/skeleton": "^2.10.3",
26+
"@skeletonlabs/tw-plugin": "^0.4.0",
2527
"@sveltejs/adapter-static": "^3.0.1",
2628
"@sveltejs/kit": "^2.5.25",
2729
"@types/swiper": "^5.4.3",
@@ -60,8 +62,7 @@
6062
"feather-icons": "^4.29.2",
6163
"flexsearch": "^0.7.43",
6264
"postcss": "^8.4.49",
63-
"shiki": "^1.6.1",
64-
"shiki-es": "^0.14.0",
65+
"shiki": "^1.23.1",
6566
"svelte-toc": "^0.5.9",
6667
"tocbot": "^4.29.0",
6768
"vscode-oniguruma": "^2.0.1",

src/lib/components/organisms/RelatedPosts.story.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
title: 'Getting Started with Svelte',
1212
date: '2024-04-28',
1313
contributor: 'John Doe',
14+
contributorSlug: 'john-doe',
1415
coverImage: '/images/svelte-cover.jpg',
1516
tags: ['Technology', 'Programming'],
1617
readingTime: '5 minutes',

src/lib/components/singletons/TorrustTrackerPost.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import CodeBlock from '$lib/components/molecules/CodeBlock.svelte';
3-
import Toc from '../atoms/Toc.svelte';
4-
import PagesWrapper from '../atoms/PagesWrapper.svelte';
3+
import Toc from '$lib/components/atoms/Toc.svelte';
4+
import PagesWrapper from '$lib/components/atoms/PagesWrapper.svelte';
55
</script>
66

77
<PagesWrapper heading="">

src/lib/utils/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type BlogPost = {
4747
slug: string;
4848
title: string;
4949
contributor: string;
50+
contributorSlug: string;
5051
coverImage: string;
5152
tags?: string[];
5253
readingTime: string;

src/routes/(pages)/about/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
padding-top: 2rem;
355355
}
356356
357-
#toc-builder-preview > h2 {
357+
h2 {
358358
font-size: 1.8rem;
359359
font-weight: bold;
360360
}

src/routes/api/+server.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ export const GET = async () => {
88
const dateA = new Date(a.meta.date);
99
const dateB = new Date(b.meta.date);
1010

11-
// Check if the dates are valid before sorting
1211
if (isNaN(dateA.getTime()) || isNaN(dateB.getTime())) {
1312
console.error('Invalid date found:', a.meta.date, b.meta.date);
14-
return 0; // Keep original order if dates are invalid
13+
return 0;
1514
}
1615

17-
return dateB.getTime() - dateA.getTime(); // Sort in descending order
16+
return dateB.getTime() - dateA.getTime();
1817
});
1918

2019
if (!sortedPosts.length) {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { filteredPosts } from '$lib/data/blog-posts';
1+
export const load = async ({ fetch }) => {
2+
const response = await fetch(`/api`);
3+
const posts = await response.json();
24

3-
export async function load() {
45
return {
5-
posts: filteredPosts
6+
posts
67
};
7-
}
8+
};

src/routes/contributor/+layout.svelte

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script lang="ts">
22
import { onMount } from 'svelte';
3+
import { page } from '$app/stores';
34
45
import Button from '$lib/components/atoms/Button.svelte';
5-
import RelatedPostCard from '$lib/components/molecules/RelatedPostCard.svelte';
66
import ContentSection from '$lib/components/organisms/ContentSection.svelte';
77
import type { BlogPost } from '$lib/utils/types';
8+
import BlogPreview from '$lib/components/molecules/BlogPreview.svelte';
89
910
export let data: {
1011
posts: BlogPost[];
@@ -17,10 +18,10 @@
1718
let numberOfPosts: number | undefined;
1819
1920
onMount(() => {
20-
currentUrl = window.location.href;
21+
currentUrl = $page.url.pathname;
2122
splitUrl = currentUrl.split('/').pop();
2223
23-
numberOfPosts = posts.filter((post) => post.contributorSlug === splitUrl).length;
24+
numberOfPosts = posts.filter((post) => post.meta.contributorSlug === splitUrl).length;
2425
});
2526
</script>
2627

@@ -31,16 +32,9 @@
3132
<ContentSection title="All Blog Posts">
3233
<div class="grid">
3334
{#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>
4438
{/each}
4539
</div>
4640
</ContentSection>
@@ -61,45 +55,31 @@
6155

6256
<style lang="scss">
6357
@import '$lib/scss/_mixins.scss';
58+
@import '$lib/scss/_breakpoints.scss';
6459
6560
.container {
6661
background: rgba(26, 26, 26, 1);
6762
color: rgba(245, 245, 245, 0.96);
6863
}
6964
7065
.grid {
71-
width: 100%;
66+
padding-top: 3rem;
7267
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;
7572
76-
@include for-tablet-portrait-down {
73+
@include for-phone-only {
7774
grid-template-columns: 1fr;
7875
}
7976
8077
@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;
10383
}
10484
}
10585
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
<slot />
1+
<div class="contributors">
2+
<h1>Contributors</h1>
3+
<slot />
4+
</div>
5+
6+
<style lang="scss">
7+
.contributors {
8+
background: rgba(26, 26, 26, 1);
9+
padding-block: 2rem;
10+
}
11+
12+
h1 {
13+
font-size: 2.5rem;
14+
padding-block: 3rem;
15+
text-align: center;
16+
color: rgba(245, 245, 245, 0.96);
17+
}
18+
</style>

0 commit comments

Comments
 (0)