modules

package
v0.0.0-...-5b3a7c8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModuleConfig = Config{}

Functions

func ApplyProjectConfigDefaults

func ApplyProjectConfigDefaults(cfg config.Provider, mod Module) error

ApplyProjectConfigDefaults applies default/missing module configuration for the main project.

Types

type Client

type Client struct {

	// Set when Go modules are initialized in the current repo, that is:
	// a go.mod file exists.
	GoModulesFilename string
	// contains filtered or unexported fields
}

Client contains most of the API provided by this package.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient creates a new Client that can be used to manage the Hugo Components in a given workingDir. The Client will resolve the dependencies recursively, but needs the top level imports to start out.

func (*Client) Collect

func (h *Client) Collect() (ModulesConfig, error)

type ClientConfig

type ClientConfig struct {
	// Fs to get the source
	Fs afero.Fs

	// If set, it will be run before we do any duplicate checks for modules
	// etc.
	// It must be set in our case, for default project structure
	HookBeforeFinalize func(m *ModulesConfig) error

	// Absolute path to the project dir.
	WorkingDir string

	// Absolute path to the project's themes dir.
	ThemesDir string

	// Read from config file and transferred
	ModuleConfig Config
}

ClientConfig configures the module Client.

type Config

type Config struct {
	Mounts  []Mount
	Imports []Import

	// Meta info about this module (license information etc.).
	Params map[string]any
}

Config holds a module config.

func DecodeConfig

func DecodeConfig(cfg config.Provider) (Config, error)

DecodeConfig creates a modules Config from a given Hugo configuration.

type Import

type Import struct {
	Path string // Module path

	IgnoreConfig  bool // Ignore any config in config.toml (will still follow imports).
	IgnoreImports bool // Do not follow any configured imports.
	NoMounts      bool // Do not mount any folder in this import.
	NoVendor      bool // Never vendor this import (only allowed in main project).
	Disable       bool // Turn off this module.
	Mounts        []Mount
	// contains filtered or unexported fields
}

type Module

type Module interface {

	// Config The decoded module config and mounts.
	Config() Config

	// Dir Directory holding files for this module.
	Dir() string

	// IsGoMod Returns whether this is a Go Module.
	IsGoMod() bool

	// Path Returns the path to this module.
	// This will either be the module path, e.g. "github.com/gohugoio/myshortcodes",
	// or the path below your /theme folder, e.g. "mytheme".
	Path() string

	// Owner In the dependency tree, this is the first module that defines this module
	// as a dependency.
	Owner() Module

	// Mounts Any directory remappings.
	Mounts() []Mount
}

type Modules

type Modules []Module

type ModulesConfig

type ModulesConfig struct {
	// All modules, including any disabled.
	AllModules Modules

	// All active modules.
	ActiveModules Modules

	// Set if this is a Go modules enabled project.
	GoModulesFilename string
}

type Mount

type Mount struct {
	Source string // relative path in source repo, e.g. "scss"
	Target string // relative target path, e.g. "assets/bootstrap/scss"

	Lang string // any language code associated with this mount.
}

func (Mount) Component

func (m Mount) Component() string

Jump to

Keyboard shortcuts

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