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

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

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

  1. 将下载好的md文章适配hexo格式,如 title、 tags 。。。代码如下


/* 文件名: 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} 更新成功`);
        }
      });
    });
  });
});

      
      
      
      

相关推荐

  1. csdn文章迁移/历程实践

    2024-04-14 05:00:05       43 阅读
  2. Go GORM中的迁移系统,实现自动迁移手动迁移

    2024-04-14 05:00:05       29 阅读
  3. 昇思MindSpore 应用学习-ResNet50迁移学习-CSDN

    2024-04-14 05:00:05       20 阅读
  4. CSDN文章导出PDF整理状况一览

    2024-04-14 05:00:05       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-14 05:00:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-14 05:00:05       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-14 05:00:05       87 阅读
  4. Python语言-面向对象

    2024-04-14 05:00:05       96 阅读

热门阅读

  1. 进程线程的关系

    2024-04-14 05:00:05       45 阅读
  2. libftdi1学习笔记 1 - 打开/关闭设备

    2024-04-14 05:00:05       39 阅读
  3. 设计模式之责任链讲解

    2024-04-14 05:00:05       42 阅读
  4. 基于机器学习的节日大促营销模型

    2024-04-14 05:00:05       158 阅读
  5. Vue2基础知识

    2024-04-14 05:00:05       113 阅读
  6. C语言CRC通用模块代码

    2024-04-14 05:00:05       38 阅读
  7. Docker in Docker简介

    2024-04-14 05:00:05       43 阅读