-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/storyblok/storyblok-svelte
- Loading branch information
Showing
11 changed files
with
145 additions
and
16 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
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
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,20 @@ | ||
{ | ||
"name": "my-app", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"dev": "svelte-kit dev", | ||
"build": "svelte-kit build", | ||
"package": "svelte-kit package", | ||
"preview": "svelte-kit preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-auto": "next", | ||
"@sveltejs/kit": "next", | ||
"svelte": "^3.44.0" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@storyblok/svelte": "^1.0.1", | ||
"axios": "^0.26.1" | ||
} | ||
} |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="description" content="Svelte demo app" /> | ||
<link rel="icon" href="%svelte.assets%/favicon.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
%svelte.head% | ||
</head> | ||
<body> | ||
<div>%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,9 @@ | ||
<script> | ||
import { storyblokEditable } from "@storyblok/svelte"; | ||
export let blok; | ||
</script> | ||
|
||
<div use:storyblokEditable={blok} class="py-2"> | ||
<h1 class="text-lg">{blok.name}</h1> | ||
</div> |
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,13 @@ | ||
<script> | ||
import { storyblokEditable, StoryblokComponent } from "@storyblok/svelte"; | ||
export let blok; | ||
</script> | ||
|
||
<div use:storyblokEditable={blok} class="flex py-8 mb-6"> | ||
{#each blok.columns as blok} | ||
<div class="flex-auto px-6"> | ||
<StoryblokComponent {blok} /> | ||
</div> | ||
{/each} | ||
</div> |
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,11 @@ | ||
<script> | ||
import { storyblokEditable, StoryblokComponent } from "@storyblok/svelte"; | ||
export let blok; | ||
</script> | ||
|
||
<div use:storyblokEditable={blok} class="px-6"> | ||
{#each blok.body as blok} | ||
<StoryblokComponent {blok} /> | ||
{/each} | ||
</div> |
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,12 @@ | ||
<script> | ||
import { storyblokEditable } from "@storyblok/svelte"; | ||
export let blok; | ||
</script> | ||
|
||
<div | ||
use:storyblokEditable={blok} | ||
class="py-8 mb-6 text-5xl font-bold text-center" | ||
> | ||
{blok.headline} | ||
</div> |
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,25 @@ | ||
<script> | ||
import { storyblokInit, apiPlugin } from "@storyblok/svelte"; | ||
import Feature from "../components/Feature.svelte"; | ||
import Grid from "../components/Grid.svelte"; | ||
import Page from "../components/Page.svelte"; | ||
import Teaser from "../components/Teaser.svelte"; | ||
storyblokInit({ | ||
accessToken: "OurklwV5XsDJTIE1NJaD2wtt", | ||
use: [apiPlugin], | ||
components: { | ||
// teaser: () => import("./Teaser.svelte"), // Lazy load it on demand | ||
feature: Feature, | ||
grid: Grid, | ||
page: Page, | ||
teaser: Teaser, | ||
}, | ||
}); | ||
console.log("teaser", Teaser); | ||
</script> | ||
|
||
<main> | ||
<slot /> | ||
</main> |
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,33 @@ | ||
<script context="module"> | ||
import { useStoryblokApi } from "@storyblok/svelte"; | ||
export async function load() { | ||
const storyblokApi = useStoryblokApi(); | ||
const { data } = await storyblokApi.get("cdn/stories/svelte", { | ||
version: "draft", | ||
}); | ||
return { | ||
status: 200, | ||
props: { story: data.story }, | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
import { onMount } from "svelte"; | ||
import { useStoryblokBridge, StoryblokComponent } from "@storyblok/svelte"; | ||
export let story; | ||
console.log(story, "story"); | ||
onMount(() => { | ||
useStoryblokBridge(story.id, (newStory) => (story = newStory)); | ||
}); | ||
</script> | ||
|
||
<div> | ||
{#if story} | ||
<StoryblokComponent blok={story.content} /> | ||
{/if} | ||
</div> |
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 @@ | ||
import { defineConfig } from "vite"; | ||
import { svelte } from "@sveltejs/vite-plugin-svelte"; | ||
|
||
export default defineConfig({ | ||
plugins: [svelte()], | ||
}); |