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

无法替换成纯名称的,代码是不是有问题 #100

Open
joebnb opened this issue Dec 25, 2023 · 1 comment
Open

无法替换成纯名称的,代码是不是有问题 #100

joebnb opened this issue Dec 25, 2023 · 1 comment

Comments

@joebnb
Copy link

joebnb commented Dec 25, 2023

https://github.com/vbenjs/vite-plugin-svg-icons/blob/7550357300793b96b3561fc708899b9f4309e906/packages/core/src/index.ts#L270C4-L270C38

用了FName 导致拿到的名称即使配置成

symbolId: '[name]',

也会永远存在 path

应该是

export function createSymbolId(name: string, options: ViteSvgIconsPlugin) {
  const { symbolId } = options

  if (!symbolId) {
    return name
  }

  let id = symbolId
  let fName = name

  const { fileName = '', dirName } = discreteDir(name)
  if (symbolId.includes('[dir]')) {
    id = id.replace(/\[dir\]/g, dirName)
    if (!dirName) {
      id = id.replace('--', '-')
    }
    fName = fileName
  }
  id = id.replace(/\[name\]/g, fileName) //这样的吧
  return id.replace(path.extname(id), '')
}
@joebnb joebnb changed the title 这行代码是不是有问题 无法替换成纯名称的,代码是不是有问题 Dec 25, 2023
@liang0-0
Copy link

+1, html里面会显示全路径,
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants