
{%- doc -%}
  Renders the blog post info text block.

  @param {object} [article] - The article object
  @param {string} [alignment] - The alignment of the text. Defaults to the block's alignment setting.
  @param {string} [author] - The author name. Defaults to article.author, placeholder text for onboarding
  @param {string} [date] - The published date. Defaults to article.published_at, placeholder text for onboarding
{%- enddoc -%}

{% assign block_settings = block.settings %}
{% assign alignment = alignment | default: block_settings.alignment %}
{% assign display_author = author | default: article.author %}
{% assign display_date = date | default: article.published_at %}

{%- if block_settings.show_date or block_settings.show_author -%}
  <div
    class="
      blog-post-details
      spacing-style
      justify-{{ alignment }}
      {% if block_settings.type_preset != '' %}{{ block_settings.type_preset }}{% endif%}
    "
    style="{% render 'spacing-style', settings: block_settings %}"
  >
    {%- if block_settings.show_date -%}
      <span>{{- display_date | time_tag: format: 'date' -}}</span>
    {%- endif -%}

    {%- if block_settings.show_date and block_settings.show_author -%}
      <span>{{ 'content.blog_details_separator' | t }}</span>
    {%- endif -%}

    {%- if block_settings.show_author -%}
      <span>{{ display_author }}</span>
    {%- endif -%}
  </div>
{% endif %}

{% stylesheet %}
  .blog-post-details {
    display: flex;
    gap: var(--gap-sm);
    font-size: var(--font-paragraph-size);
    color: rgb(var(--color-foreground-rgb) / var(--opacity-subdued-text));
    white-space: nowrap;
    flex-wrap: wrap;
  }

  .blog-post-details > span {
    text-overflow: clip;
    overflow: hidden;
  }
{% endstylesheet %}

{% # theme-check-disable ValidVisibleIf %}
{% schema %}
{
  "name": "t:names.details",
  "settings": [
    {
      "type": "checkbox",
      "id": "show_date",
      "label": "t:settings.show_date",
      "default": true
    },
    {
      "type": "checkbox",
      "id": "show_author",
      "label": "t:settings.show_author",
      "default": true
    },
    {
      "type": "header",
      "content": "t:content.typography"
    },
    {
      "type": "select",
      "id": "type_preset",
      "label": "t:settings.preset",
      "options": [
        {
          "value": "",
          "label": "t:options.default"
        },
        {
          "value": "paragraph",
          "label": "t:options.paragraph"
        },
        {
          "value": "h1",
          "label": "t:options.h1"
        },
        {
          "value": "h2",
          "label": "t:options.h2"
        },
        {
          "value": "h3",
          "label": "t:options.h3"
        },
        {
          "value": "h4",
          "label": "t:options.h4"
        },
        {
          "value": "h5",
          "label": "t:options.h5"
        },
        {
          "value": "h6",
          "label": "t:options.h6"
        }
      ],
      "default": "",
      "info": "t:info.edit_presets_in_theme_settings"
    },
    {
      "type": "text_alignment",
      "id": "alignment",
      "label": "t:settings.alignment",
      "visible_if": "{{ block.settings.show_alignment != false }}"
    },
    {
      "type": "checkbox",
      "id": "show_alignment",
      "label": "t:settings.show_alignment",
      "default": true,
      "visible_if": "{{ false }}"
    },
    {
      "type": "header",
      "content": "t:content.padding"
    },
    {
      "type": "range",
      "id": "padding-block-start",
      "label": "t:settings.top",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 24
    },
    {
      "type": "range",
      "id": "padding-block-end",
      "label": "t:settings.bottom",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 0
    }
  ],
  "presets": [
    {
      "name": "t:names.details"
    }
  ]
}
{% endschema %}
