parser

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date int64

type Frontmatter

type Frontmatter struct {
	Title        string   `yaml:"title"`
	Date         string   `yaml:"date"`
	Draft        bool     `yaml:"draft"`
	JSFiles      []string `yaml:"scripts"`
	Type         string   `yaml:"type"`
	Description  string   `yaml:"description"`
	PreviewImage string   `yaml:"previewimage"`
	Tags         []string `yaml:"tags"`
	TOC          bool     `yaml:"toc"`
	Authors      []string `yaml:"authors"`

	// Head is specifically used for
	// mentioning the head of the notes
	Head bool `yaml:"head"`
}

type LayoutConfig

type LayoutConfig struct {
	Navbar      []string `yaml:"navbar"`
	BaseURL     string   `yaml:"baseURL"`
	SiteTitle   string   `yaml:"siteTitle"`
	SiteScripts []string `yaml:"siteScripts"`
	Author      string   `yaml:"author"`
	ThemeURL    string   `yaml:"themeURL"`
}

type Note

type Note struct {
	CompleteURL    template.URL
	Date           int64
	Frontmatter    Frontmatter
	Body           template.HTML
	MarkdownBody   string
	LinkedNoteURLs []template.URL
	LiveReload     bool
}

type Parser

type Parser struct {
	// Templates stores the template data of all the pages of the site
	// Access the data for a particular page by using the relative path to the file as the key
	Templates map[template.URL]TemplateData

	// K-V pair storing all templates correspoding to a particular tag in the site
	TagsMap map[template.URL][]TemplateData

	// Stores data parsed from layout/config.yml
	LayoutConfig LayoutConfig

	// Posts contains the template data of files in the posts directory
	Posts []TemplateData

	//Stores all the notes
	Notes map[template.URL]Note

	// TODO: Look into the two below fields into a single one
	MdFilesName []string
	MdFilesPath []string

	// Stores flag value to render draft posts
	RenderDrafts bool

	// Common logger for all parser functions
	ErrorLogger *log.Logger

	Helper *helpers.Helper

	// Determines the injection of Live Reload JS in HTML
	LiveReload bool
}

func (*Parser) AddFile

func (p *Parser) AddFile(baseDirPath string, dirEntryPath string, frontmatter Frontmatter, markdownContent string, body string)

func (*Parser) BackLinkParser

func (p *Parser) BackLinkParser()

func (*Parser) DateParse

func (p *Parser) DateParse(date string) time.Time
func (p *Parser) ParseBacklink(noteURL template.URL)

func (*Parser) ParseConfig

func (p *Parser) ParseConfig(inFilePath string)

func (*Parser) ParseLayoutFiles

func (p *Parser) ParseLayoutFiles() *template.Template

ParseLayoutFiles Parse all the ".html" layout files in the layout/ directory

func (*Parser) ParseMDDir

func (p *Parser) ParseMDDir(baseDirPath string, baseDirFS fs.FS)

func (*Parser) ParseMarkdownContent

func (p *Parser) ParseMarkdownContent(filecontent string) (Frontmatter, string, string, bool)

func (*Parser) ParseRobots

func (p *Parser) ParseRobots(inFilePath string, outFilePath string)
func (p *Parser) ValidateBackLink(noteTitle string) (template.URL, error)

type TemplateData

type TemplateData struct {
	CompleteURL template.URL
	Date        int64
	Frontmatter Frontmatter
	Body        template.HTML
	LiveReload  bool
}

TemplateData This struct holds all of the data required to render any page of the site

Jump to

Keyboard shortcuts

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