nuxt-live-editor
Version:
My new Nuxt module
22 lines (21 loc) • 603 B
JavaScript
import { useLiveEditorStore } from "../stores/useLiveEditorStore.mjs";
import { storeToRefs } from "pinia";
import { ref, watch } from "vue";
export const useContentAsync = (key, default_value) => {
const { data_live_editor_async } = storeToRefs(useLiveEditorStore());
const contentModal = ref(
data_live_editor_async.value[key] || default_value
);
watch(
() => data_live_editor_async.value[key],
(newVal) => {
contentModal.value = newVal;
}
);
watch(contentModal, (newVal) => {
data_live_editor_async.value[key] = newVal;
});
return {
contentModal
};
};