mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-03 19:29:30 +08:00
28 lines
686 B
Text
28 lines
686 B
Text
export default function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
return nodes.map((node) => {
|
|
let cloned = node.clone()
|
|
|
|
// We always want override the source map
|
|
// except when explicitly told not to
|
|
let shouldOverwriteSource = node.raws.tailwind?.preserveSource !== true || !cloned.source
|
|
|
|
if (source !== undefined && shouldOverwriteSource) {
|
|
cloned.source = source
|
|
|
|
if ('walk' in cloned) {
|
|
cloned.walk((child) => {
|
|
child.source = source
|
|
})
|
|
}
|
|
}
|
|
|
|
if (raws !== undefined) {
|
|
cloned.raws.tailwind = {
|
|
...cloned.raws.tailwind,
|
|
...raws,
|
|
}
|
|
}
|
|
|
|
return cloned
|
|
})
|
|
}
|