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

support filename for code block #1027

Closed
4 tasks done
Sepush opened this issue Jul 20, 2022 · 3 comments
Closed
4 tasks done

support filename for code block #1027

Sepush opened this issue Jul 20, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@Sepush
Copy link

Sepush commented Jul 20, 2022

Is your feature request related to a problem? Please describe.

I wan't a feature to show dir/filename of current code.

Describe the solution you'd like

same as nuxt docs
图片
may be we can add this on the top left
图片

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd brc-dd added the enhancement New feature or request label Jul 20, 2022
@brc-dd
Copy link
Member

brc-dd commented Jul 21, 2022

For now you can create some component like this:

<script setup lang="ts">
defineProps<{ title: string }>();
</script>

<template>
  <div :style="{ '--title': `'${title}'` }">
    <slot />
  </div>
</template>

<style scoped>
div :deep([class*='language-']:before) {
  content: var(--title);
}
</style>

Then in your markdown file you can to do:

<code-block title="index.ts">

```ts
console.log('hey there')
```

</code-block>

Demo: https://stackblitz.com/edit/vite-p9dak1

@Sepush
Copy link
Author

Sepush commented Jul 22, 2022

For now you can create some component like this:

<script setup lang="ts">
defineProps<{ title: string }>();
</script>

<template>
  <div :style="{ '--title': `'${title}'` }">
    <slot />
  </div>
</template>

<style scoped>
div :deep([class*='language-']:before) {
  content: var(--title);
}
</style>

Then in your markdown file you can to do:

<code-block title="index.ts">

```ts
console.log('hey there')
```

Demo: https://stackblitz.com/edit/vite-p9dak1

Thanks a lot. I can use this solution as a workaround now.

@brc-dd
Copy link
Member

brc-dd commented Jul 22, 2022

Let's track this one too on #728. I have modified its title. We'll probably be supporting something like this (#728 (comment)) directly in markdown:

```ts [index.ts]
const a: number = 1
```

So it would work with bare code blocks too.

@brc-dd brc-dd closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants