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

      
      
      
      
相关推荐
梦道长生18 天前
Hexo 个人博客配置记录(GitHub Pages + Butterfly 主题 + Waline 评论 + 自动部署)
github·hexo·个人博客·waline·vercel
荔枝吻1 个月前
【沉浸式解决问题】csdn无法发布文章
csdn
gavin carter1 个月前
gitHub hexo 个人博客升级版
python·github·hexo
CSharp精选营1 个月前
Hexo-butterfly 接入腾讯混元大模型自动生成文章摘要(保姆教程)
hexo·butterfly·腾讯混元·生成摘要
在未来等你1 个月前
SQL进阶之旅 Day 15:动态SQL与条件查询构建
数据库·sql·csdn·动态sql·条件查询
结构化知识课堂1 个月前
Axure RP完全掌握指南:从入门到精通的系统化学习路线
javascript·axure·csdn·原型设计·axure教程·axure学习·axure课程
CSharp精选营2 个月前
小白也能行!10分钟用Cursor搭建个人博客网站(零基础教程)
hexo·github pages·个人博客·cursor
Silence4Allen2 个月前
零基础用 Hexo + Matery 搭建博客|Github Pages 免费部署教程
github·hexo·博客搭建·matery
寒山李白2 个月前
CSDN积分详解(介绍、获取、用途)
csdn·积分·收益
寒山李白2 个月前
关于CSDN创作的常用模板内容
csdn·创作模板·常用模板