hugo: github.com/gohugoio/hugo/markup/tableofcontents Index | Files

package tableofcontents

import "github.com/gohugoio/hugo/markup/tableofcontents"

Index

Package Files

tableofcontents.go

Variables

var DefaultConfig = Config{
    StartLevel: 2,
    EndLevel:   3,
    Ordered:    false,
}

DefaultConfig is the default ToC configuration.

type Config Uses

type Config struct {
    // Heading start level to include in the table of contents, starting
    // at h1 (inclusive).
    StartLevel int

    // Heading end level, inclusive, to include in the table of contents.
    // Default is 3, a value of -1 will include everything.
    EndLevel int

    // Whether to produce a ordered list or not.
    Ordered bool
}
type Header struct {
    ID   string
    Text string

    Headers Headers
}

Header holds the data about a header and its children.

func (Header) IsZero Uses

func (h Header) IsZero() bool

IsZero is true when no ID or Text is set.

type Headers Uses

type Headers []Header

Headers holds the top level (h1) headers.

type Root Uses

type Root struct {
    Headers Headers
}

Root implements AddAt, which can be used to build the data structure for the ToC.

func (*Root) AddAt Uses

func (toc *Root) AddAt(h Header, row, level int)

AddAt adds the header into the given location.

func (Root) ToHTML Uses

func (toc Root) ToHTML(startLevel, stopLevel int, ordered bool) string

ToHTML renders the ToC as HTML.

Package tableofcontents imports 1 packages (graph) and is imported by 14 packages. Updated 2020-09-30. Refresh now. Tools for package owners.