Skip to content

Commit 61f2fc6

Browse files
committedJul 22, 2022
:)
1 parent 3ce1b03 commit 61f2fc6

16 files changed

+2601
-1744
lines changed
 

‎.idea/.gitignore

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

‎.idea/contentful.iml

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

‎.idea/modules.xml

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

‎.idea/vcs.xml

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

‎README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22
<a href="" rel="noopener">
33
<img src="https://i.imgur.com/AZ2iWek.png" alt="Project logo"></a>
44
</p>
5-
<h3 align="center">Svelte - Pokeman</h3>
5+
<h3 align="center">Svelte-Contentful-Blog</h3>
66

77
<div align="center">
88

9-
[![Hackathon](https://img.shields.io/badge/svelt-pokeman-green.svg)](http://hackathon.url.com)
9+
[![Hackathon](https://img.shields.io/badge/svelt-contentful-cms.svg)](http://hackathon.url.com)
1010
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
1111

1212
</div>
13+
1314

14-
---
15-
16-
<p align="center">Svelte Pokemon is a simple API based app which can show Pokemon list and search for a Pokemon.
17-
18-
> This example ideal for beginners and will help to understand the basic concepts in `Svelte`.
15+
<p align="center">This is Svelte Contentful Headless CMS integration example app.
1916
<br>
2017
</p>
2118

@@ -43,9 +40,10 @@ npm run dev -- --open
4340
## ⛏️ Built With <a name = "tech_stack"></a>
4441

4542
- [Svelte](https://svelte.dev/) - Web Framework
43+
- [Contentful](https://www.contentful.com/) - Contentful Headless CMS
4644
- [NodeJs](https://nodejs.org/en/) - Server Environment
4745
- JavaScript
48-
- TailwindCSS
46+
- [TailwindCSS](http://tailwindcss.com) - CSS Framework
4947

5048
## 🔷 Additional Guide
5149

‎package-lock.json

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

‎package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "pokemon",
2+
"name": "SvelteContentful",
33
"version": "0.0.1",
44
"scripts": {
55
"dev": "svelte-kit dev",
@@ -28,5 +28,8 @@
2828
"tailwindcss": "^3.1.4",
2929
"typescript": "^4.7.2"
3030
},
31-
"type": "module"
31+
"type": "module",
32+
"dependencies": {
33+
"contentful": "^9.1.32"
34+
}
3235
}

‎src/components/nav.svelte

+105-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,105 @@
1-
<nav class="flex w-full justify-center text-lg font-bold text-pink-700 text-center">
2-
<a class="px-2" href="/">Home</a>
3-
<a href="/about">About</a>
4-
</nav>
1+
<nav class="bg-white shadow dark:bg-gray-800 sticky top-0">
2+
<div class="container px-6 py-4 mx-auto lg:flex lg:justify-between lg:items-center">
3+
<div class="lg:flex lg:items-center">
4+
<div class="flex items-center justify-between">
5+
<div>
6+
<a
7+
class="text-2xl font-bold text-gray-800 transition-colors duration-200 transform dark:text-white lg:text-3xl hover:text-gray-700 dark:hover:text-gray-300"
8+
href="/">
9+
{brand}
10+
</a>
11+
</div>
12+
13+
14+
<div class="flex lg:hidden">
15+
<button
16+
type="button"
17+
class="text-gray-500 dark:text-gray-200 hover:text-gray-600 dark:hover:text-gray-400 focus:outline-none focus:text-gray-600 dark:focus:text-gray-400"
18+
aria-label="toggle menu"
19+
>
20+
<svg viewBox="0 0 24 24" class="w-6 h-6 fill-current">
21+
<path
22+
fill-rule="evenodd"
23+
d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z"
24+
></path>
25+
</svg>
26+
</button>
27+
</div>
28+
</div>
29+
30+
<div class="flex flex-col text-gray-600 capitalize dark:text-gray-300 lg:flex lg:px-16 lg:-mx-4 lg:flex-row lg:items-center">
31+
32+
<a
33+
href='/'
34+
class="mt-2 transition-colors duration-200 transform lg:mt-0 lg:mx-4 hover:text-gray-900 dark:hover:text-gray-200"
35+
>
36+
Home
37+
</a>
38+
<a
39+
href='/category'
40+
class="mt-2 transition-colors duration-200 transform lg:mt-0 lg:mx-4 hover:text-gray-900 dark:hover:text-gray-200"
41+
>
42+
Category
43+
</a>
44+
<a
45+
href='/About'
46+
class="mt-2 transition-colors duration-200 transform lg:mt-0 lg:mx-4 hover:text-gray-900 dark:hover:text-gray-200"
47+
>
48+
About
49+
</a>
50+
</div>
51+
</div>
52+
53+
<div class="flex justify-center mt-6 lg:flex lg:mt-0 lg:-mx-2">
54+
<a
55+
href="/"
56+
class="mx-2 text-gray-600 transition-colors duration-200 transform dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-300"
57+
aria-label="Reddit"
58+
>
59+
<svg
60+
class="w-5 h-5 fill-current"
61+
viewBox="0 0 24 24"
62+
fill="none"
63+
xmlns="http://www.w3.org/2000/svg"
64+
>
65+
<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C21.9939 17.5203 17.5203 21.9939 12 22ZM6.807 10.543C6.20862 10.5433 5.67102 10.9088 5.45054 11.465C5.23006 12.0213 5.37133 12.6558 5.807 13.066C5.92217 13.1751 6.05463 13.2643 6.199 13.33C6.18644 13.4761 6.18644 13.6229 6.199 13.769C6.199 16.009 8.814 17.831 12.028 17.831C15.242 17.831 17.858 16.009 17.858 13.769C17.8696 13.6229 17.8696 13.4761 17.858 13.33C18.4649 13.0351 18.786 12.3585 18.6305 11.7019C18.475 11.0453 17.8847 10.5844 17.21 10.593H17.157C16.7988 10.6062 16.458 10.7512 16.2 11C15.0625 10.2265 13.7252 9.79927 12.35 9.77L13 6.65L15.138 7.1C15.1931 7.60706 15.621 7.99141 16.131 7.992C16.1674 7.99196 16.2038 7.98995 16.24 7.986C16.7702 7.93278 17.1655 7.47314 17.1389 6.94094C17.1122 6.40873 16.6729 5.991 16.14 5.991C16.1022 5.99191 16.0645 5.99491 16.027 6C15.71 6.03367 15.4281 6.21641 15.268 6.492L12.82 6C12.7983 5.99535 12.7762 5.993 12.754 5.993C12.6094 5.99472 12.4851 6.09583 12.454 6.237L11.706 9.71C10.3138 9.7297 8.95795 10.157 7.806 10.939C7.53601 10.6839 7.17843 10.5422 6.807 10.543ZM12.18 16.524C12.124 16.524 12.067 16.524 12.011 16.524C11.955 16.524 11.898 16.524 11.842 16.524C11.0121 16.5208 10.2054 16.2497 9.542 15.751C9.49626 15.6958 9.47445 15.6246 9.4814 15.5533C9.48834 15.482 9.52348 15.4163 9.579 15.371C9.62737 15.3318 9.68771 15.3102 9.75 15.31C9.81233 15.31 9.87275 15.3315 9.921 15.371C10.4816 15.7818 11.159 16.0022 11.854 16C11.9027 16 11.9513 16 12 16C12.059 16 12.119 16 12.178 16C12.864 16.0011 13.5329 15.7863 14.09 15.386C14.1427 15.3322 14.2147 15.302 14.29 15.302C14.3653 15.302 14.4373 15.3322 14.49 15.386C14.5985 15.4981 14.5962 15.6767 14.485 15.786V15.746C13.8213 16.2481 13.0123 16.5208 12.18 16.523V16.524ZM14.307 14.08H14.291L14.299 14.041C13.8591 14.011 13.4994 13.6789 13.4343 13.2429C13.3691 12.8068 13.6162 12.3842 14.028 12.2269C14.4399 12.0697 14.9058 12.2202 15.1478 12.5887C15.3899 12.9572 15.3429 13.4445 15.035 13.76C14.856 13.9554 14.6059 14.0707 14.341 14.08H14.306H14.307ZM9.67 14C9.11772 14 8.67 13.5523 8.67 13C8.67 12.4477 9.11772 12 9.67 12C10.2223 12 10.67 12.4477 10.67 13C10.67 13.5523 10.2223 14 9.67 14Z"></path>
66+
</svg>
67+
</a>
68+
69+
<a
70+
href="/"
71+
class="mx-2 text-gray-600 transition-colors duration-200 transform dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-300"
72+
aria-label="Facebook"
73+
>
74+
<svg
75+
class="w-5 h-5 fill-current"
76+
viewBox="0 0 24 24"
77+
fill="none"
78+
xmlns="http://www.w3.org/2000/svg"
79+
>
80+
<path d="M2.00195 12.002C2.00312 16.9214 5.58036 21.1101 10.439 21.881V14.892H7.90195V12.002H10.442V9.80204C10.3284 8.75958 10.6845 7.72064 11.4136 6.96698C12.1427 6.21332 13.1693 5.82306 14.215 5.90204C14.9655 5.91417 15.7141 5.98101 16.455 6.10205V8.56104H15.191C14.7558 8.50405 14.3183 8.64777 14.0017 8.95171C13.6851 9.25566 13.5237 9.68693 13.563 10.124V12.002H16.334L15.891 14.893H13.563V21.881C18.8174 21.0506 22.502 16.2518 21.9475 10.9611C21.3929 5.67041 16.7932 1.73997 11.4808 2.01722C6.16831 2.29447 2.0028 6.68235 2.00195 12.002Z"></path>
81+
</svg>
82+
</a>
83+
84+
<a
85+
href="/"
86+
class="mx-2 text-gray-600 transition-colors duration-200 transform dark:text-gray-300 hover:text-gray-500 dark:hover:text-gray-300"
87+
aria-label="Github"
88+
>
89+
<svg
90+
class="w-5 h-5 fill-current"
91+
viewBox="0 0 24 24"
92+
fill="none"
93+
xmlns="http://www.w3.org/2000/svg"
94+
>
95+
<path d="M12.026 2C7.13295 1.99937 2.96183 5.54799 2.17842 10.3779C1.395 15.2079 4.23061 19.893 8.87302 21.439C9.37302 21.529 9.55202 21.222 9.55202 20.958C9.55202 20.721 9.54402 20.093 9.54102 19.258C6.76602 19.858 6.18002 17.92 6.18002 17.92C5.99733 17.317 5.60459 16.7993 5.07302 16.461C4.17302 15.842 5.14202 15.856 5.14202 15.856C5.78269 15.9438 6.34657 16.3235 6.66902 16.884C6.94195 17.3803 7.40177 17.747 7.94632 17.9026C8.49087 18.0583 9.07503 17.99 9.56902 17.713C9.61544 17.207 9.84055 16.7341 10.204 16.379C7.99002 16.128 5.66202 15.272 5.66202 11.449C5.64973 10.4602 6.01691 9.5043 6.68802 8.778C6.38437 7.91731 6.42013 6.97325 6.78802 6.138C6.78802 6.138 7.62502 5.869 9.53002 7.159C11.1639 6.71101 12.8882 6.71101 14.522 7.159C16.428 5.868 17.264 6.138 17.264 6.138C17.6336 6.97286 17.6694 7.91757 17.364 8.778C18.0376 9.50423 18.4045 10.4626 18.388 11.453C18.388 15.286 16.058 16.128 13.836 16.375C14.3153 16.8651 14.5612 17.5373 14.511 18.221C14.511 19.555 14.499 20.631 14.499 20.958C14.499 21.225 14.677 21.535 15.186 21.437C19.8265 19.8884 22.6591 15.203 21.874 10.3743C21.089 5.54565 16.9181 1.99888 12.026 2Z"></path>
96+
</svg>
97+
</a>
98+
</div>
99+
</div>
100+
</nav>
101+
102+
<script>
103+
let brand = import.meta.env.VITE_ENV_BRAND;
104+
console.log(brand)
105+
</script>

‎src/components/pokemanCard.svelte

-14
This file was deleted.

‎src/routes/__error.svelte

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<div id='oopss'>
2+
<div id='error-text'>
3+
<span>404</span>
4+
<p>PAGE NOT FOUND</p>
5+
<p class='hmpg'><a href='/' class="back">Back To Home</a></p>
6+
</div>
7+
8+
</div>
9+
<style>
10+
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
11+
12+
a,
13+
a:visited {
14+
color: #fff;
15+
outline: none;
16+
text-decoration: none;
17+
}
18+
19+
a:hover,
20+
a:focus,
21+
a:visited:hover {
22+
color: #fff;
23+
text-decoration: none;
24+
}
25+
26+
27+
#oopss {
28+
background: #222;
29+
text-align: center;
30+
margin-bottom: 50px;
31+
font-weight: 400;
32+
font-size: 20px;
33+
position: fixed;
34+
width: 100%;
35+
height: 100%;
36+
line-height: 1.5em;
37+
z-index: 9999;
38+
left: 0px;
39+
}
40+
41+
#error-text {
42+
top: 30%;
43+
position: relative;
44+
font-size: 40px;
45+
color: #eee;
46+
}
47+
48+
#error-text a {
49+
color: #eee;
50+
}
51+
52+
#error-text a:hover {
53+
color: #fff;
54+
}
55+
56+
#error-text p {
57+
color: #eee;
58+
margin: 70px 0 0 0;
59+
}
60+
61+
#error-text i {
62+
margin-left: 10px;
63+
}
64+
65+
#error-text p.hmpg {
66+
margin: 40px 0 0 0;
67+
}
68+
69+
#error-text span {
70+
position: relative;
71+
background: #ef4824;
72+
color: #fff;
73+
font-size: 300%;
74+
padding: 0 20px;
75+
border-radius: 5px;
76+
font-weight: bolder;
77+
transition: all .5s;
78+
cursor: pointer;
79+
margin: 0 0 40px 0;
80+
}
81+
82+
#error-text span:hover {
83+
background: #d7401f;
84+
color: #fff;
85+
-webkit-animation: jelly .5s;
86+
-moz-animation: jelly .5s;
87+
-ms-animation: jelly .5s;
88+
-o-animation: jelly .5s;
89+
animation: jelly .5s;
90+
}
91+
92+
#error-text span:after {
93+
top: 100%;
94+
left: 50%;
95+
border: solid transparent;
96+
content: '';
97+
height: 0;
98+
width: 0;
99+
position: absolute;
100+
pointer-events: none;
101+
border-color: rgba(136, 183, 213, 0);
102+
border-top-color: #ef4824;
103+
border-width: 7px;
104+
margin-left: -7px;
105+
}
106+
107+
@-webkit-keyframes jelly {
108+
from, to {
109+
-webkit-transform: scale(1, 1);
110+
transform: scale(1, 1);
111+
}
112+
25% {
113+
-webkit-transform: scale(.9, 1.1);
114+
transform: scale(.9, 1.1);
115+
}
116+
50% {
117+
-webkit-transform: scale(1.1, .9);
118+
transform: scale(1.1, .9);
119+
}
120+
75% {
121+
-webkit-transform: scale(.95, 1.05);
122+
transform: scale(.95, 1.05);
123+
}
124+
}
125+
126+
@keyframes jelly {
127+
from, to {
128+
-webkit-transform: scale(1, 1);
129+
transform: scale(1, 1);
130+
}
131+
25% {
132+
-webkit-transform: scale(.9, 1.1);
133+
transform: scale(.9, 1.1);
134+
}
135+
50% {
136+
-webkit-transform: scale(1.1, .9);
137+
transform: scale(1.1, .9);
138+
}
139+
75% {
140+
-webkit-transform: scale(.95, 1.05);
141+
transform: scale(.95, 1.05);
142+
}
143+
}
144+
/* CSS Error Page Responsive */
145+
146+
@media only screen and (max-width:640px) {
147+
#error-text span {
148+
font-size: 200%;
149+
}
150+
#error-text a:hover {
151+
color: #fff;
152+
}
153+
}
154+
155+
.back:active {
156+
-webkit-transform: scale(0.95);
157+
-moz-transform: scale(0.95);
158+
transform: scale(0.95);
159+
background: #f53b3b;
160+
color: #fff;
161+
}
162+
163+
.back:hover {
164+
background: #4c4c4c;
165+
color: #fff;
166+
}
167+
168+
.back {
169+
text-decoration: none;
170+
background: #5b5a5a;
171+
color: #fff;
172+
padding: 10px 20px;
173+
font-size: 20px;
174+
font-weight: 700;
175+
line-height: normal;
176+
text-transform: uppercase;
177+
border-radius: 3px;
178+
-webkit-transform: scale(1);
179+
-moz-transform: scale(1);
180+
transform: scale(1);
181+
transition: all 0.5s ease-out;
182+
}</style>
183+

‎src/routes/__layout.svelte

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import Nav from "../components/nav.svelte";
44
import "../app.css";
55
</script>
66

7-
<div class="p-8 max-w-6xl mx-auto">
8-
<Nav/>
9-
<slot/>
7+
<div class="bg-gray-800">
8+
<Nav />
9+
<div class=" dark:text-white dark:bg-gray-800 items-center overflow-auto h-screen">
10+
<slot/>
11+
</div>
1012
</div>
11-
1213

‎src/routes/api/pokemon/index.js

-15
This file was deleted.

‎src/routes/index.svelte

+16-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
1+
<script context="module">
2+
import {client} from "../contentful";
3+
export async function load() {
4+
let posts = [{}];
5+
client.getEntries().then(entries => posts = entries)
6+
return {props: {posts}}
7+
}
8+
</script>
19
<script>
2-
import { pokemon } from '../store/pokestore';
3-
import PokemanCard from '../components/pokemanCard.svelte';
4-
let searchTerm = '';
5-
/**
6-
* @type {any[]}
7-
*/
8-
let filteredPokemon = [];
9-
$: {
10-
if (searchTerm) {
11-
filteredPokemon = $pokemon.filter((pokeman) =>
12-
pokeman.name.toLowerCase().includes(searchTerm.toLowerCase())
13-
);
14-
} else {
15-
filteredPokemon = [...$pokemon];
16-
}
17-
}
10+
import PostGrid from './../components/postGrid.svelte';
11+
export let posts;
12+
client.getEntries().then(entries => posts = entries)
13+
1814
</script>
19-
<h1 class="text-4xl uppercase text-center my-8">Svelte Poke Kit</h1>
20-
<input
21-
class="w-full m-2 rounded-md text-lg p-4 border-2 border-gray-200"
22-
type="text"
23-
placeholder="Search Pokemon"
24-
bind:value={searchTerm} />
25-
<div class="grid gap-4 md:grid-cols-2 grid-cols-1">
26-
{#each filteredPokemon as pokeman}
27-
<p>
28-
<PokemanCard {pokeman} />
29-
</p>
30-
{/each}
31-
</div>
15+
<div>
16+
<!-- {JSON.stringify(posts.items[0].fields)} -->
17+
<PostGrid posts={posts.items}/>
18+
</div>

‎src/routes/pokemon/[id].svelte

-28
This file was deleted.

‎src/store/pokestore.js

-17
This file was deleted.

‎yarn.lock

+1,852-1,611
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.