From b9226797253d6e65e550eef5b5b810a0cd0addbf Mon Sep 17 00:00:00 2001 From: Malcolm Crum Date: Wed, 18 Dec 2024 14:17:39 +1300 Subject: [PATCH] Consistent column width. Auto parsing. Date default. --- src/content.config.ts | 1 + src/examples/date.json | 3 ++- src/pages/index.astro | 45 ++++++++++++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/content.config.ts b/src/content.config.ts index 20bfe09..1416cc8 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -9,6 +9,7 @@ export const examples = defineCollection({ title: z.string(), grammar: z.string(), input: z.string(), + highlighted: z.boolean().optional() }) }); diff --git a/src/examples/date.json b/src/examples/date.json index 2532462..6b0a50d 100644 --- a/src/examples/date.json +++ b/src/examples/date.json @@ -1,5 +1,6 @@ { "title": "Date", "grammar": "date = year '-' month '-' day\nyear = [1-2][0-9]*3\nmonth = '0'[1-9] / '1'[0-2]\nday = [0-3][0-9]\n\n# A simple example to play around with.\n# More examples in menu at top.\n\n# This Dingus is only a toy web-page.\n# To try your own pPEG grammars use\n# the peg-play.mjs command line tool,\n# that lets you work on your own files.", - "input": "2021-02-03" + "input": "2021-02-03", + "highlighted": true } \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 633a2e7..000ec85 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -3,33 +3,49 @@ import Layout from '../layouts/Layout.astro'; import {getCollection} from "astro:content" -const examples = (await getCollection("examples")).map(c => c.data) +const collection = await getCollection("examples") +const examples = collection.map(c => c.data) +const initialExample = examples.find(e => e.highlighted)?.title --- @@ -42,7 +58,7 @@ const examples = (await getCollection("examples")).map(c => c.data) "grammar input output" "footer footer footer"; grid-template-rows: auto 1fr auto; - grid-template-columns: 3fr 2fr 2fr; + grid-template-columns: 1fr 1fr 1fr; width: 100%; height: 100vh; padding: 1em; @@ -131,18 +147,17 @@ const examples = (await getCollection("examples")).map(c => c.data) -
+
-
-
+
Parse Tree