<commit_before><%
  # Fall back on legacy link klass if we don't have any linkable types set on this link field
  linkable_types = field.fetch(:migrated_link, false) \
    ? field.dig(:options, 'linkable_types') # New-style link
    : [page.send(attribute).klass]          # Old-style link

  # Constantize upfront so we can #icon, #color, etc
  linkable_types.map! { |class_name| content_class_from_name(class_name) }
%>

<div class="content-field link">
  <div>
    <i class="material-icons left grey-text">link</i>
    <%= f.label attribute, I18n.translate(
      "attributes.#{page.class.name.downcase}.#{attribute}",
      scope: :activerecord,
      default: label.humanize.capitalize
    ) %>
  </div>

  <div class="input-field">
    <select name="attribute_field[linked_pages][]" multiple class="autosave-closest-form-on-change">
      <% linkable_types.each do |page_type| %>
        <optgroup label="<%= page_type.name.pluralize %>"><commit_msg>fix 500 on old links migrated over<commit_after><%
  # Fall back on legacy link klass if we don't have any linkable types set on this link field
  linkable_types = field.fetch(:migrated_link, false) \
    ? field.dig(:options, 'linkable_types') || [] # New-style link
    : [page.send(attribute).klass]                # Old-style link

  # Constantize upfront so we can #icon, #color, etc
  linkable_types.map! { |class_name| content_class_from_name(class_name) }
%>

<div class="content-field link">
  <div>
    <i class="material-icons left grey-text">link</i>
    <%= f.label attribute, I18n.translate(
      "attributes.#{page.class.name.downcase}.#{attribute}",
      scope: :activerecord,
      default: label.humanize.capitalize
    ) %>
  </div>

  <div class="input-field">
    <select name="attribute_field[linked_pages][]" multiple class="autosave-closest-form-on-change">
      <% linkable_types.each do |page_type| %>
        <optgroup label="<%= page_type.name.pluralize %>">
{'fraction_non_alphanumeric': 0.14601542416452443, 'fraction_numerical': 0.0035989717223650387, 'mean_word_length': 3.7579462102689485, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1460417', 'n_tokens_mistral': 659, 'n_tokens_neox': 637, 'n_words': 144}