@@ -17,7 +17,10 @@ import { ref } from 'vue'
17
17
import { fetchGlobalDebug } from ' ~/composables/fetch'
18
18
import { devtoolsClient } from ' ~/composables/rpc'
19
19
import { loadShiki } from ' ~/composables/shiki'
20
+ import { CreateOgImageDialogPromise } from ' ~/composables/templates'
20
21
import { separateProps } from ' ../src/runtime/shared'
22
+ import CreateOgImageDialog from ' ./components/CreateOgImageDialog.vue'
23
+ import { ogImageRpc } from ' ./composables/rpc'
21
24
import {
22
25
description ,
23
26
hasMadeChanges ,
@@ -165,7 +168,16 @@ function toggleSocialPreview(preview?: string) {
165
168
}
166
169
167
170
const activeComponentName = computed (() => {
168
- return optionsOverrides .value ?.component || options .value ?.component || ' NuxtSeo'
171
+ let componentName = optionsOverrides .value ?.component || options .value ?.component || ' NuxtSeo'
172
+ for (const componentDirName of (globalDebug ?.value ?.runtimeConfig .componentDirs || [])) {
173
+ componentName = componentName .replace (componentDirName , ' ' )
174
+ }
175
+ return componentName
176
+ })
177
+
178
+ const isOgImageTemplate = computed (() => {
179
+ const component = globalDebug .value ?.componentNames ?.find (c => c .pascalName === activeComponentName .value )
180
+ return component ?.path .includes (' node_modules' ) || component ?.path .includes (' og-image/src/runtime/app/components/Templates/Community/' )
169
181
})
170
182
171
183
const renderer = computed (() => {
@@ -261,10 +273,21 @@ const currentPageFile = computed(() => {
261
273
// get the path only from the `pages/<path>`
262
274
return ` pages/${path ?.split (' pages/' )[1 ]} `
263
275
})
276
+
277
+ async function ejectComponent(component : string ) {
278
+ const dir = await CreateOgImageDialogPromise .start (component )
279
+ if (! dir )
280
+ return
281
+ // do fix
282
+ const v = await ogImageRpc .value ! .ejectCommunityTemplate (` ${dir }/${component }.vue ` )
283
+ // open
284
+ await devtoolsClient .value ?.devtools .rpc .openInEditor (v )
285
+ }
264
286
</script >
265
287
266
288
<template >
267
289
<div class =" relative n-bg-base flex flex-col" >
290
+ <CreateOgImageDialog />
268
291
<header class =" sticky top-0 z-2 px-4 pt-4" >
269
292
<div class =" flex justify-between items-start" mb2 >
270
293
<div class =" flex space-x-5" >
@@ -468,9 +491,10 @@ const currentPageFile = computed(() => {
468
491
<NButton v-if =" !isPageScreenshot" icon =" carbon:html" :border =" imageFormat === 'html'" @click =" patchOptions({ extension: 'html' })" />
469
492
</div >
470
493
<div class =" text-xs" >
471
- <div v-if =" !isPageScreenshot" class =" opacity-70 space-x-1 hover:opacity-90 transition cursor-pointer" @click =" openCurrentComponent" >
472
- <span >{{ activeComponentName.replace('OgImage', '') }}</span >
473
- <span class =" underline" >View source</span >
494
+ <div v-if =" !isPageScreenshot" class =" opacity-70 space-x-1 hover:opacity-90 transition cursor-pointer" >
495
+ <span >{{ activeComponentName }}</span >
496
+ <span v-if =" isOgImageTemplate" class =" underline" @click =" ejectComponent(activeComponentName)" >Eject Component</span >
497
+ <span v-else class =" underline" @click =" openCurrentComponent" >View Source</span >
474
498
</div >
475
499
<div v-else >
476
500
Screenshot of the current page.
0 commit comments