SvelteKit is a relatively new SSR framework for SvelteJS. We can compare it to NextJS, but instead of using React, it uses Svelte. In this tutorial, you'll learn how you can create a blog website with SvelteKit and Strapi as a CMS.
When I get to the part where I restart the server and go to: http://localhost:3000/posts
I get an error:
Error: Cannot find module ‘tailwindcss’
Require stack:
C:\svelte\frontend\node_modules\vite\dist\node\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (C:\svelte\frontend\postcss.config.cjs:1:21)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
Anyone have any ideas ?
I compared with the github rep & it all looks fine up to this stage.
TIA, Dave
My apologies if that was a little vague. From the svelte front-end created, what is the best way to reference/display media that has been uploaded via to the strapi cms?
Example for employees with photo media(this is for typescript, but its similar to javascript):
in src/routes/api/employees.json.ts
what i like is to have the return value (in this example .json. in the Endpoint filename => endpoint.json.ts)
import type {EndpointOutput} from '@sveltejs/kit'
export async function get(): Promise<EndpointOutput> {
const res = await fetch('http://localhost:1337/api/employees?populate=Photo')
const data = await res.json()
return {body: data}
}
With this procedure you will receive 4 types of image URLs => ‘large, small, medium and thumbnail’.
To populate all relations one could use wildcard * in query string
const res = await fetch('http://localhost:1337/api/employees?populate=*')
ps.: @Strapi-Team, please expand your posts example data with such media image relation.
You will probably get an error like this… page in load functions has been replaced by url and params on page new.svelte and [slug].svelte if you use the latest version of Sveltekit.
new.svelte
Replace page: {query}
by url: {searchParams}
in your Load function.
Hi, im kind of new in strapi, i can make the app but how do i deploy it? i mean, i can have both the strapi and the sveltekit in the same project or i have to make them separately? or theres a method to use them concurrently? help please
I have a problem to keep the login status. Even I make it enable in Users-Permissions => AUTH, USER (Sellect all for Authenticated and public)
I created Auth controller as like explained
Now, if we access /auth/me, we get 404 NotFoundError.
Like the post routes, Strapi doesn’t, by default, allow anyone to access this route either. So, let’s edit permissions like how we did earlier for the Authenticated role.
I’m new to web development, and totally new to both Strapi and Svelte, so forgive me if the answer to my question should be obvious.
I’m encountering issues with the Fetch Blog Posts section, just before the Posts Page section. All of the non-relational data renders just fine, but the author is always undefined.
I read in this thread that querying http://strapidomain:1337/api/type?populate=* would solve the issue, but whether I use populate=* or populate=author, the author field is never fetched by the query. For this reason, I think the issue is on the Strapi side rather than the Svelte side.
I also tried restarting the tutorial, and even cloning Sheriff’s source code from GitHub and starting from there, yet nothing seems to fetch this author field.
I’ve triple-checked my Strapi configuration too. Users, permissions, posts, everything is as the tutorial states it should be. Would anyone happen to know where I’m going wrong?