Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat: show example config
Browse files Browse the repository at this point in the history
  • Loading branch information
hanspagel committed Dec 13, 2023
1 parent 54bda26 commit 4d27fd0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions demo/src/components/CodeExample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ const props = defineProps<{
const code = ref('')
const highlightedCode = ref('')
const highlightedRequest = ref('')
onMounted(async () => {
// Code
const source = undici(props.request)
code.value = await snippetz().get(source)
code.value = snippetz().get(source)
// Syntax highlighting for the code
const shiki = await getHighlighter({
themes: ['nord'],
langs: [source.target],
langs: [source.target, 'json'],
})
await shiki.loadTheme('vitesse-dark')
await shiki.loadLanguage(source.target)
highlightedCode.value = shiki.codeToHtml(code.value, { lang: source.target, theme: 'vitesse-dark' })
highlightedRequest.value = shiki.codeToHtml(JSON.stringify(props.request, null, 2), { lang: 'json', theme: 'vitesse-dark' })
})
</script>

Expand All @@ -33,6 +36,7 @@ onMounted(async () => {
<div class="title">
{{ target }}
</div>
<div class="configuration" v-html="highlightedRequest" />
<div class="container" v-html="highlightedCode" />
</div>
</template>
Expand All @@ -43,16 +47,20 @@ onMounted(async () => {
border-radius: 4px;
font-family: monospace;
}
.configuration {
border-bottom: 2px solid #343a40;
}
.title {
background: #343a40;
color: #868e96;
padding: 0.5rem 1rem calc(0.5rem + 2px);
}
.configuration >>> pre,
.container >>> pre {
margin: 0;
padding: 1rem;
padding: 0.75rem;
}
pre code {
Expand Down

0 comments on commit 4d27fd0

Please sign in to comment.