Skip to content

[next] markdown code block use cases (script, render, story, preview, ...) #315

@daKmoR

Description

@daKmoR

in markdown we currently have this

```js server
const foo = 'bar';
```

```js client
const foo = 'bar';
```

but we also have more

Markdown

## Overview

You will be able to...

Which will result in:

```js xxx
import { html } from 'lit';
const users = [
  { firstName: 'John', lastName: 'Doe' },
  { firstName: 'Jane', lastName: 'Doe' },
];
```

```js xxx
export const listOfUsers = () => html`
  <ul>
    ${users.map(user => html`<li>${user.firstName} ${user.lastName}</li>`)}
  </ul>
`;
```

```js xxx
export const listOfUsersWithFrame = () => html`
  <ul>
    ${users.map(user => html`<li>${user.firstName} ${user.lastName}</li>`)}
  </ul>
`;
```

which shows/executes the code at the place of the code block on the client
e.g. the above example would become

HTML

<h2>Overview</h2>
<p>You will be able to...</p>
<p>Which will result in:</p>

<mdjs-story mdjs-story-name="listOfUsers">
  <ul>
    <li>John Doe</li>
    <li>Jane Doe</li>
  </ul>
</mdjs-story>

<mdjs-preview mdjs-story-name="listOfUsersWithFrame">
  <pre><code>[...]</code></pre>
  <div slot="story">
    <ul>
      <li>John Doe</li><li>Jane Doe</li>
    </ul>
  </div>
</mdjs-preview>

Rendered

Screenshot 2022-03-07 at 09 24 18

Question

now the question is... would that make sense server-side as well? I guess... and what should the key be 🤔

should it retain the story? or a complete "new" set?

suggestion from the top of my head...

  • js server
  • js server inject
  • js server inject-frame
  • js client
  • js client inject (former js story )
  • js client inject-frame (former js story-preview )

hmmm inject, inject-frame seems not very intuitive... anyone got better ideas? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions