diff --git a/src/admin/app/App.vue b/src/admin/app/App.vue
index fa90f7eb2..b0624b57b 100644
--- a/src/admin/app/App.vue
+++ b/src/admin/app/App.vue
@@ -9,36 +9,19 @@
-
+
diff --git a/src/admin/app/components/Editor.vue b/src/admin/app/components/Editor.vue
index 14afb85f7..785077c23 100644
--- a/src/admin/app/components/Editor.vue
+++ b/src/admin/app/components/Editor.vue
@@ -1,9 +1,13 @@
-
-
+
+
+
+
+
+
+
{{ previewUrl }}
+
+
+
+
+
diff --git a/src/admin/app/composables/index.ts b/src/admin/app/composables/index.ts
new file mode 100644
index 000000000..2d3d80bf1
--- /dev/null
+++ b/src/admin/app/composables/index.ts
@@ -0,0 +1 @@
+export * from './preview'
diff --git a/src/admin/app/composables/preview.ts b/src/admin/app/composables/preview.ts
new file mode 100644
index 000000000..b4e622c57
--- /dev/null
+++ b/src/admin/app/composables/preview.ts
@@ -0,0 +1,21 @@
+import { ref, computed } from 'vue3'
+import { useApi } from '../plugins/api'
+
+export const previewOrigin = ref('http://localhost:4000')
+export const previewPath = ref('/')
+export const previewUrl = computed(() => previewOrigin.value + previewPath.value)
+
+const api = useApi()
+
+export async function fetchPreviewOrigin() {
+ const { url } = (await api.get('/preview')) as any
+
+ previewOrigin.value = url
+}
+
+export function navigateToFile(filepath: string) {
+ previewPath.value = filepath
+ .replace(/\/\d+\./g, '/')
+ .replace(/\.md$/, '')
+ .replace(/\/index$/, '/')
+}
diff --git a/src/admin/app/pages/index.vue b/src/admin/app/pages/index.vue
index bc69796f6..d68ff2dac 100644
--- a/src/admin/app/pages/index.vue
+++ b/src/admin/app/pages/index.vue
@@ -16,6 +16,7 @@ import { reactive, defineComponent, onMounted, toRefs } from 'vue3'
import FilesTree from '../components/FilesTree.vue'
import Editor from '../components/Editor.vue'
import { useApi } from '../plugins/api'
+import { navigateToFile } from '../composables/preview'
export default defineComponent({
components: {
@@ -30,7 +31,10 @@ export default defineComponent({
currentFile: null
})
- const openFile = async file => (state.currentFile = await api.get(`/pages${file.path}`))
+ const openFile = async file => {
+ navigateToFile(file.path)
+ state.currentFile = await api.get(`/pages${file.path}`)
+ }
onMounted(async () => (state.files = await api.get('/pages')))
diff --git a/src/admin/app/pages/static.vue b/src/admin/app/pages/static.vue
index 23e83b118..91b2a6bb2 100644
--- a/src/admin/app/pages/static.vue
+++ b/src/admin/app/pages/static.vue
@@ -27,42 +27,27 @@
-