How do I list entries from a single author? I'm returning the username as the second segment /blog/username and then setting the username var to craft.request.segment(2).

I'm looking to list a group of entries by that author (username). I've tried:

{% set blogPosts = craft.entries.section('blog').relatedTo(username) %}


I've also tried this:

{% set blogPosts = craft.entries.section('blog').relatedTo({ targetElement: username, field: 'author' })%}


Anyone have a way to list through entries related by author?
Try this:

{# First, grab the username from the URI #}
{% set username = craft.request.segment(2) %}

{# Then, grab the user based on the username %}
{% set user = craft.users.username(username).first() %}

{# Make sure we actually found a user #}
{% if user %}
    {% set blogPosts = craft.entries.section('blog').authorId(user.id).find() %}

    Found: {{ blogPosts|length }} blog posts.
{% endif %}