asset

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package asset collects render-time asset references, accepts only publishable vault-relative file paths, excludes scan-skipped subtrees such as hidden paths, .obsidian, and node_modules, builds a single basename inventory over accepted regular non-symlink vault files, constrains outputs to assets/, reuses the pass-1 collision-aware destination plan when available, restores plain names for unique render-only assets, and copies only regular, non-symlink vault files with deterministic, case-safe output paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CandidatePaths

func CandidatePaths(note *model.Note, attachmentFolderPath string, rawDestination string) []string

CandidatePaths expands a destination into the ordered vault-relative candidates that pass 1 and pass 2 should probe.

func CopyAssetsWithReservedPaths

func CopyAssetsWithReservedPaths(vaultRoot string, outputRoot string, assets map[string]*model.Asset, diagCollector *diag.Collector, reservedOutputPaths []string) error

CopyAssetsWithReservedPaths copies merged assets while preserving reserved output destinations for non-asset writers.

func HasImageExtension

func HasImageExtension(value string) bool

HasImageExtension reports whether the destination ends with a supported image extension.

func IsPublishableAssetPath

func IsPublishableAssetPath(value string) bool

IsPublishableAssetPath reports whether value is a vault-relative path that the asset pipeline accepts as a publishable input.

func VaultRelativePathCandidate

func VaultRelativePathCandidate(rawDestination string) string

VaultRelativePathCandidate returns an exact vault-relative path candidate for explicit destinations that already contain path segments.

Types

type AssetCollector

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

AssetCollector records pass-2 asset registrations and returns the site-relative output path that renderers should use in generated HTML.

func NewCollectorWithResourceFiles

func NewCollectorWithResourceFiles(vaultRoot string, indexed map[string]*model.Asset, reservedOutputPaths []string, resourceFiles []string) (*AssetCollector, error)

NewCollectorWithResourceFiles creates a collector that optionally reuses a caller-provided emitted-resource inventory instead of walking the vault. Passing nil keeps collision planning scoped to indexed assets plus later pass-2 registrations.

func (*AssetCollector) PlanDestinations

func (c *AssetCollector) PlanDestinations(assets map[string]*model.Asset) map[string]string

PlanDestinations expands requested sources through the collector's inventory-aware basename groups, updates the collector's cached plan, and returns destinations for the requested sources.

func (*AssetCollector) Register

func (c *AssetCollector) Register(vaultRelPath string) string

Register records a vault-relative asset reference and returns the site-relative output path under assets/.

func (*AssetCollector) Snapshot

func (c *AssetCollector) Snapshot() map[string]*model.Asset

Snapshot returns a stable copy of the pass-2 registrations.

Jump to

Keyboard shortcuts

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