SilasBerger / teaching-website

My teaching website 👨‍🏫
https://teach.silasberger.ch
1 stars 0 forks source link

Create shorthand for tiles #25

Closed SilasBerger closed 7 months ago

SilasBerger commented 7 months ago

Rough syntax idea:

:::Tiles small
:::Tile The title; https://foo.bar/
The body of the tile

::Tile Another title; no_grow
Another tile body

::Tile Third tile

::Tile Fourth tile; https://bar.baz/; no_grow
One more body
:::
lebalz commented 7 months ago

Not sure i got the idea right - in my understanding you want to nest the tiles inside the title? Note: nested directives must have more : than their children. And the "directive way" of doing, such that it's supported by e.g. mdxeditor, would be to write the title text as follows:

::::Tiles[small]
:::Tile[The title; https://foo.bar/]
The body of the tile

::Tile Another title; no_grow
Another tile body

::Tile Third tile

::Tile Fourth tile; https://bar.baz/; no_grow
One more body
:::
::::

Edit: Ahh, i think i misunderstood: the first :::Tile in your example should be ::Tile, then it works ;) (the comment about the square brackets still is true...)

I did something similar here: https://github.com/lebalz/ofi-blog/tree/docusaurus-v3/src/plugins/remark-flex-cards

with it, you can define cards (your tiles) or flex containers:

:::cards
First Card
::br
Second Card
:::

checkout the tests for some examples. If you want to support Tiles nested in Tiles, it is quiet tricky, but interesting to implement ;) https://github.com/lebalz/ofi-blog/blob/docusaurus-v3/src/plugins/remark-flex-cards/tests/plugin.test.ts