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

Create a CLI tool to browse examples #4

Open
fabiancook opened this issue Jun 15, 2021 · 0 comments
Open

Create a CLI tool to browse examples #4

fabiancook opened this issue Jun 15, 2021 · 0 comments

Comments

@fabiancook
Copy link
Contributor

🚀 Feature Proposal

Using import * as Examples from "@virtualstate/examples" you can access all the examples available from this repository.

This proposal is to use all the objects available with keys ending with ExampleInformation and use them to create a command line "book" of examples that can be stepped through.

Details

You can get all these matching keys using

import * as Examples from "@virtualstate/examples";

const informationKeys = Object.keys(Examples)
  .filter(key => key.endsWith("ExampleInformation");

informationKeys will be an array of strings

You can get the source of an individual key using

const { source } = Examples[key];

This will be a string of the original source for the example, however, if you use:

const { cleanerSource } = Examples[key];

Then I have applied some clean up steps to the source so that it is more readable.

To get the related VNode for an example, you can use:

const node = await Examples[key].import();
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

1 participant