Skip to content

Update author h-card on single posts#4

Merged
manton merged 2 commits intomicrodotblog:masterfrom
gRegorLove:author-hcard
Jun 16, 2020
Merged

Update author h-card on single posts#4
manton merged 2 commits intomicrodotblog:masterfrom
gRegorLove:author-hcard

Conversation

@gRegorLove
Copy link
Copy Markdown
Contributor

This moves some microformats2 classes so that the author h-card parses name, url, and photo. Also moves the p-author h-card inside the h-entry so it will parse the author property for the post.

I tested this in-browser on a friend's site and with the php-mf2 parser. It parses correctly and does not appear to change the page visually even though the conversation.js and post-meta are now moved inside the <article> element.

Minimum HTML example:

<article class="h-entry post">
  <section id="post-meta" class="clearfix p-author h-card">
    <a href="/" class="u-url">
      <img class="u-photo avatar" src="https://micro.blog/toddgrotenhuis/avatar.jpg" width="96" height="96">
      <div>
        <span class="p-name dark">Todd Grotenhuis</span>
        <span><a href="https://micro.blog/toddgrotenhuis">@toddgrotenhuis</a></span>
      </div>
    </a>
  </section>
</article>

Parsed:

{
    "items": [
        {
            "type": [
                "h-entry"
            ],
            "properties": {
                "author": [
                    {
                        "type": [
                            "h-card"
                        ],
                        "properties": {
                            "name": [
                                "Todd Grotenhuis"
                            ],
                            "url": [
                                "https://blog.grotenhuis.info/"
                            ],
                            "photo": [
                                "https://micro.blog/toddgrotenhuis/avatar.jpg"
                            ]
                        },
                        "value": "Todd Grotenhuis"
                    }
                ]
            }
        }
    ],
    "rels": {},
    "rel-urls": {},
    "debug": {
        "package": "https://packagist.org/packages/mf2/mf2",
        "source": "https://github.com/indieweb/php-mf2",
        "version": "0.4.6",
        "note": [
            "This output was generated from the php-mf2 library available at https://github.com/indieweb/php-mf2",
            "Please file any issues with the parser at https://github.com/indieweb/php-mf2/issues",
            "Using the Masterminds HTML5 parser"
        ]
    }
}

@gRegorLove
Copy link
Copy Markdown
Contributor Author

@manton Can you review this?

@manton
Copy link
Copy Markdown
Contributor

manton commented Jun 16, 2020

This is great, thank you! Will test it this week.

@manton manton merged commit f3f74ea into microdotblog:master Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants