Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: print templates, slide layers and rewrite export function #1513

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7f03f74
feat: custom page templates
KermanX Apr 10, 2024
1c237df
rewrite notes page
KermanX Apr 11, 2024
604bee4
fix: overview style
KermanX Apr 11, 2024
ef9c67c
feat: implement print template
KermanX Apr 14, 2024
0c235e9
feat: implement entry template
KermanX Apr 14, 2024
0f6c200
Merge branch 'main' into feat/custom-pages
KermanX Apr 14, 2024
8cf763c
fix: print styles
KermanX Apr 14, 2024
6d326db
fix: warnings
KermanX Apr 14, 2024
05e7b7a
fix: e2e test
KermanX Apr 14, 2024
98f3bc9
feat: implement slide top & bottom layer
KermanX Apr 14, 2024
3f1dac5
Merge branch 'main' into feat/custom-pages
KermanX Apr 16, 2024
06d2e72
fix: restore id
KermanX Apr 16, 2024
8ff21ca
Merge branch 'main' into feat/custom-pages
KermanX Apr 16, 2024
4ed3e8b
fix
KermanX Apr 16, 2024
5112946
chore: update
KermanX Apr 17, 2024
3b491b3
docs: fix dead link
KermanX Apr 17, 2024
0587c2d
Merge branch 'main' into feat/custom-pages
KermanX Apr 17, 2024
cecfced
fix
KermanX Apr 17, 2024
6428d19
Merge branch 'feat/custom-pages' of https://github.com/KermanX/slidev…
KermanX Apr 17, 2024
c567e87
Merge branch 'main' into feat/custom-pages
KermanX Apr 18, 2024
dec41e1
feat: handout print template (wip)
KermanX Apr 18, 2024
8b8637b
chore: update
KermanX Apr 19, 2024
869da0e
chore: update
KermanX Apr 19, 2024
c6c151d
wip: rewrite export function
KermanX Apr 19, 2024
152d6fd
chore: update
KermanX Apr 19, 2024
408f0e3
wip
KermanX Apr 20, 2024
75f0744
Merge branch 'main' into feat/custom-pages
KermanX May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into feat/custom-pages
KermanX committed Apr 16, 2024
commit 3f1dac5b39a9608a5b636a9234b698c46256cb9d
6 changes: 5 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -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',
@@ -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',
},

12 changes: 12 additions & 0 deletions docs/.vitepress/showcases.ts
Original file line number Diff line number Diff line change
@@ -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://[email protected]/hongquan/rust-error-handling-ease-web-dev.git',
cover: 'https://i.imgur.com/2eBJofY.png',
datetime: '2024-04-10',
},
// Add yours here!
{
title: 'Yours?',
10 changes: 5 additions & 5 deletions docs/builtin/layouts.md
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
---
```

@@ -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%
---
```
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": "[email protected]",
"engines": {
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 <[email protected]>",
"license": "MIT",
64 changes: 0 additions & 64 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
@@ -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'
@@ -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)
74 changes: 74 additions & 0 deletions packages/client/setup/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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'),
})
}

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 <[email protected]>",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/create-app/template/package.json
Original file line number Diff line number Diff line change
@@ -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"
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 <[email protected]>",
"license": "MIT",
4 changes: 2 additions & 2 deletions packages/create-theme/template/package.json
Original file line number Diff line number Diff line change
@@ -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": {
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 <[email protected]>",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/slidev/node/virtual/setups.ts
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"license": "MIT",
7 changes: 7 additions & 0 deletions packages/types/client.d.ts
Original file line number Diff line number Diff line change
@@ -104,6 +104,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'

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 <[email protected]>",
"license": "MIT",
5 changes: 4 additions & 1 deletion packages/types/src/setups.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Awaitable } from '@antfu/utils'
import type * as monaco from 'monaco-editor'
import type { App, ComputedRef, Ref } from 'vue'
import type { Router } from 'vue-router'
import type { RouteRecordRaw, Router } from 'vue-router'
import type mermaid from 'mermaid'
import type { KatexOptions } from 'katex'
import type { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, Highlighter, LanguageInput } from 'shiki'
@@ -73,6 +73,7 @@ export type PreparserSetup = (filepath: string) => SlidevPreparserExtension
export type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>
export type AppSetup = (context: AppContext) => Awaitable<void>
export type RootSetup = () => Awaitable<void>
export type RoutesSetup = (routes: RouteRecordRaw[]) => RouteRecordRaw[]
export type MermaidSetup = () => Partial<MermaidOptions> | void
export type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>
export type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>
@@ -86,6 +87,8 @@ export const defineShikiSetup = defineSetup<ShikiSetup>
export const defineUnoSetup = defineSetup<UnoSetup>
export const defineMonacoSetup = defineSetup<MonacoSetup>
export const defineAppSetup = defineSetup<AppSetup>
export const defineRootSetup = defineSetup<RootSetup>
export const defineRoutesSetup = defineSetup<RoutesSetup>
export const defineMermaidSetup = defineSetup<MermaidSetup>
export const defineKatexSetup = defineSetup<KatexSetup>
export const defineShortcutsSetup = defineSetup<ShortcutsSetup>
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.