11<script setup>
22import { ref , computed , onMounted } from ' vue'
3+ import MarkdownIt from ' markdown-it'
4+ import Modal from ' ./Modal.vue'
35
46const props = defineProps ({
57 title: { type: String , default: ' Plugin Registry' },
@@ -11,6 +13,33 @@ const loading = ref(true)
1113const searchQuery = ref (' ' )
1214const activeCategory = ref (' All' )
1315
16+ // Docs Modal Logic
17+ const showModal = ref (false )
18+ const modalTitle = ref (' ' )
19+ const modalContent = ref (' ' )
20+ const loadingDocs = ref (false )
21+ const md = new MarkdownIt ({ html: true , linkify: true })
22+
23+ const fetchDocs = async (plugin ) => {
24+ modalTitle .value = plugin .name
25+ modalContent .value = ' '
26+ showModal .value = true
27+ loadingDocs .value = true
28+
29+ try {
30+ const res = await fetch (plugin .readme )
31+ if (! res .ok ) throw new Error (' Failed to load README' )
32+ const text = await res .text ()
33+ // Simple sanitization or just render
34+ modalContent .value = md .render (text)
35+ } catch (e) {
36+ modalContent .value = ` <p class="text-error">Failed to load documentation: ${ e .message } </p>
37+ <p><a href="${ plugin .repo } " target="_blank" rel="noopener noreferrer">View on GitHub</a></p>`
38+ } finally {
39+ loadingDocs .value = false
40+ }
41+ }
42+
1443// Fetch data
1544const fetchPlugins = async () => {
1645 loading .value = true
@@ -75,6 +104,16 @@ function copyToClipboard(text) {
75104 <p class =" page-description" >{{ description }}</p >
76105 </div >
77106
107+ <!-- Docs Modal -->
108+ <Modal :show =" showModal " :title =" modalTitle " @close =" showModal = false " >
109+ <template #body >
110+ <div v-if =" loadingDocs" class =" flex justify-center p-8" >
111+ <div class =" spinner" ></div >
112+ </div >
113+ <div v-else class =" markdown-body vp-doc" v-html =" modalContent" ></div >
114+ </template >
115+ </Modal >
116+
78117 <div class =" plugin-registry space-y-8" >
79118 <!-- Search & Filter Controls -->
80119 <div class =" controls-wrapper glass-panel" >
@@ -138,7 +177,7 @@ function copyToClipboard(text) {
138177 </div >
139178
140179 <div class =" card-footer" >
141- <a :href = " plugin.readme " target = " _blank " class =" VPButton alt action-btn" >Docs</a >
180+ <button @click = " fetchDocs( plugin) " class =" VPButton alt action-btn" >Docs</button >
142181 <a :href =" plugin.download" class =" VPButton brand action-btn" >Download</a >
143182 </div >
144183 </div >
0 commit comments