blogatto/config/sitemap
Configuration for generating the XML sitemap.
When a SitemapConfig is provided to the main Config, the build pipeline
collects all routes (both static pages and blog posts) and generates a
sitemap XML file. The optional filter and serialize functions allow
controlling which routes appear and how they are represented.
Example
import blogatto/config/sitemap
let cfg =
sitemap.new("/sitemap.xml")
|> sitemap.filter(fn(url) { url != "/admin" })
Types
How frequently a page is likely to change.
Used as a hint for search engine crawlers.
pub type ChangeFrequency {
Always
Hourly
Daily
Weekly
Monthly
Yearly
Never
}
Constructors
-
AlwaysThe page changes every time it is accessed.
-
HourlyThe page changes approximately every hour.
-
DailyThe page changes approximately every day.
-
WeeklyThe page changes approximately every week.
-
MonthlyThe page changes approximately every month.
-
YearlyThe page changes approximately every year.
-
NeverThe page is archived and will not change again.
Configuration for sitemap XML generation.
The filter function excludes routes by path. The serialize function
converts a route path into a SitemapEntry with priority, change frequency,
and optional alternate language links. The sitemap’s absolute URL is derived
from Config.site_url combined with path at build time.
pub type SitemapConfig {
SitemapConfig(
filter: option.Option(fn(String) -> Bool),
serialize: option.Option(fn(String) -> SitemapEntry),
path: String,
)
}
Constructors
-
SitemapConfig( filter: option.Option(fn(String) -> Bool), serialize: option.Option(fn(String) -> SitemapEntry), path: String, )Arguments
- filter
-
Optional predicate to include or exclude routes from the sitemap.
- serialize
-
Optional function to convert a route path into a sitemap entry.
- path
-
Output file path for the sitemap, relative to
output_dir(e.g.,"/sitemap.xml").
A single entry in the sitemap XML.
pub type SitemapEntry {
SitemapEntry(
url: String,
priority: option.Option(Float),
last_modified: option.Option(timestamp.Timestamp),
change_frequency: option.Option(ChangeFrequency),
)
}
Constructors
-
SitemapEntry( url: String, priority: option.Option(Float), last_modified: option.Option(timestamp.Timestamp), change_frequency: option.Option(ChangeFrequency), )Arguments
- url
-
The full URL for this sitemap entry.
- priority
-
Priority hint for search engines, between
0.0and1.0. - last_modified
-
Optional timestamp of the last modification of this page.
- change_frequency
-
Optional hint for how frequently this page changes.
Values
pub fn filter(
config: SitemapConfig,
f: fn(String) -> Bool,
) -> SitemapConfig
Set the predicate used to include or exclude routes from the sitemap.
pub fn new(path: String) -> SitemapConfig
Create a new SitemapConfig with the given output path.
All optional fields receive sensible defaults (None). Use the setter
functions to customize them via piping.
pub fn path(config: SitemapConfig, path: String) -> SitemapConfig
Set the output file path for the sitemap, relative to output_dir.
pub fn serialize(
config: SitemapConfig,
f: fn(String) -> SitemapEntry,
) -> SitemapConfig
Set the function used to convert a route path into a sitemap entry.