html Jekyll的API.json液体文档

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Jekyll的API.json液体文档相关的知识,希望对你有一定的参考价值。

<!--Beginning Liquid Listing of _data/api-commons/ folder-->
{% assign raw_url = 'https://raw.githubusercontent.com/' | append: site.github_org  | append: '/' | append: site.github_repo | append: '/master/_data/api-commons/' %}
{% assign index = site.data.apis %}
{% assign apijson = index[0] %}
{% assign contents = site.data.api-commons %}

{% for item in contents %}

  {% assign item_name = item[0] %}
  {% assign folderitem = item[1] %}
  {% assign apijson = folderitem.apis %}

  {% assign api_name = apijson.name %}
  {% assign api_description = apijson.description %}
  {% assign api_image = apijson.image %}
  {% assign api_json_url = apijson.url %}

    <!-- APIs.json -->
    <table cellpadding="3" cellspacing="2" width="100%" border="0" style="margin-top: 0px;">

    {% assign blog_url = '' %}
    {% assign blogrss_url = '' %}
    {% assign portal_url = '' %}
    {% assign gitub_url = '' %}
    {% assign twitter_url = '' %}
    {% assign website_url = '' %}

    {% for common in apijson.x-common %}

      {% if common.type == 'x-portal' %}
        {% assign portal_url = common.url %}
      {% endif %}

      {% if common.type == 'x-website' %}
        {% assign website_url = common.url %}
      {% endif %}

      {% if portal_url == empty %}
        {% assign portal_url = website_url %}
      {% endif %}

      {% if common.type == 'x-getting-started' %}
        {% assign getting_started_url = common.url %}
      {% endif %}
      {% if common.type == 'x-authentication-overview' %}
        {% assign authentication_url = common.url %}
      {% endif %}
      {% if common.type == 'x-faq' %}
        {% assign faq_url = common.url %}
      {% endif %}

      {% if common.type == 'x-login' %}
        {% assign login_url = common.url %}
      {% endif %}

      {% if common.type == 'x-selfservice-registration' %}
        {% assign signup_url = common.url %}
      {% endif %}

      {% if common.type == 'x-documentation' %}
        {% assign documentation_url = common.url %}
      {% endif %}

      {% if common.type == 'x-code-page' %}
        {% assign code_page_url = common.url %}
      {% endif %}

      {% if common.type == 'x-road-map' %}
        {% assign road_map_url = common.url %}
      {% endif %}
      {% if common.type == 'x-issues' %}
        {% assign issue_url = common.url %}
      {% endif %}
      {% if common.type == 'x-change-log' %}
        {% assign change_log_url = common.url %}
      {% endif %}
      {% if common.type == 'x-status' %}
        {% assign status_dashboard_url = common.url %}
      {% endif %}

      {% if common.type == 'x-support' %}
        {% assign support_url = common.url %}
      {% endif %}

      {% if common.type == 'x-blog' %}
        {% assign blog_url = common.url %}
      {% endif %}

      {% if common.type == 'x-blog-rss' %}
        {% assign blogrss_url = common.url %}
      {% endif %}

      {% if common.type == 'x-twitter' %}
        {% assign twitter_url = common.url %}
      {% endif %}

      {% if common.type == 'x-github' %}
        {% assign gitub_url = common.url %}
      {% endif %}

      {% if common.type == 'x-signup' %}
        {% assign gitub_url = common.url %}
      {% endif %}

      {% if common.type == 'x-dedicated-plans--pricing-page' %}
        {% assign plan_url = common.url %}
      {% endif %}
      {% if common.type == 'x-rate-limit' %}
        {% assign rate_limit_url = common.url %}
      {% endif %}

      {% if common.type == 'x-terms-of-service-page' %}
        {% assign terms_of_service_url = common.url %}
      {% endif %}
      {% if common.type == 'x-privacy-policy-page' %}
        {% assign privacy_policy_url = common.url %}
      {% endif %}

    {% endfor %}

    <tr>
      <td>

        <h3>{{ api_name }} (<a href="{{ api_json_url }}" style="font-size: 12px; padding-left: 3px;">view APIs.json</a>)<h3>
        <p><img src="{{ api_image }}" width="150" style="padding: 15px;" align="left" /></p>
        <p style="font-size: 13px;">{{ api_description }}<p>

          <table width="100%" border="0" style="padding-top: 10px;">
            <tr>
              <td align="center" colspan="3" style="margin-left: 25px; margin-right: 25px;">
                <ul style="list-style: none; display: inline;">
                  {% if portal_url != '' %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ portal_url }}" target="_blank" title="Portal">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-portal-developers.jpg" width="32" align="center" />
                      </a>
                    </li>
                  {% endif %}
                  {% if blog_url != '' && blog_url != empty && blog_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ blog_url }}" target="_blank" title="Blog">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-blog-icon.png" width="27" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if blogrss_url != '' && blogrss_url != empty && blogrss_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ blogrss_url }}" target="_blank" title="Blog RSS">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-rss-icon.png" width="27" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if twitter_url != '' && twitter_url != empty && twitter_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ twitter_url }}" target="_blank" title="Twitter">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-twitter-icon.png" width="44" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if gitub_url != '' && gitub_url != empty && gitub_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ gitub_url }}" target="_blank" title="Github">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-github-icon.png" width="52" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if signup_url != '' && signup_url != empty && signup_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ signup_url }}" target="_blank" title="Signup">
                        <img src="https://s3.amazonaws.com/kinlane-productions/building-blocks/x-signup.png" width="45" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if issue_url != '' && issue_url != empty && issue_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ issue_url }}" target="_blank" title="Issues">
                        <img src="https://s3.amazonaws.com/kinlane-productions/bw-icons/bw-bug.png" width="38" align="center" />
                      </a>
                    </li>
                  {% endif %}

                  {% if terms_of_service_url != '' && terms_of_service_url != empty && terms_of_service_url != null %}
                    <li style="display: inline; padding-left: 15px; padding-right: 15px;">
                      <a href="{{ terms_of_service_url }}" target="_blank" title="Terms of Service">
                        <img src="http://kinlane-productions.s3.amazonaws.com/api-evangelist-site/building-blocks/bw-terms-conditions.png" width="33" align="center" />
                      </a>
                    </li>
                  {% endif %}


                </ul>
              </td>
            </tr>
          </table>

          <table width="100%" border="0" style="padding-top: 10px; border-bottom: 1px solid #000;">
             <tr>
             <td align="center" style="margin-left: 90px; margin-right: 90px;">

                 {% assign api_action_url = '' %}
                 {% assign numberofapis = apijson.apis | size %}

                   {% assign api_action_url = '' %}
                   {% for api in apijson.apis %}

                   <table cellpadding="3" cellspacing="2" width="100%" border="0">

                       {% assign api_action_spec = '' %}
                       {% assign api_action_url = '' %}
                       {% assign openapi_spec_json = '' %}

                       {% for property in api.properties %}

                         {% assign thisname = apijson.name | downcase %}
                         {% assign thisname = thisname | append:'/' %}
                         {% assign thisname = thisname | replace: ' ','-' %}

                         {% if property.type == 'x-openapi-spec' %}

                           {% assign openapi_spec_url = property.url %}
                           {% assign pathname = openapi_spec_url | replace: raw_url,'' %}
                           {% assign pathname = pathname | replace: '.json','' %}
                           {% assign pathname = pathname | replace: '/','.' %}

                           {% assign paths = pathname | split: '.' %}
                           {% assign root_index = paths[0] %}
                           {% assign api_index = paths[1] %}

                           {% assign openapi_spec_json = contents[root_index][api_index] %}

                         {% endif %}

                         <tr style="background-color: #FFF;">
                           <td align="left" style="font-size: 16px; font-weight: bold; padding: 10px;">{{ api.name }} Paths Available</td>
                           <td align="right" style="padding: 10px;">
                             {% if openapi_spec_url != null and openapi_spec_url != empty %}
                               (<a href="{{ openapi_spec_url }}" target="_blank" title="View OpenAPI Spec" style="font-size: 16px; font-weight: normal;">OpenAPI Spec</a>)
                             {% endif %}
                           </td>
                         </tr>
                         <tr id="methods-for-{{ pathname }}">
                           <td colspan="2">
                             <ul>

                               {% for path in openapi_spec_json.paths %}

                                 {% assign path_name = path[0] %}
                                 {% assign method_json = path[1] %}

                                 {% for method in method_json %}

                                   {% assign tagarray = method[1].tags %}
                                   {% assign tag = tagarray[0] %}
                                   {% assign verb = method[0] | upcase %}

                                   {% if verb == 'GET' %}
                                     {% assign back_color = site.get_color %}
                                   {% endif %}
                                   {% if verb == 'POST' %}
                                     {% assign back_color = site.post_color %}
                                   {% endif %}
                                   {% if verb == 'PUT' %}
                                     {% assign back_color = site.put_color %}
                                   {% endif %}
                                   {% if verb == 'DELETE' %}
                                     {% assign back_color = site.delete_color %}
                                   {% endif %}

                                   {% assign summary = method[1].summary %}
                                   {% assign description = method[1].description %}

                                   {% if summary != '' %}
                                      <li style="font-size: 11px;"><strong>{{ path_name }} -- {{ summary }} </strong> [{{ verb }}] {% if description != '' %} - {{ description }}{% endif %}</li>
                                   {% endif %}

                                 {% endfor %}
                               {% endfor %}

                             </ul>
                           </td>
                         </tr>
                       </table>

                       {% endfor %}
                   {% endfor %}

                 </td>
               </tr>
             </table>

        </td>
      </tr>
    </table>
{% endfor %}
<!--Ending Liquid Listing of _data/api-commons/ folder-->

以上是关于html Jekyll的API.json液体文档的主要内容,如果未能解决你的问题,请参考以下文章

html Jekyll Casts - 液体:循环

html 使用Jekyll _includes作为自定义液体功能

html Jekyll Casts - 液体:字符串过滤器

使用 Jekyll 时出现“液体异常:液体语法错误”

Jekyll 液体 if 语句混淆

在 Jekyll 的 Markdown 代码块中转义双花括号