Skip to content

Commit 3d49885

Browse files
committed
fix(SchemaOrgDebug): use props.console
1 parent 5d46947 commit 3d49885

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/schema-org/runtime/components/SchemaOrgDebug.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const SchemaOrgDebug = defineComponent({
88
default: false,
99
},
1010
},
11-
setup() {
11+
setup(props) {
1212
const schemaRaw = ref('')
1313
let observer: MutationObserver
1414

@@ -20,7 +20,7 @@ export const SchemaOrgDebug = defineComponent({
2020

2121
const fetchSchema = () => {
2222
$el = document.querySelector('script[data-id="schema-org-graph"]')
23-
schemaRaw.value = $el?.innerText
23+
schemaRaw.value = $el?.textContent || ''
2424
}
2525

2626
// Create an observer instance linked to the callback function
@@ -38,6 +38,13 @@ export const SchemaOrgDebug = defineComponent({
3838
})
3939
})
4040

41+
if (props.console) {
42+
watch(schemaRaw, (val) => {
43+
// eslint-disable-next-line no-console
44+
console.info('[SchemaOrgDebug]', JSON.parse(val))
45+
})
46+
}
47+
4148
onBeforeUnmount(() => {
4249
observer?.disconnect()
4350
})

0 commit comments

Comments
 (0)