mirror of
				https://github.com/ZetaKebab/quartz.git
				synced 2025-11-03 22:49:47 +00:00 
			
		
		
		
	fix: deep clone before relativizing urls in transclude (closes #640)
This commit is contained in:
		
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -52,6 +52,7 @@
 | 
			
		||||
        "remark-parse": "^11.0.0",
 | 
			
		||||
        "remark-rehype": "^11.0.0",
 | 
			
		||||
        "remark-smartypants": "^2.0.0",
 | 
			
		||||
        "rfdc": "^1.3.0",
 | 
			
		||||
        "rimraf": "^5.0.5",
 | 
			
		||||
        "serve-handler": "^6.1.5",
 | 
			
		||||
        "shikiji": "^0.9.9",
 | 
			
		||||
@@ -5161,6 +5162,11 @@
 | 
			
		||||
        "node": ">=0.10.0"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/rfdc": {
 | 
			
		||||
      "version": "1.3.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz",
 | 
			
		||||
      "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/rimraf": {
 | 
			
		||||
      "version": "5.0.5",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz",
 | 
			
		||||
 
 | 
			
		||||
@@ -77,6 +77,7 @@
 | 
			
		||||
    "remark-parse": "^11.0.0",
 | 
			
		||||
    "remark-rehype": "^11.0.0",
 | 
			
		||||
    "remark-smartypants": "^2.0.0",
 | 
			
		||||
    "rfdc": "^1.3.0",
 | 
			
		||||
    "rimraf": "^5.0.5",
 | 
			
		||||
    "serve-handler": "^6.1.5",
 | 
			
		||||
    "shikiji": "^0.9.9",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,9 @@
 | 
			
		||||
import { slug as slugAnchor } from "github-slugger"
 | 
			
		||||
import type { Element as HastElement } from "hast"
 | 
			
		||||
import rfdc from "rfdc"
 | 
			
		||||
 | 
			
		||||
const clone = rfdc()
 | 
			
		||||
 | 
			
		||||
// this file must be isomorphic so it can't use node libs (e.g. path)
 | 
			
		||||
 | 
			
		||||
export const QUARTZ = "quartz"
 | 
			
		||||
@@ -121,7 +125,8 @@ const _rebaseHastElement = (
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function normalizeHastElement(el: HastElement, curBase: FullSlug, newBase: FullSlug) {
 | 
			
		||||
export function normalizeHastElement(rawEl: HastElement, curBase: FullSlug, newBase: FullSlug) {
 | 
			
		||||
  const el = clone(rawEl) // clone so we dont modify the original page
 | 
			
		||||
  _rebaseHastElement(el, "src", curBase, newBase)
 | 
			
		||||
  _rebaseHastElement(el, "href", curBase, newBase)
 | 
			
		||||
  if (el.children) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user