A continuation of HomeBox the inventory and organization system built for the Home User
Revert temp API test
Katos7279703d7c68
diff --git a/docs/en/api.md b/docs/en/api.mdindex add0ad99..fb9d1536 100644--- a/docs/en/api.md+++ b/docs/en/api.md@@ -4,28 +4,27 @@ sidebar: false---<script setup lang="ts">-import { ref, onMounted, watch, onBeforeUnmount } from 'vue';+import { ref, watch, onMounted, onBeforeUnmount } from 'vue';import { useData } from 'vitepress';-const apiSpec = ref(null);-const demoBaseUrl = "https://demo.homebox.software/api";+// Reactive key for re-rendering the elements-api component+const componentKey = ref(0);++// Set BaseURL+const BaseURL = "https://demo.homebox.software/api";++// Access dark mode setting from VitePress+const { isDark } = useData();+const theme = ref(isDark.value ? 'dark' : 'light');-// Fetch and patch the spec on mount-onMounted(async () => {- try {- const res = await fetch('https://cdn.jsdelivr.net/gh/sysadminsmedia/homebox@main/docs/docs/api/openapi-2.0.json');- const spec = await res.json();- // Override the host and basePath- spec.host = "demo.homebox.software";- spec.basePath = "/api";- apiSpec.value = spec;- } catch (error) {- console.error("Error fetching the OpenAPI spec:", error);- }+// Watch for changes to the dark mode value and force a re-render when it changes+watch(isDark, (newVal) => {+ theme.value = newVal ? 'dark' : 'light';+ // Increment key to force a refresh of the Stoplight component and its CSS+ componentKey.value++;});-// For navigation refresh-const componentKey = ref(0);+// Use a native hashchange listener (as before) to refresh on navigation changesconst handleHashChange = () => {componentKey.value++;};@@ -37,15 +36,7 @@ onBeforeUnmount(() => {window.removeEventListener('hashchange', handleHashChange);});-// Handle theme changes to re-render the component-const { isDark } = useData();-const theme = ref(isDark.value ? 'dark' : 'light');-watch(isDark, (newVal) => {- theme.value = newVal ? 'dark' : 'light';- componentKey.value++;-});--// Append Stoplight Elements script and stylesheet+// Append the Stoplight Elements script and stylesheetconst elementScript = document.createElement('script');elementScript.src = 'https://unpkg.com/@stoplight/elements/web-components.min.js';document.head.appendChild(elementScript);@@ -57,15 +48,13 @@ document.head.appendChild(elementStyle);</script><client-only>- <!-- Render only after the spec is loaded --><elements-api- v-if="apiSpec":key="componentKey"- :apiDescription="apiSpec"+ apiDescriptionUrl="https://cdn.jsdelivr.net/gh/sysadminsmedia/homebox@main/docs/docs/api/openapi-2.0.json"router="hash"layout="responsive"hideSchemas="true":data-theme="theme"- tryItBaseUrl="https://demo.homebox.software/api"+ :tryItBaseUrl="BaseURL"/></client-only>