README.md

WebLS

A Gleam library for generating sitemaps and RSS feeds and more. to meet all your common web listing needs.

Package Version Hex Docs

sh
1gleam add webls
gleam
1import webls/sitemap
2import webls/rss
3import webls/robots
4
5pub fn sitemap() -> String {
6 sitemap.sitemap("https://gleam.run/sitemap.xml")
7 |> sitemap.with_sitemap_last_modified(birl.now())
8 |> sitemap.with_sitemap_items([
9 sitemap.item("https://gleam.run")
10 |> sitemap.with_item_frequency(sitemap.Monthly)
11 |> sitemap.with_item_priority(1.0),
12 sitemap.item("https://gleam.run/blog")
13 |> sitemap.with_item_frequency(sitemap.Weekly),
14 sitemap.item("https://gleam.run/blog/gleam-1.0"),
15 sitemap.item("https://gleam.run/blog/gleam-1.1"),
16 ]) |> sitemap.to_string()
17}
18
19pub fn rss() -> String {
20 [
21 rss.channel("Gleam RSS", "A test RSS feed", "https://gleam.run")
22 |> rss.with_channel_category("Releases")
23 |> rss.with_channel_language("en")
24 |> rss.with_channel_items([
25 rss.item("Gleam 1.0", "Gleam 1.0 is here!")
26 |> rss.with_item_link("https://gleam.run/blog/gleam-1.0")
27 |> rss.with_item_pub_date(birl.now())
28 |> rss.with_item_guid(#("gleam 1.0", Some(False))),
29 rss.item("Gleam 0.10", "Gleam 0.10 is here!")
30 |> rss.with_item_link("https://gleam.run/blog/gleam-0.10")
31 |> rss.with_item_author("user@example.com")
32 |> rss.with_item_guid(#("gleam 0.10", Some(True))),
33 ]),
34 ] |> rss.to_string()
35}
36
37pub fn robots() -> String {
38 robots.config("https://example.com/sitemap.xml")
39 |> robots.with_config_robots([
40 robots.robot("googlebot")
41 |> robots.with_robot_allowed_routes(["/posts/", "/contact/"])
42 |> robots.with_robot_disallowed_routes(["/admin/", "/private/"]),
43 robots.robot("bingbot")
44 |> robots.with_robot_allowed_routes(["/posts/", "/contact/", "/private/"])
45 |> robots.with_robot_disallowed_routes(["/"]),
46 ])
47 |> robots.to_string()
48}

Further documentation can be found at https://hexdocs.pm/webls.

Current Standards Compliance

ProtocolVersionStatus
Sitemaps0.9Complete
RSS2.0.1Complete
Robots.txt1997 IDSComplete

A Note on the RSS 2.0 spec, the PICS field for content ratings is not going to be supported as the PICS standard was discontinued more than a decade ago.

Utility Support

Typeto_stringBuilder FunctionsValidators
SitemapCompleteCompleteNone
RSS v2.0CompleteCompleteNone
Robots.txtCompleteCompleteNone

Development

sh
1gleam run # Run the project
2gleam test # Run the tests

Yes the name is a reference to the ls command in unix to list files