Fixes syntax highlighting

This commit is contained in:
2026-05-21 16:14:40 -07:00
parent 42cf585dca
commit 5c90096a10
2 changed files with 5 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
- [ ] Improve table rendering
- [ ] More image-flow options
- [ ] Fix capitalization in notes values/headers. Only the first letter is capitalized, but it should follow the capitalization of the folder. E.g. "NixOS" not "Nixos"
- [x] Code Highlighting
## Interaction

View File

@@ -26,7 +26,7 @@ So now that I had these notes, I needed to rebuild the structure so I could rend
I created a type like the following. Note that TypeScript does not support self-referential recursive types! It does allow self-referential interfaces though. Hence the odd syntax.
```TypeScript
```typescript
interface Hierarchy extends Record<string, Hierarchy> {}
```
@@ -34,7 +34,7 @@ However, after messing around with it for a while I realized I needed a little m
This lead me to create the following data structure. Some nodes would have children, others not, and they may or may not have an ID or title. (I could write both of these as `type` declarations because they are _mutually recursive_ types. TypeScript is weird.)
```TypeScript
```typescript
interface HierarchyNode {
id: string | null;
title: string | null;
@@ -45,7 +45,7 @@ type Hierarchy = Record<string, HierarchyNode>;
I started with algorithm of splitting all the paths into their parts, then going through and recursively grouping. However, I found this would be much simpler if I just did this as a fold/reduce so I could just focus on adding one path at a time. This gave me the following simple algorithm. Please ignore the repetition, it didn't seem worth cleaning up at the time.
```TypeScript
```typescript
function addToHierarchy(
tree: Hierarchy,
[noteId, title]: [string, string],
@@ -82,7 +82,7 @@ export function makeHierarchy(notes: Array<[string, string]>): Hierarchy {
So now I had to render the links. Astro thankfully _does_ support recursive components through `Astro.self`, so I was able to write a single component to render the hierarchy.
```Astro
```astro
---
import { type Hierarchy } from "../lib/hierarchy.ts";