Compare commits
No commits in common. "3d9617f06c026203425829c96e75f9b8c36ef130" and "d19401373fc14bf91200bd10f1c2b9e49b8ab36d" have entirely different histories.
3d9617f06c
...
d19401373f
|
|
@ -204,7 +204,6 @@ export function createContentServer(
|
|||
contentDir: string,
|
||||
port: number,
|
||||
distPath: string = distDir,
|
||||
host: string = "0.0.0.0",
|
||||
): ContentServer {
|
||||
let contentIndex: ContentIndex = {};
|
||||
|
||||
|
|
@ -264,12 +263,11 @@ export function createContentServer(
|
|||
// 创建 HTTP 服务器
|
||||
const server = createServer(handleRequest);
|
||||
|
||||
server.listen(port, host, () => {
|
||||
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
||||
console.log(`\n开发服务器已启动:http://${displayHost}:${port}`);
|
||||
server.listen(port, () => {
|
||||
console.log(`\n开发服务器已启动:http://localhost:${port}`);
|
||||
console.log(`内容目录:${contentDir}`);
|
||||
console.log(`静态资源目录:${distPath}`);
|
||||
console.log(`索引文件:http://${displayHost}:${port}/__CONTENT_INDEX.json\n`);
|
||||
console.log(`索引文件:http://localhost:${port}/__CONTENT_INDEX.json\n`);
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
@ -290,7 +288,6 @@ export function createContentServer(
|
|||
export const serveCommand: ServeCommandHandler = async (dir, options) => {
|
||||
const contentDir = resolve(dir);
|
||||
const port = parseInt(options.port, 10);
|
||||
const host = options.host || "0.0.0.0";
|
||||
|
||||
createContentServer(contentDir, port, distDir, host);
|
||||
createContentServer(contentDir, port);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ program
|
|||
.description('运行一个 web 服务器预览目录中的内容,并实时监听更新')
|
||||
.argument('[dir]', '要预览的目录', '.')
|
||||
.option('-p, --port <port>', '端口号', '3000')
|
||||
.option('-h, --host <host>', '主机地址', '0.0.0.0')
|
||||
.action(serveCommand);
|
||||
|
||||
program
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
export interface ServeOptions {
|
||||
port: string;
|
||||
host?: string;
|
||||
}
|
||||
|
||||
export interface CompileOptions {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function extractHeadings(content: string): TocNode[] {
|
|||
const slugger = new Slugger();
|
||||
|
||||
for (const line of lines) {
|
||||
const match = line.trim().match(/^(#{1,6})\s+(.+)$/);
|
||||
const match = line.match(/^(#{1,6})\s+(.+)$/);
|
||||
if (!match) continue;
|
||||
|
||||
const level = match[1].length;
|
||||
|
|
|
|||
Loading…
Reference in New Issue