gold_utils

package
v1.0.1-0...-3379034 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCrossOrigin = errors.New(`file is from another origin, cannot be opened`)

Functions

func AddClass

func AddClass(node ast.Node, classes ...string)

func ApplyHtmlTransformers

func ApplyHtmlTransformers(raw []byte, trs ...HtmlTransformer) ([]byte, error)

Types

type HtmlTransformer

type HtmlTransformer interface {
	TransformHtml(doc *goquery.Document) error
}

type NodeFilter

type NodeFilter func(node *goquery.Selection) bool

func NegateNodeFilter

func NegateNodeFilter(f NodeFilter) NodeFilter

type WebFileSystem

type WebFileSystem interface {
	// 比如页面地址是:/page/
	// 如果 url 是:1.txt,则打开 /page/1.txt
	// 如果 url 是:/other/2.txt,则打开 /other/2.txt
	OpenURL(url string) (fs.File, error)
	// relative: 结果是否只保留相对路径(前提是同源的情况下)。
	Resolve(url string, relative bool) (*url.URL, error)
}

URL 引用文件系统。

场景:前端相对路径链接。

func NewWebFileSystem

func NewWebFileSystem(root fs.FS, base *url.URL) WebFileSystem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL