diff --git a/package.json b/package.json index a7dd93579..849ccd0b3 100755 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "dev": "ADMIN_DEV=true nuxt dev docs", "dev:nuxtjs": "nuxt dev nuxtjs.org", "dev:admin": "vite --config src/admin/app/vite.config.ts", + "build:admin": "vite build --config src/admin/app/vite.config.ts", "generate": "nuxt generate --force-build docs", "generate:nuxtjs": "nuxt generate --force-build nuxtjs.org", "start": "nuxt start docs", @@ -131,9 +132,12 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-nuxt": "^2.0.0", "eslint-plugin-prettier": "^3.4.0", + "monaco-editor": "^0.25.2", "prettier": "^2.3.1", "siroc": "^0.9.3", + "splitpanes": "^3.0.4", "standard-version": "^9.3.0", + "vite": "^2.3.8", "vite-plugin-components": "^0.11.2", "vite-plugin-icons": "^0.6.3" }, diff --git a/playground/pages/index.md b/playground/content/index.md similarity index 100% rename from playground/pages/index.md rename to playground/content/index.md diff --git a/src/admin/api/functions/content.ts b/src/admin/api/functions/content.ts index fbf08a54e..ce6b52bfc 100644 --- a/src/admin/api/functions/content.ts +++ b/src/admin/api/functions/content.ts @@ -1,15 +1,10 @@ import { promises as fs } from 'fs' import { join, extname } from 'path' -import matter from 'gray-matter' import { createError, Middleware, useBody } from 'h3' import dirTree from 'directory-tree' +import { FileData, File } from '../../type' import { normalizeFiles, r } from '../utils' -interface Body { - data: any - content: string -} - export default async function contentHandler(req) { const url = req.url @@ -23,13 +18,11 @@ export default async function contentHandler(req) { try { const path = join(r('content'), url) const file = await fs.readFile(path, 'utf-8') - const { content, data } = matter(file) - return { + return { path: path.replace(r('content'), ''), extension: extname(path), - data, - content + raw: file } } catch (err) { return createError({ @@ -41,12 +34,11 @@ export default async function contentHandler(req) { // Update changes if (req.method === 'PUT') { - const { data, content } = await useBody(req) - - if (!data || !content) { + const { raw } = await useBody(req) + if (raw == null) { return createError({ statusCode: 400, - statusMessage: 'data and content keys are required' + statusMessage: '"raw" key is required' }) } @@ -54,11 +46,8 @@ export default async function contentHandler(req) { try { // @ts-ignore - await fs.stat(path, 'utf-8') - - const file = matter.stringify(content, data) - - await fs.writeFile(path, file) + // await fs.stat(path, 'utf-8') + await fs.writeFile(path, raw) return { ok: true } } catch (err) { diff --git a/src/admin/app/App.vue b/src/admin/app/App.vue index b0624b57b..0792f3526 100644 --- a/src/admin/app/App.vue +++ b/src/admin/app/App.vue @@ -8,20 +8,9 @@ - - - diff --git a/src/admin/app/components/Editor.vue b/src/admin/app/components/Editor.vue index 31e784a8d..447fdfdeb 100644 --- a/src/admin/app/components/Editor.vue +++ b/src/admin/app/components/Editor.vue @@ -1,72 +1,35 @@