files

package
v0.0.0-...-90e99f2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsolutePath

func AbsolutePath(relativePath string) string

Convert a relative path to an absolute path, relative to the current working directory.

func CopyDirectory

func CopyDirectory(sourceDirectory string, targetDirectory string) (int, error)

Copy a directory into another.

func CopyFile

func CopyFile(source string, destination string) error

Copy a file from a source to a destination. Taken from: https://opensource.com/article/18/6/copying-files-go

func FileName

func FileName(filePath string) string

Given a path, return the name of a file without the file extension.

func ParseMarkdown

func ParseMarkdown(text []byte) (map[string]interface{}, string)

Parse markdown, rendering it to HTML and returning the metadata as a map.

func PathToIdentifier

func PathToIdentifier(filePath string) string

Convert a path into a page/post ID.

func PathToTitle

func PathToTitle(filePath string) string

Convert a path into a page/post title.

func ReadFiles

func ReadFiles(directoryPath string, pathPrefix string) (map[string]File, error)

Recursively read files and returns a map of their path to their content, relative to the directory path.

func RenderMarkdown

func RenderMarkdown(text []byte) string

Render markdown to HTML.

func WriteFile

func WriteFile(targetFilePath string, contents string) error

Write the contents of the string to a file.

Types

type File

type File struct {
	Type    FileType
	Path    string
	Content []byte
}

A file which was read from the file system.

func (File) Render

func (f File) Render() string

Render the file.

type FileType

type FileType uint8

A file type.

const (
	UnknownFile FileType = iota
	HtmlFile
	MarkdownFile
)

Jump to

Keyboard shortcuts

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