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} 更新成功`);
        }
      });
    });
  });
});

      
      
      
      
相关推荐
明明明h11 天前
复制他人 CSDN 文章到自己的博客
博客·csdn
BD_Marathon1 个月前
怎么在CSDN上赚钱?
csdn
Soujer2 个月前
记一次CSDN认证模块后端未校验漏洞
安全威胁分析·漏洞分析·csdn
爱摸鱼的孔乙己2 个月前
细说文件操作
c语言·开发语言·数据结构·数据库·csdn
爱摸鱼的孔乙己3 个月前
【C语言】结构体(及位段)
c语言·开发语言·数据结构·c++·csdn
real_metrix3 个月前
【教程】Hexo 部署到 Github Page 后,自定义域名失效的问题
hexo·github page
Gzzz__3 个月前
百度、谷歌、必应收录个人博客网站
博客·hexo·butterfly
Silverados3 个月前
非常疑惑文章变成了仅VIP可读
csdn
北桥苏4 个月前
Hexo最新实战:(一)Hexo7.0+GitHub Pages博客搭建
github·hexo·github pages
咸鱼运维杂谈5 个月前
hexo 博客插入本地图片时遇到的坑
linux·运维·hexo