NewSitemap (sitemap/sitemap.go)

gitea · modules/sitemap/sitemap.go · go · MIT
search

Copyright 2022 The Gitea Authors. All rights reserved. SPDX-License-Identifier: MIT

// Source: https://github.com/go-gitea/gitea | License: MIT | Copyright 2016 The Gitea Authors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package sitemap

import (
	"bytes"
	"encoding/xml"
	"fmt"
	"io"
	"time"
)

const (
	sitemapFileLimit = 50 * 1024 * 1024 // the maximum size of a sitemap file
	urlsLimit        = 50000

	schemaURL        = "http://www.sitemaps.org/schemas/sitemap/0.9"
	urlsetName       = "urlset"
	sitemapindexName = "sitemapindex"
)

// URL represents a single sitemap entry
type URL struct {
	URL     string     `xml:"loc"`
	LastMod *time.Time `xml:"lastmod,omitempty"`
}

// Sitemap represents a sitemap
type Sitemap struct {
	XMLName   xml.Name
	Namespace string

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key