1
1
import path from 'node:path'
2
- import type { Connect , HtmlTagDescriptor , ModuleNode , Plugin , Update , ViteDevServer } from 'vite'
3
- import { isString , isTruthy , notNullish , range } from '@antfu/utils'
2
+ import type { Connect , ModuleNode , Plugin , Update , ViteDevServer } from 'vite'
3
+ import { notNullish , range } from '@antfu/utils'
4
4
import fg from 'fast-glob'
5
- import Markdown from 'markdown-it'
6
5
import { bold , gray , red , yellow } from 'kolorist'
7
6
8
7
import type { ResolvedSlidevOptions , SlideInfo , SlidePatch , SlidevPluginOptions , SlidevServerOptions } from '@slidev/types'
9
8
import * as parser from '@slidev/parser/fs'
10
9
import equal from 'fast-deep-equal'
11
10
12
11
import type { LoadResult } from 'rollup'
13
- import { stringifyMarkdownTokens , updateFrontmatterPatch } from '../utils'
12
+ import { updateFrontmatterPatch } from '../utils'
14
13
import { toAtFS } from '../resolver'
15
14
import { templates } from '../virtual'
16
15
import type { VirtualModuleTempalteContext } from '../virtual/types'
@@ -19,7 +18,7 @@ import { VIRTUAL_SLIDE_PREFIX, templateSlides } from '../virtual/slides'
19
18
import { templateConfigs } from '../virtual/configs'
20
19
import { templateMonacoRunDeps } from '../virtual/monaco-deps'
21
20
import { templateMonacoTypes } from '../virtual/monaco-types'
22
- import markdownItLink from '../syntax/markdown-it/markdown-it-link '
21
+ import { sharedMd } from '../commands/shared '
23
22
24
23
const regexId = / ^ \/ \@ s l i d e v \/ s l i d e \/ ( \d + ) \. ( m d | j s o n ) (?: \? i m p o r t ) ? $ /
25
24
const regexIdQuery = / ( \d + ?) \. ( m d | j s o n | f r o n t m a t t e r ) $ /
@@ -64,12 +63,9 @@ export function sendHmrReload(server: ViteDevServer, modules: ModuleNode[]) {
64
63
} )
65
64
}
66
65
67
- const md = Markdown ( { html : true } )
68
- md . use ( markdownItLink )
69
-
70
66
function renderNote ( text : string = '' ) {
71
67
let clickCount = 0
72
- const html = md . render ( text
68
+ const html = sharedMd . render ( text
73
69
// replace [click] marker with span
74
70
. replace ( / \[ c l i c k (?: : ( \d + ) ) ? \] / gi, ( _ , count = 1 ) => {
75
71
clickCount += Number ( count )
@@ -103,7 +99,7 @@ export function createSlidesLoader(
103
99
const { data, clientRoot, roots, mode } = options
104
100
105
101
const templateCtx : VirtualModuleTempalteContext = {
106
- md,
102
+ md : sharedMd ,
107
103
async getLayouts ( ) {
108
104
const now = Date . now ( )
109
105
if ( now - _layouts_cache_time < 2000 )
@@ -422,39 +418,6 @@ export function createSlidesLoader(
422
418
return replaced
423
419
} ,
424
420
} ,
425
- {
426
- name : 'slidev:index-html-transform' ,
427
- transformIndexHtml ( ) {
428
- const { info, author, keywords } = data . headmatter
429
- return [
430
- {
431
- tag : 'title' ,
432
- children : getTitle ( ) ,
433
- } ,
434
- info && {
435
- tag : 'meta' ,
436
- attrs : {
437
- name : 'description' ,
438
- content : info ,
439
- } ,
440
- } ,
441
- author && {
442
- tag : 'meta' ,
443
- attrs : {
444
- name : 'author' ,
445
- content : author ,
446
- } ,
447
- } ,
448
- keywords && {
449
- tag : 'meta' ,
450
- attrs : {
451
- name : 'keywords' ,
452
- content : Array . isArray ( keywords ) ? keywords . join ( ', ' ) : keywords ,
453
- } ,
454
- } ,
455
- ] . filter ( isTruthy ) as HtmlTagDescriptor [ ]
456
- } ,
457
- } ,
458
421
]
459
422
460
423
function updateServerWatcher ( ) {
@@ -554,12 +517,4 @@ export function createSlidesLoader(
554
517
// no setup script and not a vue component
555
518
return `<script setup>\n${ imports . join ( '\n' ) } \n</script>\n${ code } `
556
519
}
557
-
558
- function getTitle ( ) {
559
- if ( isString ( data . config . title ) ) {
560
- const tokens = md . parseInline ( data . config . title , { } )
561
- return stringifyMarkdownTokens ( tokens )
562
- }
563
- return data . config . title
564
- }
565
520
}
0 commit comments