up seo
This commit is contained in:
39
scripts/seo-static-generator/debug.js
Normal file
39
scripts/seo-static-generator/debug.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 调试脚本
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
console.log('当前工作目录:', process.cwd());
|
||||
console.log('脚本目录:', __dirname);
|
||||
console.log('输出目录:', path.resolve(__dirname, 'static-pages'));
|
||||
|
||||
const OUTPUT_DIR = path.resolve(__dirname, 'static-pages');
|
||||
|
||||
console.log('\n创建目录...');
|
||||
try {
|
||||
if (!fs.existsSync(OUTPUT_DIR)) {
|
||||
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
||||
console.log('目录创建成功:', OUTPUT_DIR);
|
||||
} else {
|
||||
console.log('目录已存在:', OUTPUT_DIR);
|
||||
}
|
||||
|
||||
// 写入测试文件
|
||||
const testFile = path.join(OUTPUT_DIR, 'test.html');
|
||||
fs.writeFileSync(testFile, '<!DOCTYPE html><html><body>测试</body></html>', 'utf-8');
|
||||
console.log('测试文件写入成功:', testFile);
|
||||
|
||||
// 读取文件验证
|
||||
const content = fs.readFileSync(testFile, 'utf-8');
|
||||
console.log('文件内容:', content);
|
||||
|
||||
} catch (error) {
|
||||
console.error('错误:', error.message);
|
||||
console.error('错误堆栈:', error.stack);
|
||||
}
|
||||
Reference in New Issue
Block a user