Neater way to merge this conditional entry query? I know there's a better way to do this - eg by merging in the relatedTo parameter if categorySlug is defined rather than defining 2 different queries, but I can't for the life of me figure it out... how would you simplify this?

{% if (categorySlug is defined) and (categorySlug != null) %}
   {# GET CONTENT FROM ONE CATEGORY #}
   {% set contentQuery = craft.entries
   .section(contentSection)
   .isFeatured('not 1')
   .relatedTo(craft.categories.slug(categorySlug))
%}
{% else %}
   {# GET ALL CONTENT #}
   {% set contentQuery = craft.entries
   .section(contentSection)
   .isFeatured('not 1')
   %}
{% endif %}
You can do this:

{% set query = craft.entries.section(contentSection).isFeatured('not 1') %}

{% if (categorySlug is defined) and (categorySlug != null) %}
   {# GET CONTENT FROM ONE CATEGORY #}
   {% set contentQuery = query.relatedTo(craft.categories.slug(categorySlug)).all() %}
{% else %}
   {# GET ALL CONTENT #}
   {% set contentQuery = query.all() %}
{% endif %}


Or if you want to be fancy ;)

{% set query = craft.entries.section(contentSection).isFeatured('not 1') %}

{% set contentQuery = ((categorySlug is defined) and (categorySlug != null)) ? query.relatedTo(craft.categories.slug(categorySlug)).all() : query.all() %}