mirror of
https://github.com/urbit/developers.urbit.org.git
synced 2024-10-26 15:49:50 +03:00
util: pull pair function into util file
This commit is contained in:
parent
798d4f16fa
commit
a3c79ec95d
9
lib/util.js
Normal file
9
lib/util.js
Normal file
@ -0,0 +1,9 @@
|
||||
// Organises arrays into arrays of pairs
|
||||
// Used mostly for TwoUps + content
|
||||
export const pair = (arr) =>
|
||||
arr.reduce(function (rows, key, index) {
|
||||
return (
|
||||
(index % 2 == 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) &&
|
||||
rows
|
||||
);
|
||||
}, []);
|
@ -13,6 +13,8 @@ import Card from "../../components/Card";
|
||||
import Meta from "../../components/Meta";
|
||||
import Header from "../../components/Header";
|
||||
import Footer from "../../components/Footer";
|
||||
import { pair } from '../../lib/util';
|
||||
|
||||
export default function Directory({ search, directory }) {
|
||||
const post = {
|
||||
title: "Directory",
|
||||
@ -156,14 +158,6 @@ export default function Directory({ search, directory }) {
|
||||
);
|
||||
}
|
||||
|
||||
const pair = (arr) =>
|
||||
arr.reduce(function (rows, key, index) {
|
||||
return (
|
||||
(index % 2 == 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) &&
|
||||
rows
|
||||
);
|
||||
}, []);
|
||||
|
||||
export async function getStaticProps() {
|
||||
const directory = getAllPosts(
|
||||
["name", "title", "patp", "org", "content"],
|
||||
|
Loading…
Reference in New Issue
Block a user