urls

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package urls provides template functions to deal with URLs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "urls" namespace.

func New

func New(u URL) *Namespace

New returns a new instance of the urls-namespaced template functions.

func (*Namespace) AbsLangURL

func (ns *Namespace) AbsLangURL(s any) (string, error)

AbsLangURL the string s and converts it to an absolute URL according to a page's position in the project directory structure and the current language.

func (*Namespace) AbsURL

func (ns *Namespace) AbsURL(s any) (string, error)

AbsURL takes the string s and converts it to an absolute URL.

func (*Namespace) JoinPath

func (ns *Namespace) JoinPath(elements ...any) (string, error)

JoinPath joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. If the argument list is empty, JoinPath returns an empty string.

func (*Namespace) Parse

func (ns *Namespace) Parse(rawurl any) (*url.URL, error)

Parse parses rawurl into a URL structure. The rawurl may be relative or absolute.

func (*Namespace) Ref

func (ns *Namespace) Ref(p any, args any) (string, error)

Ref returns the absolute URL path to a given content item from Page p.

func (*Namespace) RelLangURL

func (ns *Namespace) RelLangURL(s any) (string, error)

RelLangURL takes the string s and prepends the relative path according to a page's position in the project directory structure and the current language.

func (*Namespace) RelRef

func (ns *Namespace) RelRef(p any, args any) (string, error)

RelRef returns the relative URL path to a given content item from Page p.

func (*Namespace) RelURL

func (ns *Namespace) RelURL(s any) (string, error)

RelURL takes the string s and prepends the relative path according to a page's position in the project directory structure.

func (*Namespace) URLize

func (ns *Namespace) URLize(s any) (string, error)

URLize returns the the strings s formatted as an URL.

type RefLinker

type RefLinker interface {
	Ref(args map[string]any) (string, error)
	RelRef(args map[string]any) (string, error)
}

type URL

type URL interface {
	RelURL(in string) string
	AbsURL(in string) string
	URLize(uri string) string
}

Jump to

Keyboard shortcuts

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