Skip to content

Commit 422a2bf

Browse files
committed
.
1 parent 61f2fc6 commit 422a2bf

File tree

7 files changed

+1914
-2
lines changed

7 files changed

+1914
-2
lines changed

Diff for: .idea/inspectionProfiles/Project_Default.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/components/PostCard.svelte

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script>
2+
export let post= {}
3+
$:{
4+
console.log(post);}
5+
</script>
6+
<!-- {JSON.stringify(post)} -->
7+
<div class="container bg-gray-700">
8+
<a
9+
href={`/post/${post.sys.id}`}
10+
rel="noopener noreferrer"
11+
class="max-w-sm mx-auto group hover:no-underline focus:no-underline dark:bg-gray-900"
12+
>
13+
<img
14+
role="presentation"
15+
class="object-cover w-full rounded h-44 dark:bg-gray-500"
16+
src={post.fields.featuredImage.fields.file.url} alt="posy"
17+
/>
18+
<div class ="flex justify-between ">
19+
<span class="mt-3 mx-3 text-gray-600">{post.fields.createdAt}</span>
20+
<span class="mt-3 mx-3 text-gray-600"> Reactj </span>
21+
</div>
22+
23+
<div class ="px-6 py-2 space-y-2 ">
24+
<h3 class ="text-2xl font-semibold group-hover:underline group-focus:underline">
25+
{ post.fields.title || "In usu laoreet repudiare legendos"}
26+
</h3>
27+
<p class="align-baseline">{ post.fields.summary}</p>
28+
</div>
29+
30+
</a>
31+
</div>
32+
33+
<style>
34+
.container{
35+
width: 300px;
36+
height: 300px;
37+
}
38+
39+
</style>

Diff for: src/components/postGrid.svelte

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<script>
2+
import PostCard from './PostCard.svelte';
3+
export /**
4+
* @type {any[]}
5+
*/
6+
let posts=[];
7+
</script>
8+
9+
<section class=" dark:bg-gray-800 dark:text-gray-100">
10+
<div class="container max-w-6xl p-6 mx-auto space-y-6 sm:space-y-12">
11+
<span class=" ">
12+
<!-- <Featured /> -->
13+
</span>
14+
15+
16+
<div class="grid justify-center grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
17+
{" "}
18+
{#each posts as post}
19+
<PostCard post={post}/>
20+
{/each}
21+
22+
</div>{" "}
23+
24+
25+
<div class="flex justify-center">
26+
<button
27+
type="button"
28+
class="px-6 py-3 text-sm rounded-md hover:underline dark:bg-gray-900 dark:text-gray-400"
29+
>
30+
31+
</button>
32+
</div>
33+
</div>
34+
</section>

Diff for: src/contentful/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {createClient} from 'contentful'
2+
3+
const client=createClient({
4+
space:'w591jyzdi2py',
5+
accessToken:'DXG7DohnxRncpcxSPtLGr5fR4_fzjyzRzVZAiP9Ussk'
6+
});
7+
8+
export {client}

Diff for: src/routes/index.svelte

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
<script>
1010
import PostGrid from './../components/postGrid.svelte';
1111
export let posts;
12-
client.getEntries().then(entries => posts = entries)
13-
1412
</script>
1513
<div>
1614
<!-- {JSON.stringify(posts.items[0].fields)} -->

Diff for: src/routes/post/[slug].svelte

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<script context="module">
2+
import {client} from "../../contentful/index.js";
3+
export async function load({params}) {
4+
const {slug} = params;
5+
const data = await client.getEntry(slug);
6+
// console.log(data)
7+
return {
8+
props: {
9+
slug: slug,
10+
data: data
11+
}
12+
};
13+
}
14+
</script>
15+
16+
<script>
17+
export let data={};
18+
let post
19+
$:post = data;
20+
21+
</script>
22+
23+
<div>
24+
<!--{JSON.stringify(post)}-->
25+
<div class=" dark:bg-gray-800 max-w-6xl px-6 py-16 mx-auto space-y-12">
26+
{#await post}
27+
<p>Loading</p>
28+
{:then post}
29+
<!--{JSON.stringify(post.fields.contents) }-->
30+
31+
<article class=" flex-col space-y-8 dark:bg-gray-800 dark:text-gray-50">
32+
<div class="space-y-6">
33+
<h1 class="text-4xl font-bold md:tracking-tight md:text-5xl">
34+
{post.fields.title }
35+
</h1>
36+
<div>
37+
<p>{post.fields.summary}</p>
38+
</div>
39+
<div
40+
class="flex flex-col items-start justify-between w-full md:flex-row md:items-center dark:text-gray-400"
41+
>
42+
<div class="flex items-center md:space-x-2">
43+
<img
44+
src="https://source.unsplash.com/random/?face&fit=facearea&facepad=2&w=256&h=256&q=80"
45+
alt=""
46+
class="w-12 h-12 border rounded-full dark:bg-gray-500 dark:border-gray-700"
47+
/>
48+
<p class="text-sm">Leroy Jenkins • {post.fields.createdAt}</p>
49+
</div>
50+
<p class="flex-shrink-0 mt-3 text-sm md:mt-0">4 min read • 1,570 views</p>
51+
</div>
52+
</div>
53+
<div>
54+
<img src={post.fields.featuredImage.fields.file.url} alt=" "/>
55+
</div>
56+
<div class="dark:text-gray-100">
57+
<p>
58+
{#if post.fields.content.content[0].content[0].value}
59+
{ post.fields.content.content[0].content[0].value }
60+
{:else }
61+
Loading
62+
{/if}
63+
</p>
64+
</div>
65+
</article>
66+
67+
{/await}
68+
<div></div>
69+
</div>
70+
</div>

0 commit comments

Comments
 (0)