Skip to content

Commit

Permalink
fix: restore script props structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Jul 12, 2023
1 parent ed59ba6 commit 90b9686
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/providers/root/script-inject-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ export const ScriptInjectProvider = () => {
if (!scripts) return null
return (
<>
{scripts.map((props) => (
<Script key={props.src} {...props} />
))}
{scripts.map((props) => {
const nextProps = { ...props } as any
const dataKeys = Object.keys(props).filter((key) =>
/data[A-Z]/.test(key),
)

for (const key of dataKeys) {
const newKey = key.replace(/([A-Z])/g, '-$1').toLowerCase()
nextProps[newKey] = nextProps[key]
delete nextProps[key]
}

console.log(nextProps)
return <Script key={props.src} {...nextProps} />
})}
</>
)
}

1 comment on commit 90b9686

@vercel
Copy link

@vercel vercel bot commented on 90b9686 Jul 12, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

shiro – ./

springtide.vercel.app
shiro-git-main-innei.vercel.app
shiro-innei.vercel.app
innei.in

Please sign in to comment.