1
1
<script setup lang="ts">
2
2
import CodeExample from ' ./components/CodeExample.vue'
3
3
import { snippetz } from ' @scalar/snippetz'
4
- import { type ClientId } from ' @scalar/snippetz-core'
4
+ import { type ClientId , type TargetId } from ' @scalar/snippetz-core'
5
5
import { ref } from ' vue'
6
6
7
+ const selectedTarget = ref <ClientId >(' node' )
7
8
const selectedClient = ref <ClientId >(' undici' )
9
+
10
+ function selectPlugin(plugin : { target: TargetId , client: ClientId }) {
11
+ selectedTarget .value = plugin .target
12
+ selectedClient .value = plugin .client
13
+ }
8
14
</script >
9
15
10
16
<template >
@@ -22,18 +28,18 @@ const selectedClient = ref<ClientId>('undici')
22
28
Clients
23
29
</h2 >
24
30
25
- <button v-for =" plugin in snippetz().plugins()" :key =" plugin.client" class =" client" :class =" { 'client--selected': selectedClient === plugin.client }" @click =" () => selectedClient = plugin.client " >
26
- {{ plugin.client }}
31
+ <button v-for =" plugin in snippetz().plugins()" :key =" plugin.client" class =" client" :class =" { 'client--selected': selectedClient === plugin.client && selectedTarget === plugin.target }" @click =" () => { selectPlugin( plugin) } " >
32
+ {{ plugin.target }}/{{ plugin. client }}
27
33
</button >
28
34
29
35
<h2 >
30
36
Examples
31
37
</h2 >
32
38
33
39
<div class =" examples" >
34
- <CodeExample target =" node " :client =" selectedClient" :request =" { url: 'https://example.com' }" />
35
- <CodeExample target =" node " :client =" selectedClient" :request =" { url: 'https://example.com', method: 'POST' }" />
36
- <CodeExample target =" node " :client =" selectedClient" :request =" { url: 'https://example.com', method: 'POST', headers: [
40
+ <CodeExample : target =" selectedTarget " :client =" selectedClient" :request =" { url: 'https://example.com' }" />
41
+ <CodeExample : target =" selectedTarget " :client =" selectedClient" :request =" { url: 'https://example.com', method: 'POST' }" />
42
+ <CodeExample : target =" selectedTarget " :client =" selectedClient" :request =" { url: 'https://example.com', method: 'POST', headers: [
37
43
{
38
44
name: 'Content-Type',
39
45
value: 'application/json'
0 commit comments