Skip to content

Commit

Permalink
fix: improve type
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Feb 17, 2023
1 parent 6553678 commit 895e93e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/client/components/Sprites.ts
@@ -1,6 +1,5 @@
import { defineComponent, h } from 'vue'
// @ts-expect-error temp module
import { SVGIconData } from '@vuepress/plugin-svg-icons/temp'
import { SVGIconsData } from '@vuepress/plugin-svg-icons/data'

export const Sprites = defineComponent({
name: 'VpIconSprites',
Expand All @@ -10,7 +9,7 @@ export const Sprites = defineComponent({
h('div', {
style: 'display: none;',
'data-name': '__VUEPRESS_PLUGIN_SVG_ICONS__',
innerHTML: SVGIconData,
innerHTML: SVGIconsData,
})
},
})
Expand Down
3 changes: 3 additions & 0 deletions src/client/shims.d.ts
@@ -0,0 +1,3 @@
declare module '@vuepress/plugin-svg-icons/data' {
export const SVGIconsData: string
}
10 changes: 3 additions & 7 deletions src/node/svgIconPlugin.ts
Expand Up @@ -24,7 +24,7 @@ export const svgIconPlugin = ({
clientConfigFile: resolve(__dirname, '../client/config.js'),

alias: app => ({
'@vuepress/plugin-svg-icons/temp': app.dir.temp('svg-icon/svg-icon'),
'@vuepress/plugin-svg-icons/data': app.dir.temp('svg-icons/data'),
}),

define: {
Expand All @@ -40,11 +40,7 @@ export const svgIconPlugin = ({
console.error(`@goy/svg-icons: Can not find folder ${svgIconsDir}`)
}

const svgIconsData = await genSvgSprites(svgIconsDir, {
prefix: iconIdPrefix,
})
const SVGIconContent = `export const SVGIconData = '${svgIconsData}'`

app.writeTemp('svg-icon/svg-icon.js', SVGIconContent)
const svgIconsData = await genSvgSprites(svgIconsDir, { prefix: iconIdPrefix })
app.writeTemp('svg-icons/data.js', `export const SVGIconsData = '${svgIconsData}'`)
},
})

1 comment on commit 895e93e

@vercel
Copy link

@vercel vercel bot commented on 895e93e Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.