From a9706e023e005538c02c8ba9f36d03876f65dacb Mon Sep 17 00:00:00 2001 From: Leon Si Date: Wed, 5 Oct 2022 05:47:29 -0400 Subject: [PATCH 01/42] docs: fix typos and tweak grammar (#94) --- guide/hosting.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/guide/hosting.md b/guide/hosting.md index 1392a7a..61511e8 100644 --- a/guide/hosting.md +++ b/guide/hosting.md @@ -31,9 +31,9 @@ download: true --- ``` -Slidev will generate a pdf file along with the build, and a download button will be displayed in the SPA. +Slidev will generate a PDF file along with the build, and a download button will be displayed in the SPA. -You can also provide a custom url to the PDF. In that case, the rendering process will be skipped. +You can also provide a custom URL for the PDF. In that case, the rendering process will be skipped. ```md --- @@ -52,7 +52,7 @@ For more, check out [Showcases](/showcases). ## Hosting -We recommend to use `npm init slidev@lastest` to scaffolding your project, which contains the necessary configuration files for hosting services out-of-box. +We recommend to use `npm init slidev@latest` to scaffold your project, which contains the necessary configuration files for hosting services out-of-the-box. ### Netlify @@ -74,7 +74,7 @@ Create `netlify.toml` in your project root with the following content. status = 200 ``` -Then go to your Netlify dashboard, create new site with the repository. +Then go to your Netlify dashboard and create a new site with the repository. ### Vercel @@ -90,7 +90,7 @@ Create `vercel.json` in your project root with the following content. } ``` -Then go to your Vercel dashboard, create new site with the repository. +Then go to your Vercel dashboard and create a new site with the repository. ## GitHub Pages @@ -98,7 +98,7 @@ Then go to your Vercel dashboard, create new site with the repository. To deploy your slides on GitHub Pages: - upload all the files of the project in your repo (i.e. named `name_of_repo`) -- create `.github/workflows/deploy.yml` with following content to deploy your slides to GitHub Pages via GitHub Actions. In this file, replace ``with `name_of_repo`. +- create `.github/workflows/deploy.yml` with following content to deploy your slides to GitHub Pages via GitHub Actions. In this file, replace `` with `name_of_repo`. ```yaml name: Deploy pages @@ -124,5 +124,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -- In your repository, go to Setting>Pages. Under "Build and deployment", select "Deploy from a branch", select "gh- pages" and "root". Click on save. -- Finally, after all workflows is executed, a link to the slides should appear under Setting>Pages. +- In your repository, go to Settings>Pages. Under "Build and deployment", select "Deploy from a branch", select "gh-pages" and "root". Click on save. +- Finally, after all workflows are executed, a link to the slides should appear under Settings>Pages. From 550ff2f51c9e98efef76cff45ffe0cbb619afd7d Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 18 Oct 2022 10:43:11 +0800 Subject: [PATCH 02/42] chore: update algolia component --- .../theme/components/AlgoliaSearchBox.vue | 179 +++++++----------- 1 file changed, 73 insertions(+), 106 deletions(-) diff --git a/.vitepress/theme/components/AlgoliaSearchBox.vue b/.vitepress/theme/components/AlgoliaSearchBox.vue index b9a5b7f..f1479a4 100644 --- a/.vitepress/theme/components/AlgoliaSearchBox.vue +++ b/.vitepress/theme/components/AlgoliaSearchBox.vue @@ -4,126 +4,93 @@ From ecd8bf022f3594c9efceac78aae2852a0055f9bf Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Tue, 18 Oct 2022 04:44:35 +0200 Subject: [PATCH 03/42] docs(search): correct credentials for docsearch (#95) --- .vitepress/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vitepress/config.js b/.vitepress/config.js index c5b3569..cc900d2 100644 --- a/.vitepress/config.js +++ b/.vitepress/config.js @@ -252,7 +252,8 @@ module.exports = { editLinkText: 'Suggest changes to this page', algolia: { - apiKey: '1a5c5a504139c58f428974c78c55291d', + appId: 'LCBV6MIFS6', + apiKey: '1ff173fe73b20edc962c1c24c0b1c160', indexName: 'slidev', searchParameters: { // for translations maintainers: change the filter to your locale code (subdomain name) From 7fa7d16a90641985a70320e5115ac4f427cc8508 Mon Sep 17 00:00:00 2001 From: Giacomo Lombardi Date: Tue, 25 Oct 2022 07:27:57 +0200 Subject: [PATCH 04/42] doc: add presenter notes export guide (#96) Co-authored-by: Anthony Fu --- guide/exporting.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/guide/exporting.md b/guide/exporting.md index 5ee1fb0..334be75 100644 --- a/guide/exporting.md +++ b/guide/exporting.md @@ -1,6 +1,8 @@ # Exporting -## PDF +## Slides + +### PDF > Exporting to PDF or PNG relies on [Playwright](https://playwright.dev) for rendering. You will therefore need to install [`playwright-chromium`](https://playwright.dev/docs/installation#download-single-browser-binary) to use this feature. > If you are doing exporting in a CI environment, [the playwright CI guide](https://playwright.dev/docs/ci) can be helpful. @@ -25,7 +27,7 @@ In case you want to export your slides using the dark version of the theme, use $ slidev export --dark ``` -### Export Clicks Steps +#### Export Clicks Steps > Available since v0.21 @@ -35,7 +37,7 @@ By default, Slidev exports one page per slide with clicks animations disabled. I $ slidev export --with-clicks ``` -## PNGs +### PNGs When passing in the `--format png` option, Slidev will export PNG images for each slide instead of a PDF. @@ -43,6 +45,16 @@ When passing in the `--format png` option, Slidev will export PNG images for eac $ slidev export --format png ``` -## Single-Page Application (SPA) +### Single-Page Application (SPA) See [Static Hosting](/guide/hosting). + +## Presenter notes + +> Available since v0.36.8 + +Export only the presenter notes (the last comment block for each slide) into a text document in PDF. + +```bash +$ slidev export-notes +``` From 26a45505735ed4d0647775c328a0d7b7a4ca0a65 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Tue, 25 Oct 2022 08:29:07 +0300 Subject: [PATCH 05/42] docs: update for advanced navigation features (#79) --- custom/config-shortcuts.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/custom/config-shortcuts.md b/custom/config-shortcuts.md index db6cb05..0944a15 100644 --- a/custom/config-shortcuts.md +++ b/custom/config-shortcuts.md @@ -6,6 +6,8 @@ +## Getting started + Create `./setup/shortcuts.ts` with the following content: ```ts @@ -33,6 +35,8 @@ With the setup, you can provide the custom setting for shortcuts mentioned in [N The configuration function receives an object with some navigation methods, and returns an array containing some shortcut configuration. Refer to the type definitions for more details. +## Advanced key binding + The `key` type only allows for strings, but you can still bind multiple keys by using following convention: ```ts @@ -51,4 +55,26 @@ export default defineShortcutsSetup((nav: NavOperations, base: ShortcutOptions[] }) ``` +## Advanced navigation features + +The `nav` navigation operations allows you to access some functionalities than basic _next slide_ or _previous slide_. See the following for use-cases: + +```ts +import { defineShortcutsSetup, NavOperations } from '@slidev/types' + +export default defineShortcutsSetup((nav: NavOperations) => { + return [ + { + key: 'e', + + // Set the `e` keyboard shortcut to be used as a bookmark + // or quick-access of sorts, to navigate specifically to + // slide number 42 + fn: () => nav.go(42), + autoRepeat: true, + } + ] +}) +``` + Refer to [useMagicKeys | VueUse](https://vueuse.org/core/useMagicKeys/) for more details about key pressed event. From 37da379f2085eaf0e279e3b3929565606e0df481 Mon Sep 17 00:00:00 2001 From: Minsu Kim Date: Tue, 25 Oct 2022 14:49:35 +0900 Subject: [PATCH 06/42] docs: Update showcase list (#92) --- .vitepress/showcases.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.vitepress/showcases.ts b/.vitepress/showcases.ts index 7c4c6fa..43b3526 100644 --- a/.vitepress/showcases.ts +++ b/.vitepress/showcases.ts @@ -131,6 +131,17 @@ export const showcases: ShowCaseInfo[] = [ sourceLink: 'https://github.com/webup/openfunction-talks/tree/main/202-node-async', at: 'OpenFunction Tutorial Sharing', datetime: '2022-05-08', + }, + { + title: 'Is it Okay to Pursue Functional Programming on Frontend?', + author: { + name: 'Minsu Kim , Changhui Lee', + }, + at: '2022 JSConf Korea', + slidesLink: 'https://moonlit-nougat-422445.netlify.app/1', + sourceLink: 'https://github.com/alstn2468/2022-jsconf-presentation', + cover: 'https://raw.githubusercontent.com/alstn2468/2022-jsconf-presentation/main/public/images/og.png', + datetime: '2022-09-16', }, // Add yours here! { From e414b8d4982fad572da8803b6a2c84edd570a01e Mon Sep 17 00:00:00 2001 From: godkun Date: Fri, 4 Nov 2022 20:59:05 +0800 Subject: [PATCH 07/42] docs: add slidev ppt template with naive-ui (#97) --- .vitepress/showcases.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.vitepress/showcases.ts b/.vitepress/showcases.ts index 43b3526..80db948 100644 --- a/.vitepress/showcases.ts +++ b/.vitepress/showcases.ts @@ -143,6 +143,17 @@ export const showcases: ShowCaseInfo[] = [ cover: 'https://raw.githubusercontent.com/alstn2468/2022-jsconf-presentation/main/public/images/og.png', datetime: '2022-09-16', }, + { + title: 'Blazing slidev ppt template with naive-ui', + author: { + name: 'godkun', + }, + at: 'personal sharing', + slidesLink: 'https://ppt.godkun.top', + sourceLink: 'https://github.com/godkun/ppt-template', + cover: 'https://github.com/godkun/ppt-template/raw/main/public/show.gif', + datetime: '2022-10-24', + }, // Add yours here! { title: 'Yours?', From 041453dfdd1dbc3f02b3114416e1b20b60563679 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 4 Nov 2022 13:59:28 +0100 Subject: [PATCH 08/42] Add slidev-theme-mokkapps (#98) --- .vitepress/themes.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.vitepress/themes.ts b/.vitepress/themes.ts index 6e504da..8d98809 100644 --- a/.vitepress/themes.ts +++ b/.vitepress/themes.ts @@ -359,6 +359,33 @@ export const community: ThemeInfo[] = [ 'light', ], }, + { + id: 'slidev-theme-mokkapps', + name: 'Mokkapps', + description: 'A theme for my personal brand "Mokkapps"', + author: { + name: 'Michael Hoffmann', + link: 'https://github.com/mokkapps', + }, + repo: 'https://github.com/mokkapps/slidev-theme-mokkapps', + previews: [ + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/001.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/002.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/003.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/004.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/005.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/006.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/007.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/008.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/009.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/010.png', + 'https://cdn.jsdelivr.net/gh/mokkapps/slidev-theme-mokkapps@master/screenshots/dark/011.png', + ], + tags: [ + 'dark', + 'light', + ], + }, // Add yours here! { id: '', From eb148aa43004e4f35f192bf482a90cc220e943c3 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 8 Nov 2022 16:50:52 +0800 Subject: [PATCH 09/42] fix: disable search box auto open, close #99 --- .../theme/components/AlgoliaSearchBox.vue | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.vitepress/theme/components/AlgoliaSearchBox.vue b/.vitepress/theme/components/AlgoliaSearchBox.vue index f1479a4..9561cb3 100644 --- a/.vitepress/theme/components/AlgoliaSearchBox.vue +++ b/.vitepress/theme/components/AlgoliaSearchBox.vue @@ -14,25 +14,8 @@ const { theme, site } = useData() onMounted(() => { initialize(theme.value.algolia) - setTimeout(poll, 16) }) -function poll() { - // programmatically open the search box after initialize - const e = new Event('keydown') as any - - e.key = 'k' - e.metaKey = true - - window.dispatchEvent(e) - - setTimeout(() => { - if (!document.querySelector('.DocSearch-Modal')) { - poll() - } - }, 16) -} - // @ts-expect-error const docsearch$ = docsearch.default ?? docsearch type DocSearchProps = Parameters[0] From 35a71a169226ed1a0aecd46caa63ecf4e468608c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Emonet?= Date: Thu, 24 Nov 2022 09:41:04 +0100 Subject: [PATCH 10/42] docs: add parser customization (preparser, but also link vite config) (#91) --- .vitepress/config.js | 4 + custom/config-parser.md | 177 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 custom/config-parser.md diff --git a/.vitepress/config.js b/.vitepress/config.js index cc900d2..1f46141 100644 --- a/.vitepress/config.js +++ b/.vitepress/config.js @@ -164,6 +164,10 @@ const Customizations = [ text: 'Configure Mermaid', link: '/custom/config-mermaid', }, + { + text: 'Configure Parser', + link: '/custom/config-parser', + }, { text: 'Configure Shortcuts', link: '/custom/config-shortcuts', diff --git a/custom/config-parser.md b/custom/config-parser.md new file mode 100644 index 0000000..054660b --- /dev/null +++ b/custom/config-parser.md @@ -0,0 +1,177 @@ +# Configure and Extend the Parser + +Slidev parses your presentation file (e.g. `slides.md`) in three steps: + +1. A "preparsing" step is carried out: the file is split into slides using the `---` separator, and considering the possible frontmatter blocks. +2. Each slide is parsed with an external library. +3. Slidev resolves the special frontmatter property `src: ....`, which allows to include other md files. + +## Markdown Parser + +Configuring the markdown parser used in step 2 can be done by [configuring Vite internal plugins](/custom/config-vite#configure-internal-plugins). + +## Preparser Extensions + +> Available since v0.37.0 + +:::warning +Important: when modifying the preparser configuration, you need to stop and start slidev again (restart might not be sufficient). +::: + +The preparser (step 1 above) is highly extensible and allows to implement custom syntaxes for your md files. Extending the preparser is considered **an advanced feature** and is susceptible to break [editor integrations](/guide/editors) due to implicit changes in the syntax. + +To customize it, create a `./setup/preparser.ts` file with the following content: + + +```ts +import { definePreparserSetup } from '@slidev/types' + +export default definePreparserSetup((filepath) => { + return [ + { + transformRawLines(lines) { + for (const i in lines) { + if (lines[i] === '@@@') + lines[i] = 'HELLO' + } + }, + } + ] +}) +``` + +This example systematically replaces any `@@@` line by a line with `hello`. It illustrates the structure of a preparser configuration file and some of the main concepts the preparser involves: +- `definePreparserSetup` must be called with a function as parameter. +- The function receives the file path (of the root presentation file) and could use this information (e.g., enable extensions based on the presentation file). +- The function must return a list of preparser extensions. +- An extension can contain: + - a `transformRawLines(lines)` function that runs just after parsing the headmatter of the md file and receives a list of all lines (from the md file). The function can mutate the list arbitrarily. + - a `transformSlide(content, frontmatter)` function that is called for each slide, just after splitting the file, and receives the slide content as a string and the frontmatter of the slide as an object. The function can mutate the frontmatter and must return the content string (possibly modified, possibly `undefined` if no modifications have been done). + - a `name` + +## Example Preparser Extensions + +### Use case 1: compact syntax top-level presentation + +Imagine a situation where (part of) your presentation is mainly showing cover images and including other md files. You might want a compact notation where for instance (part of) `slides.md` is as follows: + +```md + +@cover: /nice.jpg +# Welcome +@src: page1.md +@src: page2.md +@cover: /break.jpg +@src: pages3-4.md +@cover: https://source.unsplash.com/collection/94734566/1920x1080 +# Questions? +see you next time + +``` + +To allow these `@src:` and `@cover:` syntaxes, create a `./setup/preparser.ts` file with the following content: + + +```ts +import { definePreparserSetup } from '@slidev/types' + +export default definePreparserSetup((filepath) => { + return [ + { + transformRawLines(lines) { + let i = 0 + while (i < lines.length) { + const l = lines[i] + if (l.match(/^@cover:/i)) { + lines.splice(i, 1, + '---', + 'layout: cover', + `background: ${l.replace(/^@cover: */i, '')}`, + '---', + '') + continue + } + if (l.match(/^@src:/i)) { + lines.splice(i, 1, + '---', + `src: ${l.replace(/^@src: */i, '')}`, + '---', + '') + continue + } + i++ + } + } + }, + ] +}) +``` + +And that's it. + + +### Use case 2: using custom frontmatter to wrap slides + +Imagine a case where you often want to scale some of your slides but still want to use a variety of existing layouts so create a new layout would not be suited. +For instance, you might want to write your `slides.md` as follows: + +```md + + + +--- +layout: quote +_scale: 0.75 +--- + +# Welcome + +> great! + +--- +_scale: 4 +--- +# Break + +--- + +# Ok + +--- +layout: center +_scale: 2.5 +--- +# Questions? +see you next time + +``` + +Here we used an underscore in `_scale` to avoid possible conflicts with existing frontmatter properties (indeed, the case of `scale`, without underscore would cause potential problems). + + +To handle this `_scale: ...` syntax in the frontmatter, create a `./setup/preparser.ts` file with the following content: + + +```ts +import { definePreparserSetup } from '@slidev/types' + +export default definePreparserSetup((filepath) => { + return [ + { + transformSlide(content, frontmatter) { + if ('_scale' in frontmatter) { + return [ + ``, + '', + content, + '', + '' + ].join('\n') + } + }, + }, + ] +}) +``` + +And that's it. From 276185826c2f774c4c27838d374730dd54986752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Emonet?= Date: Tue, 13 Dec 2022 20:45:16 +0100 Subject: [PATCH 11/42] docs: update parameters in definePreparserSetup (#101) --- custom/config-parser.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom/config-parser.md b/custom/config-parser.md index 054660b..098b359 100644 --- a/custom/config-parser.md +++ b/custom/config-parser.md @@ -26,7 +26,7 @@ To customize it, create a `./setup/preparser.ts` file with the following content ```ts import { definePreparserSetup } from '@slidev/types' -export default definePreparserSetup((filepath) => { +export default definePreparserSetup(({filepath, headmatter}) => { return [ { transformRawLines(lines) { @@ -42,7 +42,7 @@ export default definePreparserSetup((filepath) => { This example systematically replaces any `@@@` line by a line with `hello`. It illustrates the structure of a preparser configuration file and some of the main concepts the preparser involves: - `definePreparserSetup` must be called with a function as parameter. -- The function receives the file path (of the root presentation file) and could use this information (e.g., enable extensions based on the presentation file). +- The function receives the file path (of the root presentation file) and headmatter (from the md file). It could use this information (e.g., enable extensions based on the presentation file). - The function must return a list of preparser extensions. - An extension can contain: - a `transformRawLines(lines)` function that runs just after parsing the headmatter of the md file and receives a list of all lines (from the md file). The function can mutate the list arbitrarily. @@ -75,7 +75,7 @@ To allow these `@src:` and `@cover:` syntaxes, create a `./setup/preparser.ts` f ```ts import { definePreparserSetup } from '@slidev/types' -export default definePreparserSetup((filepath) => { +export default definePreparserSetup(() => { return [ { transformRawLines(lines) { @@ -155,7 +155,7 @@ To handle this `_scale: ...` syntax in the frontmatter, create a `./setup/prepar ```ts import { definePreparserSetup } from '@slidev/types' -export default definePreparserSetup((filepath) => { +export default definePreparserSetup(() => { return [ { transformSlide(content, frontmatter) { From 5cffe3bca749ea2af7b370223f0f442d15d88d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20dBruxelles?= <18559798+jdbruxelles@users.noreply.github.com> Date: Mon, 19 Dec 2022 21:51:17 +0100 Subject: [PATCH 12/42] fix: use bold instead of code tag to avoid breaking chars on mobile (#100) Closes https://github.com/slidevjs/slidev/issues/778 --- guide/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/index.md b/guide/index.md index 0d8c943..d69182d 100644 --- a/guide/index.md +++ b/guide/index.md @@ -2,7 +2,7 @@ ## Overview -Slidev (slide + dev, `/slʌɪdɪv/`) is a web-based slides maker and presenter. It's designed for developers to focus on writing content in Markdown while also having the power of HTML and Vue components to deliver pixel-perfect layouts and designs with embedded interactive demos in your presentations. +Slidev (slide + dev, **/slʌɪdɪv/**) is a web-based slides maker and presenter. It's designed for developers to focus on writing content in Markdown while also having the power of HTML and Vue components to deliver pixel-perfect layouts and designs with embedded interactive demos in your presentations. It uses a feature-rich markdown file to generate beautiful slides with an instant reloading experience, along with many built-in integrations such as live coding, PDF exporting, presentation recording, and so on. Since it's powered by the web, you can do anything with Slidev - the possibilities are endless. From c32272eee9133102e2913c79e771691761502cce Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Wed, 21 Dec 2022 09:02:16 +0000 Subject: [PATCH 13/42] chore(typos): fix typos (#102) Co-authored-by: stavares843 --- .vitepress/theme/components/Tweet.vue | 2 +- .vitepress/theme/support/sideBar.ts | 6 +++--- .vitepress/theme/utils.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vitepress/theme/components/Tweet.vue b/.vitepress/theme/components/Tweet.vue index a7bc116..cd307a2 100644 --- a/.vitepress/theme/components/Tweet.vue +++ b/.vitepress/theme/components/Tweet.vue @@ -1,5 +1,5 @@