Showcase build fix

This commit is contained in:
Sacha Weatherstone 2021-12-08 15:28:01 +11:00
parent 35269919ec
commit 0196c2b08f
5 changed files with 25 additions and 135 deletions

View file

@ -2,6 +2,7 @@ import { NetworkWriteup, ShowcaseNetwork } from '../../utils/showcase';
import { rakWireless } from '../hardware/rakWireless';
export const metadata: ShowcaseNetwork = {
id: "ckwhq3l5a000008kufkw8f3dg",
title: "Network 1",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget dui mollis.",

View file

@ -1,110 +0,0 @@
import { NetworkWriteup, ShowcaseNetwork } from '../../../utils/showcase';
import { rakWireless } from '../../hardware/rakWireless';
export const metadata: ShowcaseNetwork = {
id: "ckwhq3l5a000008kufkw8f3dg",
title: "Network 1",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget dui mollis.",
nodes: [
{
latitude: -37.656719,
longitude: 145.632219,
},
{
latitude: -37.633466,
longitude: 145.692371,
},
{
latitude: -37.559148,
longitude: 145.735771,
},
],
tags: ["community", "largeNetwork"],
};
export const writeup: NetworkWriteup = {
summary: "This is the article summary.",
body: [
{
heading: "This is the first heading.",
body: "This is the first body segment.",
},
{
heading: "This is the second heading.",
body: "This is the second body segment.",
},
{
heading: "This is the second heading.",
body: "This is the second body segment.",
},
],
bom: [
{
name: "This is the first material name.",
details: "This is the first material details.",
image: "https://example.com/image.png",
url: "https://example.com/material",
},
rakWireless.RAK19003,
rakWireless.RAK5005_O,
rakWireless.RAK11200,
rakWireless.RAK11310,
rakWireless.RAK4631,
rakWireless.RAK13101,
rakWireless.RAK2305,
rakWireless.RAK5860,
rakWireless.RAK12003,
rakWireless.RAK12004,
rakWireless.RAK12005,
rakWireless.RAK12006,
rakWireless.RAK12007,
rakWireless.RAK12009,
rakWireless.RAK12010,
rakWireless.RAK12011,
rakWireless.RAK12012,
rakWireless.RAK12015,
rakWireless.RAK12500,
rakWireless.RAK16000,
rakWireless.RAK18000,
rakWireless.RAK1901,
rakWireless.RAK1902,
rakWireless.RAK1903,
rakWireless.RAK1904,
rakWireless.RAK1906,
rakWireless.RAK1910,
rakWireless.RAK13001,
rakWireless.RAK13002,
rakWireless.RAK13003,
rakWireless.RAK13004,
rakWireless.RAK13005,
rakWireless.RAK14002,
rakWireless.RAK16001,
rakWireless.RAK1920,
rakWireless.RAK5801,
rakWireless.RAK5802,
rakWireless.RAK5804,
rakWireless.RAK5811,
rakWireless.RAK14000,
rakWireless.RAK14001,
rakWireless.RAK14003,
rakWireless.RAK1921,
rakWireless.RAK12002,
rakWireless.RAK18001,
rakWireless.RAK19005,
rakWireless.RAK19008,
rakWireless.RAK15000,
rakWireless.RAK15001,
rakWireless.RAK15002,
rakWireless.RAK19002,
rakWireless.RAK19004,
rakWireless.RAK19006,
rakWireless.RAK17000,
],
author: {
name: "Author Name",
about: "This is the author's about text.",
avatarUrl: "https://avatars0.githubusercontent.com/u/1234?s=460&v=4",
url: "",
},
};

View file

@ -3,14 +3,14 @@ import React from 'react';
import { ShowcaseNetwork, sortedNetworks, TagType } from '../utils/showcase';
import { useSelectedTags } from './useSelectedTags';
const filterNetworks = (
showcaseNetworks: ShowcaseNetwork[],
const filterNetworks = async (
showcaseNetworks: Promise<ShowcaseNetwork[]>,
selectedTags: TagType[]
) => {
if (selectedTags.length === 0) {
return showcaseNetworks;
}
return showcaseNetworks.filter((showcaseNetwork) => {
return (await showcaseNetworks).filter((showcaseNetwork) => {
if (showcaseNetwork.tags.length === 0) {
return false;
}

View file

@ -94,33 +94,27 @@ export const Tags: Record<TagType, Tag> = {
export const sortBy = <T>(array: T[], getter: (item: T) => unknown): T[] => {
const sortedArray = [...array];
sortedArray.sort((a, b) =>
// @ts-ignore
getter(a) > getter(b) ? 1 : getter(b) > getter(a) ? -1 : 0
);
return sortedArray;
};
export const TagList = Object.keys(Tags) as TagType[];
const sortNetworks = async (): Promise<ShowcaseNetwork[]> => {
const metadata = await Promise.all(
writeups.map(async (id) => {
const data = (await import(`../data/networks/${id}`)) as {
metadata: ShowcaseNetwork;
writeup: NetworkWriteup;
};
return data.metadata;
})
);
let sorted = sortBy(metadata, (network) => network.title.toLowerCase());
return (sorted = sortBy(
sorted,
(network) => !network.tags.includes("favorite")
));
// let result = networks;
const sortNetworks = async () => {
const metadataArr: ShowcaseNetwork[] = [];
const writeupsArr: NetworkWriteup[] = [];
writeups.map(async (id) => {
await import(`../data/networks/${id}`).then(
(network: { metadata: ShowcaseNetwork; writeup: NetworkWriteup }) => {
metadataArr.push(network.metadata);
writeupsArr.push(network.writeup);
}
);
});
// result = sortBy(result, (user) => user.title.toLowerCase());
// result = sortBy(result, (user) => !user.tags.includes("favorite"));
// return result;
return metadataArr;
};
export const sortedNetworks = sortNetworks();

View file

@ -1,8 +1,13 @@
{
// This file is not used in compilation. It is here just for a nice editor experience.
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"lib": ["ESNext", "DOM"],
"strict": true
"lib": ["DOM", "ESNext"],
"baseUrl": ".",
"resolveJsonModule": true,
"strict": true,
"types": ["@types/jest"]
},
"include": ["src/"]
"include": ["src/"],
"exclude": ["src/sw.js"]
}