first
少于1分钟
将以下英文翻译为中文:
first
https://gohugo.io/functions/first/
Slices an array to only the first N elements.
语法
first LIMIT COLLECTION
first works in a similar manner to the limit keyword in SQL. It reduces the array to only the first N elements. It takes the array and number of elements as input.
first takes two arguments:
number of elementsarrayorslice of maps or structs
layout/_default/section.html
| |
Note: Exclusive to first, LIMIT can be ‘0’ to return an empty array.
first and where Together
Using first and where together can be very powerful. Below snippet gets a list of posts only from main sections, sorts it by the title parameter, and then ranges through only the first 5 posts in that list:
first-and-where-together.html
| |
另请参阅
最后修改 June 1, 2023: 新增一个配置参数:sidebar_menu_truncate = 500 用于解决菜单不全的问题 (27810f1)