Skip to content

Create a CLI tool to browse examples #4

@fabiancook

Description

@fabiancook

🚀 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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions