Skip to content

Commit

Permalink
Merge branch 'main' into fix/style-inside-slide
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Apr 16, 2024
2 parents 2da0ba8 + 97f3baa commit 37ebff8
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 88 deletions.
6 changes: 5 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ const Customizations: (DefaultTheme.NavItemWithLink | DefaultTheme.NavItemChildr
text: 'Configure Parser',
link: '/custom/config-parser',
},
{
text: 'Configure Routes',
link: '/custom/config-routes',
},
{
text: 'Configure Shortcuts',
link: '/custom/config-shortcuts',
Expand Down Expand Up @@ -249,7 +253,7 @@ export default defineConfig({
themeConfig: {
logo: '/logo.svg',
editLink: {
pattern: 'https://github.com/slidevjs/docs/edit/main/:path',
pattern: 'https://github.com/slidevjs/slidev/edit/main/docs/:path',
text: 'Suggest changes to this page',
},

Expand Down
12 changes: 12 additions & 0 deletions docs/.vitepress/showcases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ export const showcases: ShowCaseInfo[] = [
cover: 'https://github-production-user-asset-6210df.s3.amazonaws.com/7693264/284304324-db973b4c-a043-4644-932c-826169a1b4d8.gif',
datetime: '2022-09-01',
},
{
title: 'How Rust error handling ease web development',
author: {
name: 'Nguyễn Hồng Quân',
link: 'https://quan.hoabinh.vn',
},
at: 'FOSSASIA Summit 2024',
slidesLink: 'https://talk.quan.hoabinh.vn/rust-error-handling-ease-web-dev/',
sourceLink: 'https://hongquan@bitbucket.org/hongquan/rust-error-handling-ease-web-dev.git',
cover: 'https://i.imgur.com/2eBJofY.png',
datetime: '2024-04-10',
},
// Add yours here!
{
title: 'Yours?',
Expand Down
10 changes: 5 additions & 5 deletions docs/builtin/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Shows an image on the left side of the screen, the content will be placed on the
layout: image-left

# the image source
image: ./path/to/the/image
image: /path/to/the/image

# a custom class name to the content
class: my-cool-content-on-the-right
Expand All @@ -57,7 +57,7 @@ Shows an image on the right side of the screen, the content will be placed on th
layout: image-right

# the image source
image: ./path/to/the/image
image: /path/to/the/image

# a custom class name to the content
class: my-cool-content-on-the-left
Expand All @@ -75,7 +75,7 @@ Shows an image as the main content of the page.
layout: image

# the image source
image: ./path/to/the/image
image: /path/to/the/image
---
```

Expand All @@ -84,15 +84,15 @@ You can change the default background size (`cover`) by adding the `backgroundSi
```yaml
---
layout: image
image: ./path/to/the/image
image: /path/to/the/image
backgroundSize: contain
---
```

```yaml
---
layout: image-left
image: ./path/to/the/image
image: /path/to/the/image
backgroundSize: 20em 70%
---
```
Expand Down
25 changes: 25 additions & 0 deletions docs/custom/config-routes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Configure Routes

<Environment type="client" />

Add your pages to the Slidev app.

## Usage

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

```ts
import { defineRoutesSetup } from '@slidev/types'

export default defineRoutesSetup((routes) => {
return [
...routes,
{
path: '/my-page',
component: () => import('../pages/my-page.vue'),
},
]
})
```

Learn more about routes in the [Vue Router documentation](https://router.vuejs.org/).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "module",
"version": "0.49.0-beta.2",
"version": "0.49.0-beta.3",
"private": true,
"packageManager": "pnpm@8.15.6",
"engines": {
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.0-beta.2",
"version": "0.49.0-beta.3",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
68 changes: 0 additions & 68 deletions packages/client/routes.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/client/setup/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createVClickDirectives } from '../modules/v-click'
import { createVMarkDirective } from '../modules/v-mark'
import { createVDragDirective } from '../modules/v-drag'
import { createVMotionDirectives } from '../modules/v-motion'
import { routes } from '../routes'
import setupRoutes from '../setup/routes'
import setups from '#slidev/setups/main'

import '#slidev/styles'
Expand All @@ -28,7 +28,7 @@ export default async function setupMain(app: App) {
history: __SLIDEV_HASH_ROUTE__
? createWebHashHistory(import.meta.env.BASE_URL)
: createWebHistory(import.meta.env.BASE_URL),
routes,
routes: setupRoutes(),
})

app.use(router)
Expand Down
80 changes: 80 additions & 0 deletions packages/client/setup/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
import configs from '#slidev/configs'
import setups from '#slidev/setups/routes'

export default function setupRoutes() {
const routes: RouteRecordRaw[] = []

if (__SLIDEV_FEATURE_PRESENTER__) {
function passwordGuard(to: RouteLocationNormalized) {
if (!configs.remote || configs.remote === to.query.password)
return true
if (configs.remote && to.query.password === undefined) {
// eslint-disable-next-line no-alert
const password = prompt('Enter password')
if (configs.remote === password)
return true
}
if (to.params.no)
return { path: `/${to.params.no}` }
return { path: '' }
}

routes.push(
{
name: 'entry',
path: '/entry',
component: () => import('../pages/entry.vue'),
},
{
name: 'overview',
path: '/overview',
component: () => import('../pages/overview.vue'),
},
{
name: 'notes',
path: '/notes',
component: () => import('../pages/notes.vue'),
beforeEnter: passwordGuard,
},
{
name: 'presenter',
path: '/presenter/:no',
component: () => import('../pages/presenter.vue'),
beforeEnter: passwordGuard,
},
{
path: '/presenter',
redirect: { path: '/presenter/1' },
},
)
}

if (__SLIDEV_HAS_SERVER__) {
routes.push(
{
name: 'print',
path: '/print',
component: () => import('../pages/print.vue'),
},
{
path: '/presenter/print',
component: () => import('../pages/presenter/print.vue'),
},
)
}

routes.push(
{
name: 'play',
path: '/:no',
component: () => import('../pages/play.vue'),
},
{
path: '',
redirect: { path: '/1' },
},
)

return setups.reduce((routes, setup) => setup(routes), routes)
}
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.0-beta.2",
"version": "0.49.0-beta.3",
"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.0-beta.2",
"@slidev/cli": "^0.49.0-beta.3",
"@slidev/theme-default": "latest",
"@slidev/theme-seriph": "latest",
"vue": "^3.4.21"
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.0-beta.2",
"version": "0.49.0-beta.3",
"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 @@ -15,12 +15,12 @@
"screenshot": "slidev export example.md --format png"
},
"dependencies": {
"@slidev/types": "^0.49.0-beta.2",
"@slidev/types": "^0.49.0-beta.3",
"codemirror-theme-vars": "^0.1.2",
"prism-theme-vars": "^0.2.4"
},
"devDependencies": {
"@slidev/cli": "^0.49.0-beta.2"
"@slidev/cli": "^0.49.0-beta.3"
},
"//": "Learn more: https://sli.dev/themes/write-a-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.0-beta.2",
"version": "0.49.0-beta.3",
"description": "Markdown parser for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/slidev/node/virtual/setups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ function createSetupTemplate(name: string): VirtualModuleTemplate {
}

// setups
const setupModules = ['shiki', 'code-runners', 'monaco', 'mermaid', 'main', 'root', 'shortcuts', 'context-menu']
const setupModules = ['shiki', 'code-runners', 'monaco', 'mermaid', 'main', 'root', 'routes', 'shortcuts', 'context-menu']

export const templateSetups = setupModules.map(createSetupTemplate)
2 changes: 1 addition & 1 deletion packages/slidev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/cli",
"version": "0.49.0-beta.2",
"version": "0.49.0-beta.3",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ declare module '#slidev/setups/shortcuts' {
export default setups
}

declare module '#slidev/setups/routes' {
import type { RoutesSetup } from '@slidev/types'

const setups: RoutesSetup[]
export default setups
}

declare module '#slidev/setups/context-menu' {
import type { ContextMenuSetup } from '@slidev/types'

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.0-beta.2",
"version": "0.49.0-beta.3",
"description": "Shared types declarations for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down

0 comments on commit 37ebff8

Please sign in to comment.