Skip to content

Commit

Permalink
feat(prose): fixed height code block
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <[email protected]>
  • Loading branch information
ZTL-UwU committed Nov 20, 2024
1 parent e62ef81 commit 4202d29
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
16 changes: 13 additions & 3 deletions components/content/ProseCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<CodeCopy :code />
</span>
<div class="bg-muted/30">
<UiScrollArea>
<UiScrollArea :style="[parsedMeta.has('height') && `height: ${parsedMeta.get('height')}px`]">
<div
class="overflow-x-auto py-3 text-sm"
:class="[
!inGroup && !filename && 'inline-copy',
!language && 'pl-3', !inGroup,
showLineNumber && 'show-line-number',
parsedMeta.has('line-numbers') && 'show-line-number',
]"
>
<slot />
Expand Down Expand Up @@ -54,7 +54,17 @@ const {
meta?: string;
}>();
const showLineNumber = computed(() => meta?.includes('line-numbers'));
const parsedMeta = computed(() => {
const split = meta?.split(' ') ?? [];
const params = new Map<string, string | undefined>();
for (const param of split) {
const [key, val] = param.split('=');
params.set(key, val);
}
return params;
});
const iconMap = new Map(Object.entries(useConfig().value.main.codeIcon));
const icon = computed(() => {
Expand Down
30 changes: 29 additions & 1 deletion content/2.components/1.prose.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ icon: lucide:letter-text
const line2 = 'This is line 2';
const line3 = 'This is line 3';
```

```ts [Fixed Height] height=150
const parsedMeta = computed(() => {
const split = meta?.split(' ') ?? [];
const params = new Map<string, string | undefined>();

for (const param of split) {
const [key, val] = param.split('=');
params.set(key, val);
}

return params;
});
```
::

````md [Code]
Expand All @@ -103,7 +117,21 @@ icon: lucide:letter-text
const line2 = 'This is line 2';
const line3 = 'This is line 3';
```
````

```ts [Fixed Height] height=150
const parsedMeta = computed(() => {
const split = meta?.split(' ') ?? [];
const params = new Map<string, string | undefined>();

for (const param of split) {
const [key, val] = param.split('=');
params.set(key, val);
}

return params;
});
```
````
::

### Inline Code
Expand Down

0 comments on commit 4202d29

Please sign in to comment.