This ties tightly into #5832
And although this exercise should try to be JS framework agnostic, picking Svelte isn't arbitrary:
I use the following site outline as a foundation for some of my thoughts below:
svelte
βββ content
βΒ Β βββ _index.md
βΒ Β βββ component.svelte
βΒ Β βββ data.json
βΒ Β βββ svelte
βΒ Β βββ _index.md
βΒ Β βββ component.svelte
βΒ Β βββ data.json
βΒ Β βββ mycomponent
βΒ Β βββ component.svelte
βΒ Β βββ data.json
βΒ Β βββ index.md
βββ layouts
βββ _default
βββ list.html
βββ list.js
βββ list.json
βββ single.html
βββ single.js
βββ single.json
With the above in mind, this PoC should:
The above are my initial first thoughts...
If Hugo started supporting Svelte things would be more awesome!
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.
Since there is no official support I thought I'd try my hand at bodging one myself. I just took the quickstart template from svelte and modified it a bit to work with hugo. Then I added hugo to the npm scripts. This was just thrown together so feel free contribute.
npx degit [email protected]:datwood/hugo-svelte.git hugo-svelte
cd hugo-svelte
npm install
npm run dev
npm run build
You website files end up in public/ including the svelte files.
I assume you have heard of MDsveX - a Svelte equivalent of MDX?
I haven't, but unless I'm missing something, it wouldn't help us much (it uses markdown-it to parse the markdown, for starters).
Mapping the example in that README into "my world" would maybe look like this:
# Hereβs a chart
{{ chart.linline }}{{ svelte.Load "Chart" }}{{ /chart.linline }}
Or maybe a predefined one:
{{ chart data="foo" }}
Or
{{ svelte component="Chart" }}
I'm not sure what looks "most pretty", but there is, in my eyes, certainly less ambiguity in the "Hugo variant".
I stopped using Hugo back in 2017 due to my difficulty with the Go templating. As a JS-only dev I really miss my console logs and the likes, and so seeing this thread gave me _tons_ of hope to be able to go back to Hugo!
I'm currently using Svelte + Sapper, and have extensive experience with Gatsby + React, so I might be of help in shaping the APIs. As long as it doesn't involve understanding Go, let me know how I can help, bep βΊοΈ
@DanielAtwood Thank you that worked perfect in my project nice and simple
fwiw mdsvex has moved from markdown-it to remark
Things seem to move a bit according to this discussion: Compiling Svelte with Go?. Particularly see https://github.com/evanw/esbuild/issues/8 and https://github.com/evanw/esbuild/issues/111.
Most helpful comment
If Hugo started supporting Svelte things would be more awesome!