Closed happypeter closed 6 years ago
mongoimport -d newcat -c episodes --file haoqiDoc.json
getDoc/index.js
const fs = require('fs')
const courseArr = require('./data')
const getDocObj = (file, course) => {
const [uid, prefix] = file.split('.')
const markdown = fs.readFileSync(
`../doc-haoqi/${course.uid}/doc/${file}`,
'utf-8'
)
const docObj = {
courseUid: course.uid,
uid,
markdown
}
return docObj
}
const getCourseDocs = course => {
const fileArr = fs.readdirSync(`../doc-haoqi/${course.uid}/doc`)
const courseDocs = fileArr.filter(t => t.split('.')[1] === 'md').map(file => {
return getDocObj(file, course)
})
return courseDocs
}
const getDocs = courseArr => {
return courseArr.reduce((arr, course) => {
arr = [...arr, ...getCourseDocs(course)]
return arr
}, [])
}
const docsArr = getDocs(courseArr)
let docs = docsArr.map(item => JSON.stringify(item)).join('\n')
fs.writeFileSync('haoqiDoc.json', docs)
console.log('The file has been restructured!')
getDoc/data.js
const courseArr = [
{
serialNo: '61',
title: 'Material UI 自定制',
uid: 'mui-cat'
},
{
serialNo: '60',
title: 'React 图片上传',
uid: 'img-upload'
},
{
serialNo: '59',
title: 'JWT 破冰',
uid: 'jwt'
},
{
serialNo: '58',
title: 'Express 实作 API (第二版)',
uid: 'express-love-api-v2'
},
{
serialNo: '57',
title: 'Ajax 摩登之旅',
uid: 'ajax-tour'
},
{
serialNo: '56',
title: 'React-static 摩登静态化之路',
uid: 'react-static-way'
},
{
serialNo: '55',
title: 'React 社交化电商--架构篇(第二版)',
uid: 'yummy-v2'
},
{
serialNo: '54',
title: '函数式编程',
uid: 'fp'
},
{
serialNo: '53',
title: 'React 项目测试',
uid: 'test-react'
},
{
serialNo: '52',
title: 'Gulp Flexbox 响应式网站(第二版)',
uid: 'gulp-flex-res-v2'
},
{
serialNo: '51',
title: 'React 婴儿(第三版)',
uid: 'react-baby-v3'
},
{
serialNo: '50',
title: 'JS 面向对象之旅(第二版)',
uid: 'o-o-js-v2'
},
{
serialNo: '49',
title: '用 gitbook 做笔记',
uid: 'gitbook'
},
{
serialNo: '48',
title: '好奇图书馆',
uid: 'haoqi-lib'
},
{
serialNo: '47',
title: 'redux 实现 Todo App',
uid: 'redux-todo'
},
{
serialNo: '46',
title: 'VSCode 爱上 JS',
uid: 'vscode'
},
{
serialNo: '45',
title: 'Hello Vuex 第二版',
uid: 'vuex-hello-v2'
},
{
serialNo: '44',
title: '塔顶上的 redux 第二版',
uid: 'redux-tower-v2'
},
{
serialNo: '43',
title: 'Hello Redux 第三版',
uid: 'redux-hello-v3'
},
{
serialNo: '42',
title: '用 redux 实现购物车',
uid: 'redux-cart'
},
{
serialNo: '41',
title: '定制 Videojs 播放器',
uid: 'happy-videojs'
},
{
serialNo: '40',
title: '用 Gatsby 开发 SPA 架构的博客',
uid: 'gatsby'
},
{
serialNo: '2',
title: 'Meteor-React 小鸟课程',
uid: 'meteor-react-bird'
},
{
serialNo: '3',
title: 'Happypeter 的摩登 JS 王国',
uid: 'happypeter-js-kingdom'
},
{
serialNo: '4',
title: 'Webpack-React 鼹鼠',
uid: 'webpack-react-mole'
},
{
serialNo: '6',
title: '驾驭命令行怪兽',
uid: 'ride-cli-monster'
},
{
serialNo: '7',
title: '跟 Peter 学 HTTP',
uid: 'http-with-peter'
},
{
serialNo: '8',
title: 'Flexbox 舞娘',
uid: 'flexbox-dancer'
},
{
serialNo: '9',
title: 'Nodejs 乐高',
uid: 'nodejs-lego'
},
{
serialNo: '10',
title: '支付宝站内集成',
uid: 'alipay'
},
{
serialNo: '11',
title: 'Atom 爱上 JS',
uid: 'atom-love-js'
},
{
serialNo: '13',
title: 'Git 北京',
uid: 'gitbeijing'
},
{
serialNo: '15',
title: 'Chrome 开发者工具',
uid: 'chrome-devtools'
},
{
serialNo: '16',
title: '小白变怪兽',
uid: 'bianguaishou'
},
{
serialNo: '17',
title: 'HTML 七日行',
uid: 'html7'
},
{
serialNo: '21',
title: 'GraphQL 婴儿',
uid: 'graphql-baby'
},
{
serialNo: '22',
title: 'Webpack-React 环境搭建技巧',
uid: 'webpack-react-tricks'
},
{
serialNo: '23',
title: '如何制作视频课程?',
uid: 'making-videos-howto'
},
{
serialNo: '24',
title: '微信小程序之吻',
uid: 'weapp'
},
{
serialNo: '25',
title: 'SVG 甜点',
uid: 'svghere'
},
{
serialNo: '26',
title: '认证授权双A之旅',
uid: 'aa-journey'
},
{
serialNo: '28',
title: 'React Router 第四版',
uid: 'react-router-v4'
},
{
serialNo: '30',
title: '克隆美团外卖',
uid: 'meituan'
},
{
serialNo: '31',
title: '快乐新知比特币',
uid: 'bitcoin'
},
{
serialNo: '37',
title: '跟 Peter 做腾讯云客户端',
uid: 'qcloud'
},
{
serialNo: '38',
title: 'React 社交化电商--功能篇',
uid: 'yummy-p2'
},
{
serialNo: '39',
title: '蚂蚁设计实战(第二版)',
uid: 'antd-v2'
}
]
module.exports = courseArr
前端还没有修。
具体的小节页:显示视频和文字稿