limber icon indicating copy to clipboard operation
limber copied to clipboard

[Feature Request] GDM codeblocks can import/export between each other

Open sukima opened this issue 1 year ago • 1 comments

In GDM modes helpful for documentation I often wish I could show (preview) the implementation of a component, helper, modifier, etc. write some documentation and then show live examples of their use.

Currently to do this the entire implementation must be copy/pasted in every codeblock as there is not a way to import something from an earlier code block.

Suggestion

Offer a way to register a filename for a codeblock allowing other codeblocks to import them using a ./ relative path.

Perhaps maybe with a filename:{FILENAME} in the codefence metadata line?

sukima avatar Jan 06 '25 18:01 sukima

I'm a big fan -- based on your suggestion, it could look like this:

text here in md

```gjs live filename="demo-a"
export const DemoA = <template> ... </template>

<template>
  <DemoA />
</template>
```

```gjs live
import { DemoA } from './demo-a';

<template>
  Again! <DemoA />
</template>
```

NullVoxPopuli avatar Jan 06 '25 18:01 NullVoxPopuli