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/postsI have a file named+server.tswhich 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.tsand then return it from theloadfunction which can then be accessed in+page.svelteand passed down as a prop is that I'm using a visual CMS that requires us to have the pages in thesrc/contentdirectory in.mdfiles.In
routes/[...slug]/+page.tsI'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.svelteBeta Was this translation helpful? Give feedback.
All reactions