博客园支持备份功能:

导出内容并生成markdown文件发布到github pages_ico

操作时间是:

工作日18:00之后、8点之前或周六、周日进行备份。

点击备份,可以选择时间段,导出以后,是xml格式,样例格式如下:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>博客园-徐同保</title>
<link>https://www.cnblogs.com/xutongbao/</link>
<description>web前端行业的小学生</description><language>zh-cn</language>
<lastBuildDate>Mon, 13 Sep 2021 10:50:44 GMT</lastBuildDate>
<pubDate>Mon, 13 Sep 2021 10:50:44 GMT</pubDate><ttl>60</ttl>

<item><title>pagic Deno + React 驱动的静态网站生成器 入门</title>
<link>http://www.cnblogs.com/xutongbao/archive/2021/09/10/15264299.html</link>
<dc:creator>徐同保</dc:creator><author>徐同保</author>
<pubDate>Fri, 10 Sep 2021 03:03:00 GMT</pubDate>
<guid>http://www.cnblogs.com/xutongbao/archive/2021/09/10/15264299.html</guid>
<description>
<![CDATA[
<p>安装:</p>
<pre><code class="language-bash"># 安装 pagic
deno install --unstable --allow-read --allow-write --allow-net --allow-run --name=pagic https://deno.land/x/pagic/mod.ts</code></pre>
<p><img alt="" height="664" src="https://img-blog.csdnimg.cn/20210910105934798.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_20,color_FFFFFF,t_30,g_se,x_16" width="677"></p>
<p><img alt="" height="113" src="https://img-blog.csdnimg.cn/20210910110003759.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_20,text_Q1NETiBA5b6Q5ZCM5L-d,size_13,color_FFFFFF,t_70,g_se,x_16" width="344"></p>
<p>pagic.config.ts:</p>
<pre><code class="language-javascript">export default {}</code></pre>
<p>README.md:</p>
<pre><code class="language-bash"># Hello world
</code></pre>
<p>启动:</p>
<pre><code class="language-bash"># 运行 pagic
pagic build --watch --serve</code></pre>
<p>效果:</p>
<p><img alt="" height="447" src="https://img-blog.csdnimg.cn/20210910110203443.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_20,color_FFFFFF,t_30,g_se,x_16" width="1200"></p>
<p></p>
<p></p>
<p></p>
<p></p>
]]>
</description>
</item>


<item>
<title>antd Form.Item label添加解释信息</title>
<link>http://www.cnblogs.com/xutongbao/archive/2021/09/10/15264300.html</link>
<dc:creator>徐同保</dc:creator>
<author>徐同保</author>
<pubDate>Fri, 10 Sep 2021 02:29:00 GMT</pubDate>
<guid>http://www.cnblogs.com/xutongbao/archive/2021/09/10/15264300.html</guid>
<description>
<![CDATA[
<p><img alt="" height="164" src="https://img-blog.csdnimg.cn/20210910102855685.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_20,text_Q1NETiBA5b6Q5ZCM5L-d,size_17,color_FFFFFF,t_70,g_se,x_16" width="435"></p>
<p></p>
<pre><code class="language-javascript"> <Col span={span} className={expandClassname}>
<Form.Item
label={
<span>
<span>是否添加</span>
<Tooltip
title='添加'
overlayClassName="m-tooltip"
>
<span className="m-help-wrap">
<Icon name="help"></Icon>
</span>
</Tooltip>
</span>
}
>
<Form.Item name="isAdd" noStyle>
<Select
placeholder="请选择"
allowClear
getPopupContainer={() =>
document.getElementById('m-content-wrap')
}
>
<Option value={1}>是</Option>
<Option value={0}>否</Option>
</Select>
</Form.Item>
</Form.Item>
</Col></code></pre>
<p></p>
]]></description>
</item>
</channel>
</rss>

 xml转md:

导出内容并生成markdown文件发布到github pages_ico_02

 csdn.js:

const fs = require('fs')
const html2md = require('html-to-md')
const { NodeHtmlMarkdown } = require('node-html-markdown')
const mommet = require('moment')
//搜索
const dataSearch = (req, res) => {
const { dataType = 0 } = req.body

let dataUrl = {
0: '/data.xml',
1: '/dataMiddle.xml',
2: '/data_9142.xml',
}[dataType]
const htmlStr = fs.readFileSync(__dirname + dataUrl, 'utf8')

//提取所有item标签存入数组中
let itemArr = []
htmlStr.replace(/<item(([\s\S])*?)<\/item>/g, (word) => {
itemArr.push(word)
return word
})

//md文件输出路径
const outputDir = `D:/source/blog/src/md`
removeFileDir(outputDir)

let mdFileNameArr = []
itemArr.forEach((item, index) => {
//提取标题
let title = ''
item.replace(/<title(([\s\S])*?)<\/title>/g, (word) => {
title = word.slice(7, word.length - 8)
return word
})

//提取标题
let pubDate = ''
item.replace(/<pubDate(([\s\S])*?)<\/pubDate>/g, (word) => {
pubDate = word.slice(9, word.length - 10)
return word
})

const pageDate = mommet(pubDate).format('YYYY-MM-DD HH:mm:ss')
const mdFileName = mommet(pubDate).format('YYYY-MM-DD_HH_mm_ss')

//提取博客内容
let content = ''
item.replace(/<!\[CDATA\[(([\s\S])*?)]]>/g, (word) => {
content = word.slice(9, word.length - 3)
return word
})
//把标题和内容组织在一起,形成md文件
const mdFile = `---
title: '${title}'
date: ${pageDate}
---
${html2md(content)}`

//创建md文件
mdFileNameArr.push(mdFileName)
fs.writeFile(`${outputDir}/${mdFileName}.md`, mdFile, function (err) {
if (err) {
return console.log('错误', err)
}
})
})

res.send({
state: 1,
data: {
count: itemArr.length,
mdFileNameArr,
},
message: 'md文件创建成功',
})
}

//删除文件夹下的所有文件和子文件夹,不删除该文件夹
const removeFileDir = (path) => {
let files = fs.readdirSync(path)
for (let item of files) {
let stats = fs.statSync(`${path}/${item}`)
if (stats.isDirectory()) {
removeFileDir(`${path}/${item}`)
} else {
fs.unlinkSync(`${path}/${item}`)
}
}
//fs.rmdirSync(path)
}

module.exports = {
csdnSearch: dataSearch,
}

 通过postman调接口,执行xml转markdown:

导出内容并生成markdown文件发布到github pages_xml_03

生成的md文件:

0.md:

---
title: 'pagic Deno + React 驱动的静态网站生成器 入门'
---
安装:

```
# 安装 pagic
deno install --unstable --allow-read --allow-write --allow-net --allow-run --name=pagic https://deno.land/x/pagic/mod.ts
```

![](https://img-blog.csdnimg.cn/20210910105934798.png?x-oss-processimage/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_20,color_FFFFFF,t_70,g_se,x_16)

![](https://img-blog.csdnimg.cn/20210910110003759.png?x-oss-processimage/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_13,color_FFFFFF,t_70,g_se,x_16)

pagic.config.ts:

```javascript
export default {}
```

README.md:

```
# Hello world

```

启动:

```
# 运行 pagic
pagic build --watch --serve
```

效果:

![](https://img-blog.csdnimg.cn/20210910110203443.png?x-oss-processimage/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_20,color_FFFFFF,t_70,g_se,x_16)

1.md:

---
title: 'antd Form.Item label添加解释信息'
---
![](https://img-blog.csdnimg.cn/20210910102855685.png?x-oss-processimage/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5b6Q5ZCM5L-d,size_17,color_FFFFFF,t_70,g_se,x_16)

```javascript
<Col span={span} className={expandClassname}>
<Form.Item
label={
<span>
<span>是否添加</span>
<Tooltip
title='添加'
overlayClassName="m-tooltip"
>
<span className="m-help-wrap">
<Icon name="help"></Icon>
</span>
</Tooltip>
</span>
}
>
<Form.Item name="isAdd" noStyle>
<Select
placeholder="请选择"
allowClear
getPopupContainer={() =>
document.getElementById('m-content-wrap')
}
>
<Option value={1}></Option>
<Option value={0}></Option>
</Select>
</Form.Item>
</Form.Item>
</Col>
```

使用vuepress-theme-reco把md转换成博客:

​https://github.com/vuepress-reco/vuepress-theme-reco​

导出内容并生成markdown文件发布到github pages_xml_04

 使用github pages发布博客:

导出内容并生成markdown文件发布到github pages_ico_05

 

导出内容并生成markdown文件发布到github pages_html_06

 

导出内容并生成markdown文件发布到github pages_html_07

博客:​​徐同保的博客​