Skip to content

Commit

Permalink
docs: use block component example for code snippets
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <[email protected]>
  • Loading branch information
ZTL-UwU committed Jan 19, 2025
1 parent 0ec49fd commit 9aa194c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 12 deletions.
2 changes: 1 addition & 1 deletion components/content/CodeSnippet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {
highlights?: string;
meta?: string;
start?: number;
offset?: string;
offset?: number;
}>();
const loadedCode = ref('');
Expand Down
72 changes: 61 additions & 11 deletions content/2.components/2.docs/code-snippet.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,101 @@ badges:

::stack
::div{class="p-4"}
:code-snippet{file="/components/DarkModeToggle.vue" language="vue"}
::code-snippet
---
file: /components/DarkModeToggle.vue
language: vue
---
::
::
```mdc
:code-snippet{file="/components/DarkModeToggle.vue" language="vue"}
::code-snippet
---
file: /components/DarkModeToggle.vue
language: vue
---
::
```
::

### Highlighting Lines

::stack
::div{class="p-4"}
:code-snippet{file="/composables/useBreadcrumb.ts" language="ts" title="useBreadcrumb" highlights="9-11" meta="line-numbers height=300"}
::code-snippet
---
file: /composables/useBreadcrumb.ts
language: ts
title: useBreadcrumb
highlights: 9-11
meta: line-numbers height=300
---
::
::
```mdc
:code-snippet{file="/composables/useBreadcrumb.ts" language="ts" title="useBreadcrumb" highlights="9-11" meta="line-numbers height=300"}
::code-snippet
---
file: /composables/useBreadcrumb.ts
language: ts
title: useBreadcrumb
highlights: 9-11
meta: line-numbers height=300
---
::
```
::

Translates to:

````md
```ts [useBreadcrumb] {9-11} line-numbers height=300
`````md
````ts [useBreadcrumb] {9-11} line-numbers height=300
// code imported from /composables/useBreadcrumb.ts
```
````
`````

### Using Offset Props

::stack
::div{class="p-4"}
:code-snippet{file="/composables/useBreadcrumb.ts" language="ts" start="6" offset="4"}
::code-snippet
---
file: /composables/useBreadcrumb.ts
language: ts
start: 6
offset: 4
---
::
::
```mdc
:code-snippet{file="/composables/useBreadcrumb.ts" language="ts" start="6" offset="4"}
::code-snippet
---
file: /composables/useBreadcrumb.ts
language: ts
start: 6
offset: 4
---
::
```
::

### Fetching From a Remote URL

::stack
::div{class="p-4"}
:code-snippet{url="https://raw.githubusercontent.com/ZTL-UwU/shadcn-docs-nuxt/refs/heads/main/pages/index.vue" language="vue"}
::code-snippet
---
url: https://raw.githubusercontent.com/ZTL-UwU/shadcn-docs-nuxt/refs/heads/main/pages/index.vue
language: vue
---
::
::
```mdc
:code-snippet{url="https://raw.githubusercontent.com/ZTL-UwU/shadcn-docs-nuxt/refs/heads/main/pages/index.vue" language="vue"}
::code-snippet
---
url: https://raw.githubusercontent.com/ZTL-UwU/shadcn-docs-nuxt/refs/heads/main/pages/index.vue
language: vue
---
::
```
::

Expand Down

0 comments on commit 9aa194c

Please sign in to comment.