-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Anthony Fu <github@antfu.me>
- Loading branch information
Showing
9 changed files
with
103 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { existsSync } from 'node:fs' | ||
import { join } from 'node:path' | ||
import { toAtFS } from '../resolver' | ||
import type { VirtualModuleTemplate } from './types' | ||
|
||
export const templateGlobalLayers: VirtualModuleTemplate = { | ||
id: `/@slidev/global-layers`, | ||
getContent({ roots }) { | ||
const imports: string[] = [] | ||
|
||
let n = 0 | ||
function getComponent(names: string[]) { | ||
const components = roots | ||
.flatMap(root => names.map(name => join(root, name))) | ||
.filter(i => existsSync(i)) | ||
|
||
imports.push(components.map((path, i) => `import __n${n}_${i} from '${toAtFS(path)}'`).join('\n')) | ||
const render = components.map((_, i) => `h(__n${n}_${i})`).join(',') | ||
|
||
n++ | ||
|
||
return `{ render: () => [${render}] }` | ||
} | ||
|
||
const globalTop = getComponent(['global.vue', 'global-top.vue', 'GlobalTop.vue']) | ||
const globalBottom = getComponent(['global-bottom.vue', 'GlobalBottom.vue']) | ||
const slideTop = getComponent(['slide-top.vue', 'SlideTop.vue']) | ||
const slideBottom = getComponent(['slide-bottom.vue', 'SlideBottom.vue']) | ||
|
||
return [ | ||
imports.join('\n'), | ||
`import { h } from 'vue'`, | ||
`export const GlobalTop = ${globalTop}`, | ||
`export const GlobalBottom = ${globalBottom}`, | ||
`export const SlideTop = ${slideTop}`, | ||
`export const SlideBottom = ${slideBottom}`, | ||
].join('\n') | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { existsSync } from 'node:fs' | ||
import { join } from 'node:path' | ||
import { toAtFS } from '../resolver' | ||
import type { VirtualModuleTemplate } from './types' | ||
|
||
export const templateNavControls: VirtualModuleTemplate = { | ||
id: '/@slidev/custom-nav-controls', | ||
getContent({ roots }) { | ||
const components = roots | ||
.flatMap((root) => { | ||
return [ | ||
join(root, 'custom-nav-controls.vue'), | ||
join(root, 'CustomNavControls.vue'), | ||
] | ||
}) | ||
.filter(i => existsSync(i)) | ||
|
||
const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join('\n') | ||
const render = components.map((i, idx) => `h(__n${idx})`).join(',') | ||
|
||
return `${imports} | ||
import { h } from 'vue' | ||
export default { | ||
render: () => [${render}], | ||
}` | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters