aaronpk / XRay

X-Ray returns structured data from any URL
https://xray.p3k.app
MIT License
90 stars 15 forks source link

Match the 'main' object of the page on url #82

Closed sebsel closed 5 years ago

sebsel commented 5 years ago

I recently changed my HTML to make feeds work in XRay, but now I broke my permalink pages.

I now have two microformats objects on my page, in pseudo-JSON:

http://example.com/the-post
[
  h-card: { url: http://example.com/the-author },
  h-entry: { url:  http://example.com/the-post } 
]

The card is the first on the page, but the URL of the second matches the URL of the resource. That is the main object.

Real example: https://xray.p3k.io/parse?url=https%3A%2F%2Fseblog.nl%2F2018%2F11%2F09%2F2%2Fjapanse-90s&pretty=true

{
    "data": {
        "type": "card",
        "name": "Sebastiaan Andeweg",
        "url": "https://seblog.nl/",
        "photo": "https://seblog.nl/photo.jpg"
    },
    "url": "https://seblog.nl/2018/11/09/2/japanse-90s",
    "code": 200,
    "source-format": "mf2+html"
}

From php.microformats.io:

{
    "items": [
        {
            "type": [
                "h-card"
            ],
            "properties": {
                "name": [
                    "Sebastiaan Andeweg"
                ],
                "photo": [
                    "https://seblog.nl/photo.jpg"
                ],
                "url": [
                    "https://seblog.nl/"
                ]
            },
            "lang": "nl"
        },
        {
            "type": [
                "h-entry"
            ],
            "properties": {
                "name": [
                    "Avondje coden met Japanse 90s op de achtergrond. Jullie hebben geen idee."
                ],
                "url": [
                    "https://seblog.nl/2018/11/09/2/japanse-90s"
                ],
                "syndication": [
                    "https://twitter.com/Sebsel/status/1060999251138883584"
                ],
                "uid": [
                    "https://seblog.nl/2018/313/2"
                ],
                "author": [
                    "https://seblog.nl/"
                ],
                "published": [
                    "2018-11-09T20:54:55+0000"
                ],
                "updated": [
                    "2018-11-09T20:54:55+0000"
                ],
                "content": [
                    {
                        "html": "<p>Avondje coden met Japanse 90s op de achtergrond. Jullie hebben geen idee.</p>",
                        "value": "Avondje coden met Japanse 90s op de achtergrond. Jullie hebben geen idee.",
                        "lang": "nl"
                    }
                ]
            },
            "lang": "nl"
        }
    ],
    "rels": // ...
}
sebsel commented 5 years ago

This turned out to be a bug and was fixed with https://github.com/aaronpk/XRay/pull/83