{
  "$schema": "./.schemas/page.schema.json",
  "title": "RSS Feeds",
  "icon": "dot.radiowaves.up.forward",
  "sources": {
    "feeds": {
      "feeds": {
        "list": "news-feeds",
        "max": 30
      },
      "every": "30m"
    }
  },
  "cards": [
    {
      "id": "latest",
      "type": "list",
      "label": "Latest",
      "max_items": 7,
      "items": [],
      "source": {
        "ref": "feeds",
        "empty": {
          "when": {
            "path": "feeds[0].key",
            "exists": false
          },
          "text": "Add a feed's address to the list news-feeds in Settings → Lists."
        },
        "map": {
          "items": {
            "each": "items",
            "limit": 30,
            "fields": {
              "text": {
                "template": "{title|clip:120}"
              },
              "subtitle": {
                "template": "{feed|clip:80}"
              },
              "detail": {
                "if": {
                  "path": "published",
                  "exists": true
                },
                "then": {
                  "template": "{published|ago}"
                }
              },
              "url": "url"
            }
          }
        }
      }
    },
    {
      "id": "feeds",
      "type": "fleet",
      "label": "Feeds",
      "max_items": 30,
      "items": [],
      "source": {
        "ref": "feeds",
        "map": {
          "items": {
            "each": "feeds",
            "fields": {
              "name": {
                "if": {
                  "path": "answer.title",
                  "exists": true
                },
                "then": {
                  "template": "{answer.title|clip:24}"
                },
                "else": {
                  "if": {
                    "path": "host",
                    "exists": true
                  },
                  "then": {
                    "template": "{host|clip:24}"
                  },
                  "else": {
                    "template": "{entry|clip:24}"
                  }
                }
              },
              "state": {
                "if": {
                  "any": [
                    {
                      "path": "state",
                      "equals": "answered"
                    },
                    {
                      "all": [
                        {
                          "path": "answer.count",
                          "exists": true
                        },
                        {
                          "path": "fails",
                          "lt": 3
                        }
                      ]
                    }
                  ]
                },
                "then": {
                  "template": "ok"
                },
                "else": {
                  "template": "warning"
                }
              },
              "detail": {
                "if": {
                  "path": "state",
                  "equals": "answered"
                },
                "then": {
                  "if": {
                    "path": "answer.items[0].published",
                    "exists": true
                  },
                  "then": {
                    "template": "Newest post {answer.items[0].published|ago}"
                  },
                  "else": {
                    "template": "{answer.count} posts, none dated"
                  }
                },
                "else": {
                  "template": "{error|clip:80}"
                }
              },
              "url": {
                "template": "legato://page/rss-feed?feed={key}"
              }
            }
          }
        }
      }
    }
  ]
}
