Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add embedding support to the REPL. #849

Open
Tropix126 opened this issue Nov 21, 2021 · 4 comments
Open

Add embedding support to the REPL. #849

Tropix126 opened this issue Nov 21, 2021 · 4 comments

Comments

@Tropix126
Copy link

Describe the problem

At the moment, setting up code examples in documentation sites is rather tedious due to svelte's compiled nature. You have a few options:

Describe the proposed solution

While all of these options are valid, I believe that this could be made easier. Similarly to sites such as YouTube that offer <iframe /> embedding, I think the site could offer an embeddable link to a specific REPL with just the input and output. This would have a few advantages:

  • Users would have access to the site's community features, such as forking and sharing their versions rather than a selfhosted solution being entirely self-contained.
  • The process for displaying interacitve examples would be made easier by a large magnitude, requiring very little setup and helping the ecosystem in the process.

Alternatives considered

Document https://github.com/sveltejs/svelte-repl and make it more easily adaptable to external environments.

Importance

would make my life easier

@Tropix126
Copy link
Author

Tropix126 commented Nov 21, 2021

With a little bit of digging I've discovered that the repl actually already supports this, but the functionality for loading usermade gists is broken. Passing in something such as https://svelte.dev/repl/embed?gist=1d80b906abca49e697dde437fd57be0a will cause an internal error. I've tracked the gist fetching problem down to this line; investigating further.

image

@Tropix126
Copy link
Author

Tropix126 commented Nov 21, 2021

I found the problem; the object being returned by Object.keys(files).map() is the wrong data.

const components = files.map(({ name, source }) => {
    const dot = name.lastIndexOf('.');
    if (!~dot) return;

    return {
        name: name.slice(0, dot),
        type: name.slice(dot + 1),
        source
    }
});

appears to return the correct data. Should I PR this?

@dummdidumm
Copy link
Member

In sveltejs/svelte#4866 (comment) @Conduitry expressed concerns about this, and I'm not sure how much that has changed. We have open collective money now though so the situation is different now.

@Tropix126
Copy link
Author

Ah, I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants