forked from ANYSECURITIES/zldnowshsveltekit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
node_modules | ||
/.svelte-kit | ||
/package | ||
.vercel_build_output | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SvelteKit | ||
|
||
Example project using SvelteKit with the [SpaceX GraphQL API](https://api.spacex.land/graphql/), deployed to [Vercel](https://vercel.com). | ||
|
||
## Deploy Your Own | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fvercel%2Ftree%2Fmain%2Fexamples%2Fsveltekit&project-name=sveltekit-vercel&repository-name=sveltekit-vercel&demo-title=SvelteKit%20%2B%20Vercel&demo-description=SvelteKit%20app%20fetching%20data%20from%20the%20SpaceX%20GraphQL%20API.&demo-url=https%3A%2F%2Fsveltekit.examples.vercel.com%2F&demo-image=https%3A%2F%2Fsveltekit.examples.vercel.com%2Ftwitter.png) | ||
|
||
_Live Example: https://sveltekit.examples.vercel.com_ | ||
|
||
## Developing | ||
|
||
Once you've created a project and installed dependencies with `npm install`, start a development server: | ||
|
||
```bash | ||
npm run dev | ||
|
||
# or start the server and open the app in a new browser tab | ||
npm run dev -- --open | ||
``` | ||
|
||
## Building | ||
|
||
This uses the [Vercel Adapter](https://github.com/sveltejs/kit/tree/master/packages/adapter-vercel) for SvelteKit. | ||
|
||
```bash | ||
npm run build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"$lib": ["src/lib"], | ||
"$lib/*": ["src/lib/*"] | ||
} | ||
}, | ||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "svelte-kit dev", | ||
"build": "svelte-kit build --verbose", | ||
"preview": "svelte-kit preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-vercel": "next", | ||
"@sveltejs/kit": "next", | ||
"svelte": "^3.38.3" | ||
}, | ||
"dependencies": { | ||
"prettier": "^2.3.2", | ||
"prettier-plugin-svelte": "^2.3.1" | ||
}, | ||
"prettier": { | ||
"arrowParens": "always", | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="robots" content="follow, index" /> | ||
<title>SpaceX Launches | SvelteKit and Vercel</title> | ||
<meta | ||
content="SvelteKit app fetching data from the SpaceX GraphQL API, deployed to Vercel." | ||
name="description" | ||
/> | ||
<meta | ||
property="og:title" | ||
content="SpaceX Launches | SvelteKit and Vercel" | ||
/> | ||
<meta property="og:image" content="/twitter.png" /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta name="twitter:site" content="@vercel" /> | ||
<meta | ||
name="twitter:title" | ||
content="SpaceX Launches | SvelteKit and Vercel" | ||
/> | ||
<meta | ||
name="twitter:description" | ||
content="SvelteKit app fetching data from the SpaceX GraphQL API, deployed to Vercel." | ||
/> | ||
<meta name="twitter:image" content="/twitter.png" /> | ||
%svelte.head% | ||
</head> | ||
<body> | ||
<div id="svelte">%svelte.body%</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="@sveltejs/kit" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<script context="module"> | ||
export async function load({ fetch }) { | ||
const res = await fetch('https://api.spacex.land/graphql', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
query: `{ | ||
launchesPast(limit: 10) { | ||
mission_name | ||
launch_date_local | ||
links { | ||
video_link | ||
} | ||
} | ||
}` | ||
}) | ||
}); | ||
if (res.ok) { | ||
const { data } = await res.json(); | ||
return { | ||
props: { | ||
launches: data.launchesPast | ||
} | ||
}; | ||
} | ||
return { | ||
status: res.status, | ||
error: new Error(`Error fetching GraphQL data`) | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
export let launches; | ||
</script> | ||
|
||
<h1>SpaceX Launches</h1> | ||
<p> | ||
This is an example <a | ||
class="link" | ||
target="_blank" | ||
rel="noopener" | ||
href="https://svelte.dev">SvelteKit</a | ||
> | ||
application fetching GraphQL data from the public | ||
<a | ||
class="link" | ||
target="_blank" | ||
rel="noopener" | ||
href="https://api.spacex.land/graphql">SpaceX API</a | ||
>. View source on | ||
<a | ||
class="link" | ||
target="_blank" | ||
rel="noopener" | ||
href="https://github.com/leerob/sveltekit-graphql">GitHub</a | ||
>. | ||
</p> | ||
<ul> | ||
{#each launches as launch} | ||
<li> | ||
<a | ||
class="card-link" | ||
target="_blank" | ||
rel="noopener" | ||
href={launch.links.video_link} | ||
> | ||
<h2>{launch.mission_name}</h2> | ||
<p>{new Date(launch.launch_date_local).toLocaleString()}</p> | ||
</a> | ||
</li> | ||
{/each} | ||
</ul> | ||
<footer> | ||
<p> | ||
Created with <a | ||
class="link" | ||
target="_blank" | ||
rel="noopener" | ||
href="https://svelte.dev">SvelteKit</a | ||
> | ||
and deployed with | ||
<a class="link" target="_blank" rel="noopener" href="https://vercel.com" | ||
>▲ Vercel</a | ||
>. | ||
</p> | ||
</footer> | ||
|
||
<style> | ||
:global(body) { | ||
font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, | ||
monospace; | ||
background-color: #fafafa; | ||
max-width: 650px; | ||
margin: 32px auto; | ||
padding: 0 16px; | ||
} | ||
h1 { | ||
letter-spacing: -0.025em; | ||
} | ||
h2 { | ||
font-size: 18px; | ||
} | ||
ul { | ||
list-style: none; | ||
padding: 0; | ||
margin-top: 32px; | ||
} | ||
li { | ||
border: 1px solid #eaeaea; | ||
border-radius: 8px; | ||
margin-bottom: 16px; | ||
background-color: white; | ||
transition: 0.15s box-shadow ease-in-out; | ||
} | ||
li:hover { | ||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.12); | ||
} | ||
p { | ||
color: #666; | ||
font-size: 14px; | ||
line-height: 1.75; | ||
} | ||
a { | ||
color: #0070f3; | ||
text-decoration: none; | ||
} | ||
.card-link { | ||
padding: 8px 24px; | ||
display: block; | ||
} | ||
.link { | ||
transition: 0.15s text-decoration ease-in-out; | ||
color: #0761d1; | ||
} | ||
.link:hover { | ||
text-decoration: underline; | ||
} | ||
</style> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import vercel from '@sveltejs/adapter-vercel'; | ||
|
||
export default { | ||
kit: { | ||
adapter: vercel(), | ||
target: '#svelte', | ||
}, | ||
}; |
Oops, something went wrong.