add structured data

This commit is contained in:
tree🌴 2023-06-16 02:23:05 +02:00
parent bdf71f68c8
commit 7c2383acf4
7 changed files with 153 additions and 1 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dist

9
Makefile Normal file
View file

@ -0,0 +1,9 @@
.PHONY: all build
all: test build
test:
deno test --unstable --allow-read index.js
build:
deno run --unstable --allow-read --allow-write index.js build

View file

@ -34,7 +34,7 @@ Calendar with all events and links:
### Meetups ### Meetups
| # id | date | location | 👥 | coincidence | dri | | # id | date | location | 👥 | coincidence | dri |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
| `bcn-1` | 2023-07-?? | 🇪🇸 Barcelona | 50 | [ETHBarcelona](https://ethbarcelona.com/) | Tree | | `bcn-1` | 2023-07-?? | 🇪🇸 Barcelona | 50 | | Tree |
| `par-1` | 2023-07-?? | 🇫🇷 Paris || [EthCC 6](https://www.ethcc.io/) | ? | | `par-1` | 2023-07-?? | 🇫🇷 Paris || [EthCC 6](https://www.ethcc.io/) | ? |
| `waw-1` | 2023-08-?? | 🇵🇱 Warsaw || [ETHwarsaw](https://www.ethwarsaw.dev/) | Tree | | `waw-1` | 2023-08-?? | 🇵🇱 Warsaw || [ETHwarsaw](https://www.ethwarsaw.dev/) | Tree |
| `ber-1` | *2023-09-??* | *🇩🇪 Berlin* || [BBW](https://ethrome.org/) w/ [Protocol Berg](https://protocol.berlin/) | Tree | | `ber-1` | *2023-09-??* | *🇩🇪 Berlin* || [BBW](https://ethrome.org/) w/ [Protocol Berg](https://protocol.berlin/) | Tree |

42
events/meetups.yaml Normal file
View file

@ -0,0 +1,42 @@
- id: w3pm-bcn-1
date: "2023-07-??"
city: Barcelona
country: es
coincidence: "[ETHBarcelona](https://ethbarcelona.com/)"
lead: TBD
visitors: 50
- id: w3pm-waw-1
date: "2023-08-??"
city: Warsaw
country: pl
coincidence: "[ETHwarsaw](https://www.ethwarsaw.dev/)"
lead: Tree
- id: w3pm-ber-1
date: "2023-09-??"
city: Berlin
country: de
coincidence: "[BBW](https://ethrome.org/) w/ [Protocol Berg](https://protocol.berlin/)"
lead: TBD
- id: w3pm-rom-1
date: "2023-10-05"
city: Rome
country: it
coincidence: "[ETHRome](https://ethrome.org/)"
lead: PG
- id: w3pm-ist-1
date: "2023-11-??"
city: Istanbul
country: tr
coincidence: "[Devconnect Istanbul](https://devconnect.org/)"
lead: TBD
- id: w3pm-ams-1
date: "2024/Q2"
city: Amsterdam
country: nl
coincidence: "[ETHDam 2024](https://www.ethdam.com/)"
lead: TBD

18
events/summits.yaml Normal file
View file

@ -0,0 +1,18 @@
- id: w3ps1
date: "2023-06-05"
city: Prague
country: cz
coincidence: "[PBW](https://prgblockweek.com/) w/ [ETHPrague](https://ethprague.com/)"
lead: Tree
visitors: 180
links:
web: https://prague.web3privacy.info/
git: https://github.com/web3privacy/w3ps1
- id: w3ps2
date: "2023-11-02"
city: Brno
country: cz
coincidence: "[ETHBrno×3](https://ethbrno.cz/)"
lead: Tree
visitors: 250

48
index.js Normal file
View file

@ -0,0 +1,48 @@
import Ajv from "npm:ajv@8.8.2";
import addFormats from "npm:ajv-formats@2.1.1";
import { load as yamlLoad } from "https://deno.land/x/js_yaml_port@3.14.0/js-yaml.js";
import { emptyDir } from "https://deno.land/std@0.173.0/fs/mod.ts";
const types = [ "summits", "meetups" ]
async function _loadYaml(fn) {
return yamlLoad(await Deno.readTextFile(fn));
}
async function test() {
const ajv = new Ajv({ strict: false });
addFormats(ajv);
const schema = await _loadYaml("./schema.yaml");
const validator = ajv.compile(schema);
for (const type of types) {
Deno.test(`Check schema: ${type}`, async () => {
const list = await _loadYaml(`./events/${type}.yaml`);
if (!validator(list)) {
throw validator.errors;
}
})
}
}
async function build() {
const output = {}
for (const type of types) {
const list = await _loadYaml(`./events/${type}.yaml`);
output[type] = list
}
await emptyDir("./dist")
const fn = "./dist/index.json"
await Deno.writeTextFile(fn, JSON.stringify(output, null, 2))
console.log(`File saved: `)
}
switch (Deno.args[0] || "test") {
case "test":
await test();
break;
case "build":
await build();
break;
}

34
schema.yaml Normal file
View file

@ -0,0 +1,34 @@
type: array
items: { "$ref": "#/$defs/event" }
$defs:
event:
type: object
additionalProperties: false
required:
- id
- date
- city
- country
properties:
id:
type: string
date:
type: string
city:
type: string
country:
type: string
pattern: "^\\w{2}$"
coincidence:
type: string
lead:
type: string
visitors:
type: number
links:
type: object
additionalProperties: false
patternProperties:
"^[\\w]+":
type: string
format: uri