Skip to content

Commit

Permalink
Merge branch 'main' into ci/cr
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Jul 26, 2024
2 parents 4158beb + f4394e9 commit bdd0596
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 37 deletions.
5 changes: 4 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export default defineConfig({
transformerTwoslash({
twoslashOptions: {
// The @slidev/* installed in docs package are very old and should only be used in the homepage demo
vfsRoot: fileURLToPath(new URL('../../demo/starter/', import.meta.url)),
vfsRoot: fileURLToPath(import.meta.url),
compilerOptions: {
resolveJsonModule: true,
},
},
}),
],
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/scripts/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { copy, remove } from 'fs-extra'

async function main() {
await remove('.vitepress/@slidev')
await copy('node_modules/@slidev', '.vitepress/@slidev', { dereference: true })
await copy('node_modules/@slidev-old', '.vitepress/@slidev', { dereference: true })
}

main()
8 changes: 8 additions & 0 deletions docs/custom/config-code-runners.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ By default, JavaScript, TypeScript runners are supported built-in. They run in t

Create `./setup/code-runners.ts` with the following content:

<!-- eslint-disable import/first -->

```ts twoslash
declare const executePythonCodeRemotely: (code: string) => Promise<string>
declare const sanitizeHtml: (html: string) => string
// ---cut---
import { defineCodeRunnersSetup } from '@slidev/types'

export default defineCodeRunnersSetup(() => {
Expand All @@ -35,6 +40,9 @@ export default defineCodeRunnersSetup(() => {
The second argument `ctx` is the runner context, which contains the following properties:

```ts twoslash
import type { CodeRunnerOutputs } from '@slidev/types'
import type { CodeToHastOptions } from 'shiki'
// ---cut---
export interface CodeRunnerContext {
/**
* Options passed to runner via the `runnerOptions` prop.
Expand Down
7 changes: 7 additions & 0 deletions docs/custom/config-context-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ Customize the context menu items in Slidev.

Create `./setup/context-menu.ts` with the following content:

<!-- eslint-disable import/first -->

```ts twoslash
// ---cut---
import { defineContextMenuSetup } from '@slidev/types'
import { useNav } from '@slidev/client'
import { computed } from 'vue'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import Icon3DCursor from '~icons/carbon/3d-cursor'

export default defineContextMenuSetup((items) => {
Expand Down
11 changes: 6 additions & 5 deletions docs/custom/config-highlighter.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ If you want to add custom theme or language (TextMate grammar/themes in JSON), y
<!-- eslint-disable import/first-->

```ts twoslash
declare module '*.tmTheme.json' {
const value: any
export default value
}
// ---cut---
/* ./setup/shiki.ts */
import { defineShikiSetup } from '@slidev/types'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import customTheme from './customTheme.tmTheme.json'
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
import customLanguage from './customLanguage.tmLanguage.json'

export default defineShikiSetup(() => {
Expand Down
4 changes: 2 additions & 2 deletions docs/custom/config-parser.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configure Pre-Parser

::: info
Custom pre-parsers are not supposed to be used too often. Please only use it if you really want to have your custom syntax.
Custom pre-parsers are not supposed to be used too often. Usually you can use [Transformers](./config-transformers) for custom syntaxes.
:::

Slidev parses your presentation file (e.g. `slides.md`) in three steps:
Expand Down Expand Up @@ -162,7 +162,7 @@ import { definePreparserSetup } from '@slidev/types'
export default definePreparserSetup(() => {
return [
{
transformSlide(content, frontmatter) {
async transformSlide(content, frontmatter) {
if ('_scale' in frontmatter) {
return [
`<Transform :scale=${frontmatter._scale}>`,
Expand Down
3 changes: 3 additions & 0 deletions docs/custom/config-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default defineRoutesSetup((routes) => {
...routes,
{
path: '/my-page',
// ---cut-start---
// @ts-expect-error missing types
// ---cut-end---
component: () => import('../pages/my-page.vue'),
},
]
Expand Down
8 changes: 7 additions & 1 deletion docs/custom/config-vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ Slidev internally adds the following plugins to Vite:

To configure the built-in plugins listed above, create a `vite.config.ts` with the following content. Please note that Slidev has some [default configurations](https://github.com/slidevjs/slidev/blob/main/packages/slidev/node/vite/index.ts) for those plugins, this usage will override some of them, which may potentially cause the app to break. Please treat this as **an advanced feature**, and make sure you know what you are doing before moving on.

<!-- eslint-disable import/first -->

```ts twoslash
/// <reference types="@slidev/types" />
import type MarkdownIt from 'markdown-it'
declare const MyPlugin: (md: MarkdownIt) => void
// ---cut---
import { defineConfig } from 'vite'

export default defineConfig({
Expand All @@ -31,7 +37,7 @@ export default defineConfig({
/* markdown-it options */
markdownItSetup(md) {
/* custom markdown-it plugins */
md.use(/* ... */)
md.use(MyPlugin/* ... */)
},
},
/* options for other plugins */
Expand Down
5 changes: 5 additions & 0 deletions docs/custom/config-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ Slidev uses [Vue 3](https://v3.vuejs.org/) to render the application on the clie

Create `./setup/main.ts` with the following content:

<!-- eslint-disable import/first -->

```ts twoslash
import type { Plugin } from 'vue'
declare const YourPlugin: Plugin
// ---cut---
import { defineAppSetup } from '@slidev/types'

export default defineAppSetup(({ app, router }) => {
Expand Down
13 changes: 8 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docs",
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"private": true,
"packageManager": "pnpm@9.6.0",
"scripts": {
Expand All @@ -17,10 +17,13 @@
"devDependencies": {
"@iconify/json": "^2.2.230",
"@shikijs/vitepress-twoslash": "^1.11.1",
"@slidev/client": "0.34.3",
"@slidev/parser": "0.34.3",
"@slidev/theme-default": "0.21.2",
"@slidev/types": "0.34.3",
"@slidev-old/client": "npm:@slidev/client@0.34.3",
"@slidev-old/parser": "npm:@slidev/parser@0.34.3",
"@slidev-old/theme-default": "npm:@slidev/theme-default@0.21.2",
"@slidev-old/types": "npm:@slidev/types@0.34.3",
"@slidev/client": "workspace:*",
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.14.11",
"@unocss/reset": "^0.61.5",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"private": true,
"packageManager": "pnpm@9.6.0",
"engines": {
Expand All @@ -21,7 +21,7 @@
"lint:fix": "nr lint --fix",
"typecheck": "vue-tsc --noEmit",
"docs": "pnpm -C docs run dev",
"docs:build": "pnpm -C docs run build && pnpm demo:build",
"docs:build": "pnpm run --filter {./docs}... build && pnpm demo:build",
"release": "bumpp package.json packages/*/package.json docs/package.json --all -x \"zx scripts/update-versions.mjs\"",
"test": "vitest test",
"prepare": "simple-git-hooks"
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@slidev/client",
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-slidev",
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"description": "Create starter template for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"export": "slidev export"
},
"dependencies": {
"@slidev/cli": "^0.49.21",
"@slidev/cli": "^0.49.22",
"@slidev/theme-default": "latest",
"@slidev/theme-seriph": "latest",
"vue": "^3.4.33"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-slidev-theme",
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"description": "Create starter theme template for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-theme/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"screenshot": "slidev export example.md --format png"
},
"dependencies": {
"@slidev/types": "^0.49.21",
"@slidev/types": "^0.49.22",
"prism-theme-vars": "^0.2.5"
},
"devDependencies": {
"@slidev/cli": "^0.49.21"
"@slidev/cli": "^0.49.22"
},
"//": "Learn more: https://sli.dev/guide/write-theme.html",
"slidev": {
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/parser",
"version": "0.49.21",
"version": "0.49.22",
"description": "Markdown parser for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/slidev/node/setups/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function setupTransformers(roots: string[]) {
postCodeblock: [],
post: [],
}
for (const r of returns.toReversed()) {
for (const r of [...returns].reverse()) {
if (r.pre)
result.pre.push(...r.pre)
if (r.preCodeblock)
Expand Down
2 changes: 1 addition & 1 deletion packages/slidev/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@slidev/cli",
"type": "module",
"version": "0.49.21",
"version": "0.49.22",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/types",
"version": "0.49.21",
"version": "0.49.22",
"description": "Shared types declarations for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Slidev",
"type": "module",
"preview": true,
"version": "0.49.21",
"version": "0.49.22",
"private": true,
"description": "Slidev support for VS Code",
"license": "MIT",
Expand Down
27 changes: 18 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bdd0596

Please sign in to comment.