Skip to content

Import Code Snippets: support external sources #1496

Open
@jthegedus

Description

@jthegedus

Feature request

Import Code Snippets support is great, but from what I have seen in the docs and related issues fetching the snippet file from external sources is not supported. It would be great if this could be extended to import code snippets from files within other repos (or if I have missed something update the docs with an example of this).

What problem does this feature solve?

If I have a docs sites at orgname/docs-site-repo and examples at orgname/examples-repo I could then import snippets from my examples repo into the docs-site repo and not need to maintain two sets of the same code.

This would also allow reusing existing code samples.

What does the proposed API look like?

# local files
<<< @/filepath{highlightLines}

# external files
<<< https://url/file.extension{highlightLines}

How should this be implemented in your opinion?

The existing API would need to support the import string starting with https and a Promise return value so it can fetch.

Are you willing to work on this yourself?

I could certainly help, but am unsure where to start given the number of open issues wanting to change this functionality.

related:

additionally

I believe #750 is adding support for code-fencing, which is highly desired 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions