web

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package web provides utilities for handling web assets in the application. It supports both development mode (using Vite dev server) and production mode (using built assets from the Vite manifest).

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultManager is the default asset manager instance
	DefaultManager = NewAssetManager()
)

Functions

func GetAssetPath

func GetAssetPath(path string) (string, error)

GetAssetPath returns the asset path using the default asset manager

func SetConfig added in v0.2.0

func SetConfig(cfg *config.Config) error

SetConfig sets the configuration for the default asset manager

Types

type AssetManager added in v0.1.5

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

AssetManager handles asset path resolution and caching

func NewAssetManager added in v0.1.5

func NewAssetManager() *AssetManager

NewAssetManager creates a new asset manager instance

func (*AssetManager) ClearCache added in v0.1.5

func (m *AssetManager) ClearCache()

ClearCache clears the asset path cache

func (*AssetManager) GetAssetPath added in v0.2.0

func (m *AssetManager) GetAssetPath(path string) (string, error)

GetAssetPath returns the correct path for an asset based on the environment

func (*AssetManager) GetAssetType added in v0.1.5

func (m *AssetManager) GetAssetType(path string) AssetType

GetAssetType returns the type of asset based on its path

func (*AssetManager) SetConfig added in v0.2.0

func (m *AssetManager) SetConfig(cfg *config.Config) error

SetConfig sets the application configuration

type AssetType added in v0.1.5

type AssetType string

AssetType represents the type of asset

const (
	// AssetTypeJS represents JavaScript files
	AssetTypeJS AssetType = "js"
	// AssetTypeCSS represents CSS files
	AssetTypeCSS AssetType = "css"
	// AssetTypeImage represents image files
	AssetTypeImage AssetType = "image"
	// AssetTypeFont represents font files
	AssetTypeFont AssetType = "font"
)

func GetAssetType added in v0.2.0

func GetAssetType(path string) AssetType

GetAssetType returns the asset type using the default asset manager

type Manifest

type Manifest map[string]ManifestEntry

Manifest represents the Vite manifest file

type ManifestEntry

type ManifestEntry struct {
	File    string   `json:"file"`
	Src     string   `json:"src"`
	IsEntry bool     `json:"isEntry"`
	CSS     []string `json:"css"`
}

ManifestEntry represents an entry in the Vite manifest file

Jump to

Keyboard shortcuts

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