rules

package
v0.0.0-...-36b92fc Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DescriptionRule

type DescriptionRule struct {
	// Description is the description of the page.
	Description string

	Errors []string
}

DescriptionRule is a rule that checks if the description is present and not too long.

func (*DescriptionRule) Check

func (r *DescriptionRule) Check() error

Check checks if the description is present and not too long.

type Heading

type Heading struct {
	Level    int
	Position int
	Text     string
}

type HeadingRule

type HeadingRule struct {
	Headings []Heading
	HTML     string

	Errors []string
}

HeadingRule is a rule that checks if the title is present and not too long.

func (*HeadingRule) Check

func (r *HeadingRule) Check() error

Check checks if the title is present and not too long.

type RobotsTXTRule

type RobotsTXTRule struct {
	Body       []byte
	StatusCode int

	Errors []string
}

func (*RobotsTXTRule) Check

func (r *RobotsTXTRule) Check() error

Check checks if the robots.txt is present and not too long.

type Rule

type Rule interface {
	Check() error
}

func WithDescription

func WithDescription(parsed *goquery.Document) Rule

func WithHeading

func WithHeading(parsed *goquery.Document) Rule

func WithRobotsTXT

func WithRobotsTXT(path string) Rule

func WithSitemap

func WithSitemap(path string) Rule

func WithStatus

func WithStatus(status int, allowed []int) Rule

func WithTitle

func WithTitle(parsed *goquery.Document) Rule

type Rules

type Rules struct {
	Parsed     *goquery.Document
	StatusCode int
	URL        string
	// contains filtered or unexported fields
}

Rules is a set of rules.

func NewRulesWith

func NewRulesWith(url string, opts ...func(*Rules)) (*Rules, error)

func (*Rules) AddRule

func (r *Rules) AddRule(rule Rule)

func (*Rules) Check

func (r *Rules) Check() []string

Check checks all the rules.

type SitemapRule

type SitemapRule struct {
	Body       []byte
	StatusCode int

	Errors []string
}

SitemapRule is the sitemap.xml of the page.

func (*SitemapRule) Check

func (r *SitemapRule) Check() error

Check checks if the robots.txt is present and not too long.

type StatusRule

type StatusRule struct {
	// Status is the Status of the page.
	Status int

	Allowed []int

	Errors []string
}

StatusRule is a rule that checks if the status is allowed.

func (*StatusRule) Check

func (r *StatusRule) Check() error

Check checks if the status is allowed.

type TitleRule

type TitleRule struct {
	// Title is the title of the page.
	Title string

	Errors []string
}

TitleRule is a rule that checks if the title is present and not too long.

func (*TitleRule) Check

func (r *TitleRule) Check() error

Check checks if the title is present and not too long.

Jump to

Keyboard shortcuts

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