Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/versecafe/webls

A Gleam library for generating sitemaps, rss feeds, and more!
https://github.com/versecafe/webls

Last synced: 16 days ago
JSON representation

A Gleam library for generating sitemaps, rss feeds, and more!

Awesome Lists containing this project

README

        

# WebLS

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

[![Package Version](https://img.shields.io/hexpm/v/webls)](https://hex.pm/packages/webls)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/webls/)

```sh
gleam add webls
```

```gleam
import webls/sitemap
import webls/rss
import webls/robots

pub fn sitemap() -> String {
sitemap.sitemap("https://gleam.run/sitemap.xml")
|> sitemap.with_sitemap_last_modified(birl.now())
|> sitemap.with_sitemap_items([
sitemap.item("https://gleam.run")
|> sitemap.with_item_frequency(sitemap.Monthly)
|> sitemap.with_item_priority(1.0),
sitemap.item("https://gleam.run/blog")
|> sitemap.with_item_frequency(sitemap.Weekly),
sitemap.item("https://gleam.run/blog/gleam-1.0"),
sitemap.item("https://gleam.run/blog/gleam-1.1"),
]) |> sitemap.to_string()
}

pub fn rss() -> String {
[
rss.channel("Gleam RSS", "A test RSS feed", "https://gleam.run")
|> rss.with_channel_category("Releases")
|> rss.with_channel_language("en")
|> rss.with_channel_items([
rss.item("Gleam 1.0", "Gleam 1.0 is here!")
|> rss.with_item_link("https://gleam.run/blog/gleam-1.0")
|> rss.with_item_pub_date(birl.now())
|> rss.with_item_guid(#("gleam 1.0", Some(False))),
rss.item("Gleam 0.10", "Gleam 0.10 is here!")
|> rss.with_item_link("https://gleam.run/blog/gleam-0.10")
|> rss.with_item_author("[email protected]")
|> rss.with_item_guid(#("gleam 0.10", Some(True))),
]),
] |> rss.to_string()
}

pub fn robots() -> String {
robots.config("https://example.com/sitemap.xml")
|> robots.with_config_robots([
robots.robot("googlebot")
|> robots.with_robot_allowed_routes(["/posts/", "/contact/"])
|> robots.with_robot_disallowed_routes(["/admin/", "/private/"]),
robots.robot("bingbot")
|> robots.with_robot_allowed_routes(["/posts/", "/contact/", "/private/"])
|> robots.with_robot_disallowed_routes(["/"]),
])
|> robots.to_string()
}
```

Further documentation can be found at .

## Current Standards Compliance

| Protocol | Version | Status |
| ---------- | -------- | -------- |
| Sitemaps | 0.9 | Complete |
| RSS | 2.0.1 | Complete |
| Robots.txt | 1997 IDS | Complete |
| Atom | 1.0 | Complete |

> 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

| Type | to_string | Builder Functions | Validators |
| ---------- | --------- | ----------------- | ---------- |
| Sitemap | Complete | Complete | None |
| RSS v2.0 | Complete | Complete | None |
| Robots.txt | Complete | Complete | None |
| Atom | Complete | Complete | None |

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
```

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