{"id":16886079,"url":"https://github.com/vdustr/example-vite-svelte-markdown","last_synced_at":"2025-10-12T08:32:16.745Z","repository":{"id":86692264,"uuid":"441672809","full_name":"VdustR/example-vite-svelte-markdown","owner":"VdustR","description":"This is an example for importing Markdown files as Svelte components.","archived":false,"fork":false,"pushed_at":"2023-10-08T08:28:17.000Z","size":186,"stargazers_count":6,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T08:51:21.592Z","etag":null,"topics":["demo","example","highlight","html-escaper","markdown","md","mdsvex","pnpm","shiki","shikijs","svelte","sveltejs","vite","vitejs","vscode"],"latest_commit_sha":null,"homepage":"https://vdustr.github.io/example-vite-svelte-markdown/","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VdustR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-25T12:16:38.000Z","updated_at":"2023-10-17T14:56:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"388768bb-4e5d-44aa-bd34-c03608cbe8cd","html_url":"https://github.com/VdustR/example-vite-svelte-markdown","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fexample-vite-svelte-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fexample-vite-svelte-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fexample-vite-svelte-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fexample-vite-svelte-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VdustR","download_url":"https://codeload.github.com/VdustR/example-vite-svelte-markdown/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248402368,"owners_count":21097328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","example","highlight","html-escaper","markdown","md","mdsvex","pnpm","shiki","shikijs","svelte","sveltejs","vite","vitejs","vscode"],"created_at":"2024-10-13T16:38:10.891Z","updated_at":"2025-10-12T08:32:16.662Z","avatar_url":"https://github.com/VdustR.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example for Svelte + TS + Vite + MDsveX\n\nThis is an example for importing Markdown files as Svelte components.\n\nWe'll use [`MDsveX`](https://github.com/pngwn/MDsveX) as our markdown pre-processor. Although there are some issues, it works pretty great for me with some workarounds.\n\nDemo: \u003chttps://vdustr.github.io/example-vite-svelte-markdown/\u003e\n\n## Dependencies\n\n- `vscode`@`^1.63.2` (for example. The editor for better DX.)\n- `pnpm`@`^6.24.2` (for example. Replace it with any other package manager you like)\n- `vite`@`^2.7.2` (for example)\n- `svelte`@`^3.44.0`\n- `mdsvex`@`^0.9.8`\n- `shiki`@`^0.9.15` (optional, for highlight)\n\n## Steps\n\nYou can pick any things you need only and skip the others.\n\n### Initial\n\nInitial a vite repo with `svelte` or `svelte-ts` template\n\n```bash\npnpm create vite\n```\n\n### Setup MDsveX\n\nYou can append this into `vite.config.js` simply for basic functions:\n\n```js\nexport default defineConfig({\n  plugins: [\n    svelte({\n      extensions: [\".svx\"],\n      preprocess: mdsvex(),\n    }),\n    svelte(),\n  ],\n});\n```\n\nHere the example for highlight with `shiki`. I got some problems and resolved them with workarounds.\n\n💡 Please check [`vite.config.js`](./vite.config.js) for more information. It might be the **MOST IMPORTANT** section in this example.\n\n### `.svx` Extension Name Association\n\nMDsveX use `.svx` as the default filename extension.\n\nIt's maybe not supported by the editor by default. It's a good choice that editing them in Markdown mode. Check [`.vscode/settings.json`](.vscode/settings.json) and append:\n\n```json\n{\n  \"files.associations\": {\n    \"*.svx\": \"markdown\"\n  }\n}\n```\n\nIf you use typescript for better DX, you can also make it import `.svx` files as Svelte component. Check [`./src/vite-env.d.ts`](./src/vite-env.d.ts) and append:\n\n```ts\ndeclare module \"*.svx\" {\n  export { SvelteComponentDev as default } from \"svelte/internal\";\n}\n```\n\n## License\n\n- Code: `mit`\n- README: `cc-by-sa-4.0`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdustr%2Fexample-vite-svelte-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdustr%2Fexample-vite-svelte-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdustr%2Fexample-vite-svelte-markdown/lists"}