utils

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetUrl added in v0.12.0

func AssetUrl(path string) string

func DecorateContext

func DecorateContext(c context.Context, k ContextKey, v string) context.Context

DecorateContext decorates the given context with a key-value pair. It returns a new context with the provided key-value pair added.

func GetCanonicalUrl added in v0.12.0

func GetCanonicalUrl(c context.Context) string

GetCanonicalUrl returns the canonical URL from the given context. If the canonical URL is found in the context, it is returned. Otherwise, an empty string is returned.

func GetDescription

func GetDescription(c context.Context) string

GetDescription retrieves the description value from the context. If the value is found and is of type string, it is returned. Otherwise, an empty string is returned.

func GetEnvironment

func GetEnvironment(c context.Context) string

GetEnvironment returns the environment value from the given context. If the environment value is not found in the context, it returns "dev" as the default value.

func GetOpenGraphTags added in v0.12.0

func GetOpenGraphTags(c context.Context) map[string]string

func GetTitle

func GetTitle(c context.Context) string

GetTitle retrieves the title from the context. If the title is found, it returns the title as a string. If the title is not found, it returns an empty string.

func GetTwitterTags added in v0.12.0

func GetTwitterTags(c context.Context) map[string]string

func StripHtmlTags added in v0.12.0

func StripHtmlTags(s string) string

Types

type ContextKey

type ContextKey string
var CanonicalUrlKey ContextKey = "canonical:url"
var DescriptionKey ContextKey = "description"
var EnvironmentKey ContextKey = "environment"
var OgDescriptionKey ContextKey = "og:description"
var OgImageKey ContextKey = "og:image"
var OgSiteNameKey ContextKey = "og:site_name"
var OgTitleKey ContextKey = "og:title"
var OgTypeKey ContextKey = "og:type"
var OgUrlKey ContextKey = "og:url"
var TitleKey ContextKey = "title"
var TwitterCardKey ContextKey = "twitter:card"
var TwitterCreatorKey ContextKey = "twitter:creator"
var TwitterDescriptionKey ContextKey = "twitter:description"
var TwitterImageKey ContextKey = "twitter:image"
var TwitterSiteKey ContextKey = "twitter:site"
var TwitterTitleKey ContextKey = "twitter:title"

Jump to

Keyboard shortcuts

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