Skip to content

Commit

Permalink
Integrate with @mikroways/reveal-md-common
Browse files Browse the repository at this point in the history
  • Loading branch information
chrodriguez committed Jan 2, 2024
1 parent 5008683 commit 54707f5
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 151 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mikroways/create-reveal-presentation",
"description": "Create Mikroways reveal-md presentation",
"version": "0.1.2",
"version": "0.1.3",
"author": "Christian Rodriguez <[email protected]>",
"bin": "src/cli.js",
"files": [
Expand Down
4 changes: 3 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ create('create-mw-reveal-presentation', {
defaultLicense: 'MIT',
after: async ({ installNpmPackage }) => {
console.log('Installing required packages');
await installNpmPackage('reveal-md');
await installNpmPackage([
'reveal-md',
'@mikroways/reveal-md-common']);
},
caveat: ({ packageDir }) => {
console.log('\nNext steps:');
Expand Down
91 changes: 2 additions & 89 deletions templates/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,9 @@ option](https://github.com/webpro/reveal-md?tab=readme-ov-file#reveal-md-options
for reveal-md is also applied to this project. Configuration is done using YAML
Front matter at `src/start.md`.

We also add new *mikroways* options that can be:
We also add new *mikroways* options that are proided by **`@mikroways/reveal-md-common`**
dependency. To understand every option, please read the [documentation](https://github.com/Mikroways/reveal-md-common).

```yaml
mikroways:
# Will print debug information
debug: false
# Base path to look for files
basePath: 'src'
# Base path to look for code blocks to import
codePath: 'code'
# Custom named slide formats
formats:
main: 'class="main-cover" data-transition="zoom"'
new-topic: 'class="dark-logo-left" data-transition="zoom"'
new-topic-center: 'class="dark-logo-center" data-transition="zoom"'
```
> This is the default configuration
And this configuration are used by **helper functions** provided with our
preprocesor, `preproc.js`. This helpers are:

* **`SLIDE_FMT: format-name[, extra string]`:** format-name is one of the
formats configured by `mikroways.format`. A comma is needed to append any
string.
* **`FILE: path/to/file.md`:** will load an external file that will be located
under `mikroways.basePath` named `path/to/file.md`. This allows to organize
courses in a better way.
* **`CODE: path/to/code.ext highlight [lines] [class=name]`:** loads a
highlighted code using syntax highlighting from an external file. This file
will be located under `mikroways.codePath` named `path/to/code.ext`. Note that
**highlight** is needed. Also accepts numbers to highlight specific lines,
separated with comma or dash. After, a custom class can be set to change some
styles.

## Example usage

Change slide format:

```
---
SLIDE_FMT: main
# Any title
---
```
> Will set slide format to `<!-- .slide: class="main-cover"
> data-transition="zoom" -->` with default configuration.

Extra options can be added:

```
---
SLIDE_FMT: main, data-transition-spped="fast"
# Any title
---
```

> Will set slide format to `<!-- .slide: class="main-cover"
> data-transition="zoom" data-transition-spped="fast" -->`.

To load an external file:

```
FILE: sections/some-slide.md
```
> Will load `some-slide.md` from a file located at `mikroways.basePath` and in
> this case, inside `sections/` directory.

A highlighted code example:

```
CODE: example.sh bash
```
> Will look for example.sh file inside `mikroways.basePath`, under directory
> `mikroways.codePath`. By default this is `src/code`.

Now we will highlight only lines 1, and from 3 to 6:

```
CODE: example.sh bash 1,3-6
```

Finally, is possible to add a custom class:

```
CODE: example.sh bash 1,3-6 class="my-code"
CODE: example.sh bash class="my-code"
```

## Containers support

Expand Down
20 changes: 19 additions & 1 deletion templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@
"author": "{{contact}}",
"dependencies": {},
"scripts": {
"prepare": "postinstall",
"prestart": "postinstall",
"prestatic": "postinstall",
"start": "reveal-md src/start.md --preprocessor preproc.js --watch",
"static": "reveal-md src/start.md --preprocessor preproc.js --static",
"container": "npm run static && buildah build -f Containerfile -t {{kebab name}} _static"
},
"license": "{{license}}"
"prepare": {
"@mikroways/reveal-md-common/src/js/script.js": "link src/js/script.js",
"@mikroways/reveal-md-common/preproc.js": "link preproc.js",
"@mikroways/reveal-md-common/reveal-md.json": "link reveal-md.json"
},
"prestart": {
"@mikroways/reveal-md-common/src/js/script.js": "link src/js/script.js",
"@mikroways/reveal-md-common/preproc.js": "link preproc.js",
"@mikroways/reveal-md-common/reveal-md.json": "link reveal-md.json"
},
"prestatic": {
"@mikroways/reveal-md-common/src/js/script.js": "link src/js/script.js",
"@mikroways/reveal-md-common/preproc.js": "link preproc.js",
"@mikroways/reveal-md-common/reveal-md.json": "link reveal-md.json"
},
"license": "MIT"
}
6 changes: 4 additions & 2 deletions templates/default/preproc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const loadFileContent = (line, opts) => {
return doProcess(readFileSync(path.join(basePath, filePath), 'utf8'), opts)
}catch(err) {
console.log(`Error loading new file from ${path.join(basePath, filePath)} at ${line.match(FILE_REF_REGEX)[0]}`)
throw(err)
if (opts.mikroways.debug) console.log(err)
return line
}
}

Expand All @@ -49,7 +50,8 @@ const loadCodeFileContent = (line, opts) => {
return codeTemplate(code, lang, props)
} catch(err) {
console.log(`Error loading code file from ${path.join(basePath, filePath)} at ${line.match(CODE_FILE_REF_REGEX)[0]}`)
throw(err)
if (opts.mikroways.debug) console.log(err)
return line
}
}

Expand Down
1 change: 1 addition & 0 deletions templates/default/src/audio/title.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: {{ space name }}
Binary file added templates/default/src/favicon.ico
Binary file not shown.
Empty file.
43 changes: 0 additions & 43 deletions templates/default/src/js/script.js

This file was deleted.

15 changes: 1 addition & 14 deletions templates/default/src/start.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
---
title: {{ space name }}
highlightTheme: vs2015
scripts:
- https://cdn.jsdelivr.net/npm/[email protected]/plugin/mermaid/mermaid.min.js
- https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle/asciinema-player.min.js
- src/js/script.js
css:
- https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle/asciinema-player.min.css
theme: https://cdn.jsdelivr.net/gh/mikroways/reveal.js-mikroways-theme/theme/mikroways.min.css
revealOptions:
transition: 'concave'
transitionSpeed: 'slow'
mermaid: {}
mikroways: {}
---

SLIDE_FMT: main, data-transition-speed="fast" data-transition="zoom"
SLIDE_FMT: main

# {{ space name }}
---
Expand Down

0 comments on commit 54707f5

Please sign in to comment.