commit 9069e4673bf74e671b7a6744911775145a1062be Author: Evan You Date: Sun Apr 26 16:30:56 2020 -0400 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9b1a20c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +node_modules +dist +TODOs.md +playground +*.log +test/temp diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..38d9aa9a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +semi: false +singleQuote: true +printWidth: 80 +trailingComma: none diff --git a/README.md b/README.md new file mode 100644 index 00000000..3bfdc13d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## Problems to Fix + +- Should not require vue-router +- Should not require chunk metadata for each page +- Should only inline site metadata that is used in runtime code (detect via proxy created with `useSiteData()`) +- Should use stringified site metadata +- i18n data should be fetched on demand diff --git a/bin/vitepress.js b/bin/vitepress.js new file mode 100755 index 00000000..5d1554e3 --- /dev/null +++ b/bin/vitepress.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../dist') diff --git a/package.json b/package.json new file mode 100644 index 00000000..15df9dba --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "vitepress", + "version": "0.1.0", + "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "bin": { + "vitepress": "bin/vitepress.js" + }, + "scripts": { + "dev": "tsc -w -p ." + }, + "keywords": [ + "vite", + "vuepress" + ], + "author": "Evan You", + "license": "MIT", + "dependencies": {}, + "devDependencies": { + "typescript": "^3.8.3" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..70d79a16 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,25 @@ +import { createServer, Plugin } from 'vite' +import path from 'path' +import { promises as fs } from 'fs' + +const indexTemplate = fs.readFile(path.join(__dirname, '../theme/index.html')) + +const VitePressPlugin: Plugin = ({ root, app }) => { + app.use(async (ctx, next) => { + // redirect request to index.html + if (ctx.path === '/index.html') { + ctx.body = await indexTemplate + return + } + + return next() + }) + + app.use(async (ctx, next) => {}) +} + +createServer({ + plugins: [VitePressPlugin] +}).listen(3000, () => { + console.log('listening on http://localhost:3000') +}) diff --git a/theme/index.html b/theme/index.html new file mode 100644 index 00000000..4effa19f --- /dev/null +++ b/theme/index.html @@ -0,0 +1 @@ +hello! diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..98bdbf01 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "outDir": "./dist", + "module": "commonjs", + "lib": ["ESNext"], + "sourceMap": false, + "target": "esnext", + "moduleResolution": "node", + "esModuleInterop": true, + "declaration": true, + "allowJs": false, + "allowSyntheticDefaultImports": true, + "noUnusedLocals": true, + "strictNullChecks": true, + "noImplicitAny": true, + "removeComments": false, + "preserveSymlinks": true + }, + "include": ["src"] +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..73c57885 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +typescript@^3.8.3: + version "3.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" + integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==