《开源精选》是我们分享Github、Gitee等开源社区中优质项目的栏目,包括技术、学习、实用与各种有趣的内容。本期推荐的这可能是迄今为止最好的网页版演示库nodeppt。
nodeppt 2.0基于webslides、webpackdown-it、posthtmlmarkdown重构。
npm install -g nodeppt# create a new slide with an official template $ nodeppt new slide.md # create a new slide straight from a github template $ nodeppt new slide.md -t username/repo # start local sever show slide $ nodeppt serve slide.md # to build a slide $ nodeppt build slide.md# help nodeppt -h# 获取帮助 nodeppt serve -hnodeppt 有演讲者模式,在页面 url 后面增加?mode=speaker 既可以打开演讲者模式,双屏同步
如果项目文件夹下,存在public文件夹,可以直接通过url访问,webpack dev server的contentBase选项。
在build那个时候,公共文件夹中的文件会完整复制到dist文件夹中
最佳体验是chrome浏览器,本来就是给做演示用的,所以考虑一下非Chrome浏览器连接问题了
这里说下怎么写。
基本语法
整个markdown文件分成两部分,第一部分是写在最前面的配置,然后是使用
nodeppt 的配置是直接写在 md 文件顶部的,采用 yaml 语法,例如下面的配置:
title: nodeppt markdown 演示speaker: 三水清url: https://github.com/ksky521/nodepptjs: - https://www.echartsjs.com/asset/theme/shine.jsprismTheme: solarizedlightplugins: - echarts - mermaid - katex插件
nodeppt 图表插件,支持KaTeX图形符号,现在三个。
图表
echarts主题配色可以直接在yaml配置的js中引入。echarts中采用fence语法,如下:
{ xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [{ data: [820, 932, 901, 934, 1290, 1330, 1320], type: 'line' }]}mermaid 主题配色可以直接在yaml配置的 js 中引入。mermaid 采用fence语法,如下:
nodeppt会根据
幻灯片会解析成下面的html结构:
其中
输出为:
nodeppt 一如既往的支持动效,2.0 版本支持动效主要是页面内的动效。
支持动效包括:
在需要支持的动效父节点添加.build或者在具体的某个元素上添加.tobuild+动效 class即可。
按照惯例,nodeppt 还支持animate.css的动效哦~
nodeppt.config.js
在 nodeppt 执行路径下创建nodeppt.config.js文件,可以配置跟webpack相关的选项,另外可以支持自研 nodeppt 插件。
默认内置的config.js内容如下:
/** * @file 默认配置 */module.exports = () => ({ // project deployment base baseUrl: '/', // where to output built files outputDir: 'dist', // where to put static assets (js/css/img/font/...) assetsDir: '', // filename for index.html (relative to outputDir) indexPath: 'index.html', // 插件,包括 markdown 和 posthtml plugins: [], // chainWebpack: [], // whether filename will contain hash part filenameHashing: true, // boolean, use full build? runtimeCompiler: false, // deps to transpile transpileDependencies: [ /* string or regex */ ], // sourceMap for production build? productionSourceMap: true, // use thread-loader for babel & TS in production build // enabled by default if the machine has more than 1 cores parallel: () => { try { return require('os').cpus().length > 1; } catch (e) { return false; } }, // multi-page config pages: undefined, //
| 留言与评论(共有 0 条评论) “” |