Welcome to mirror list, hosted at ThFree Co, Russian Federation.

absurl.go « transform - github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa1d9930607d9bed2d7657de2e6be75bc59fbdec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package transform

import (
	"sync"
)

var absURLInit sync.Once
var ar *absURLReplacer

// for performance reasons, we reuse the first baseURL given
func initAbsURLReplacer(baseURL string) {
	absURLInit.Do(func() {
		ar = newAbsURLReplacer(baseURL)
	})
}

func AbsURL(absURL string) (trs []link, err error) {
	initAbsURLReplacer(absURL)

	trs = append(trs, func(rw ContentReWriter) {
		ar.replaceInHTML(rw)
	})
	return
}

func AbsURLInXML(absURL string) (trs []link, err error) {
	initAbsURLReplacer(absURL)

	trs = append(trs, func(rw ContentReWriter) {
		ar.replaceInXML(rw)
	})
	return
}