csdn文章迁移/迁走历程与实践

从csdn迁移到博客园
  • 博客园官方本身支持,按流程迁移即可
从csdn 迁移到 hexo 的历程
  1. 获取csdn 全部文章链接

  2. 此平台批量转换并下载md文件

  1. 将下载好的md文章适配hexo格式,如 title、 tags 。。。代码如下
js 复制代码
/* 文件名: index.js */
const fs = require('fs');

// 获取目标文件夹路径
const folderPath = './';

// 读取目标文件夹中的文件列表
fs.readdir(folderPath, (err, files) => {
  if (err) {
    console.error('读取文件列表时出错:', err);
    return;
  }

  // 遍历每个文件
  files.forEach((file) => {
    // 构建文件路径
    const filePath = `${folderPath}/${file}`;

    // 读取文件内容
    fs.readFile(filePath, 'utf8', (err, data) => {
      if (err) {
        console.error(`读取文件 ${file} 时出错:`, err);
        return;
      }

      // 在文件内容顶部添加文件名
      const updatedData =`---\ntitle: ${file.replace(".md","")}\ncategories: 博客迁移\ntags: csdn\n---\n\n${data}`
    //    `/* 文件名: ${file} */\n${data}`;

      // 将更新后的内容写入文件
      fs.writeFile(filePath, updatedData, (err) => {
        if (err) {
          console.error(`写入文件 ${file} 时出错:`, err);
        } else {
          console.log(`文件 ${file} 更新成功`);
        }
      });
    });
  });
});

      
      
      
      
相关推荐
阿莫西林夹馍14 天前
hexo使用方法
hexo
Java后端的Ai之路15 天前
【CSDN创作者成长】-如何玩转 CSDN 投票功能?
csdn·投票·创作者
猫头虎21 天前
OpenClaw开源汉化发行版:介绍、下载、安装、配置教程
运维·windows·开源·aigc·ai编程·agi·csdn
猿小羽1 个月前
OkHttp vs Retrofit 技术分析报告 - 1769404939594
http·okhttp·retrofit·csdn
gjxDaniel1 个月前
什么是CSDN?
csdn开发云·csdn
mediocrep1 个月前
我的Hexo博客搭好了12 - 自动提交URL到搜索引擎(IndexNow + Google Search Console)
hexo·博客搭建·github pages·个人技术博客
mediocrep1 个月前
我的Hexo博客搭好了04 - 备份Hexo博客的源码目录,上传到Gitee仓库
hexo·博客搭建·github pages·个人技术博客
mediocrep1 个月前
我的Hexo博客搭好了10 - 怎么插入图片和视频
hexo·博客搭建·github pages·个人技术博客
竹之却1 个月前
【Hexo】Hexo搭建教程
github·hexo·blog
猫头虎1 个月前
2026年1月18日11时博客之星投票数据TOP100总排名预测:全网投票总数突破一万大关
程序人生·职场和发展·创业创新·业界资讯·程序员创富·csdn·博客之星