'How to print blog post content in the source code of the page while importing '.md' files dynamically?

I'm putting together a blog with Sveltekit and markdown files. And my blog url structure differs from where my original writings in .md format are saved.

I can get the posts from the folder using dynamic import as:

<script>
    import { page } from '$app/stores';

    //get current post name
    const pageName = $page.url.pathname;
    const postUrl = pageName.split('/');
    var lastSegment = postUrl.pop() || postUrl.pop(); // handle potential trailing slash
</script>

{#await import(`../../posts/${lastSegment}.md`) then value}
    <svelte:component this={value.default} />
{/await}

and they are shown on the page but not in the source code. I'm sure it'll have an impact on SEO. So, my issue is, how can I display the content in the page's source?

p.s. I'm also using MDSVEX.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source