Server rendering the data directly loaded into the component #9075
Unanswered
nisarhassan12
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In
routes/api/posts
I have a file named+server.ts
which upon a get request sends a JSON array as the response. I'm not able to figure out how do I get and render the response from within a component(not a page/route) in a way it gets server-rendered.The reason why I can't fetch this data first in
+page.ts
and then return it from theload
function which can then be accessed in+page.svelte
and passed down as a prop is that I'm using a visual CMS that requires us to have the pages in thesrc/content
directory in.md
files.In
routes/[...slug]/+page.ts
I'm importing all the markdown files and then returning the correct page data based on the slug parameter, which components to dynamically import on the server and server render on a specific page is specified under more details.More details
What components to render on which page is specified in the markdown frontmatter as follows:
This is how I dynamically import the components on the server
The following is how I render them in
routes/[...slug]/+page.svelte
Beta Was this translation helpful? Give feedback.
All reactions