C# AMP:在具有AMP列表的数组中按类别分组数据
我已经成功地使用C# AMP:在具有AMP列表的数组中按类别分组数据,c#,html,amp-html,C#,Html,Amp Html,我已经成功地使用amp list和amp mustache构建了一个包含简单JSON对象数组的列表,并且在JS中有一个工作版本,但尝试将其转换为amp。 我试着按每个项目的类别值对它进行分组。我不知道该怎么做。如有任何建议,将不胜感激 下面是不带类别的列表的示例代码 <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></scri
amp list
和amp mustache
构建了一个包含简单JSON对象数组的列表,并且在JS中有一个工作版本,但尝试将其转换为amp。
我试着按每个项目的类别值对它进行分组。我不知道该怎么做。如有任何建议,将不胜感激
下面是不带类别的列表的示例代码
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
<amp-list width="auto" height="140" layout="fixed-height" items="." src="/test-data">
<template type="amp-mustache">
<div class="col-12">
<a href="{{url}}">
<div class="d-flex">
<amp-img src="{{image}}" width="100" height="100"></amp-img>
<div class="col-8">
<h4>{{text}}</h4>
</div>
</div>
</a>
</div>
</template>
</amp-list>
理想结果:
我认为这是不可能的。剩下的就是通过将数据划分为类别来更改JSON结构。
[
{
"url": "google.com",
"image": "https://picsum.photos/100",
"text": "Text Here",
"category": "A"
},
{
"url": "stackoverflow.com",
"image": "https://picsum.photos/100",
"text": "More Text Here",
"category": "B"
},
{
"url": "yahoo.com",
"image": "https://picsum.photos/100",
"text": "Some Text",
"category": "A"
},
]