Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/**
* @import {Event} from 'micromark-util-types'
*/
/**
* @typedef {'center' | 'left' | 'none' | 'right'} Align
*/
/**
* Figure out the alignment of a GFM table.
*
* @param {Readonly<Array<Event>>} events
* List of events.
* @param {number} index
* Table enter event.
* @returns {Array<Align>}
* List of aligns.
*/
export function gfmTableAlign(events, index) {
let inDelimiterRow = false;
/** @type {Array<Align>} */
const align = [];
while (index < events.length) {
const event = events[index];
if (inDelimiterRow) {
if (event[0] === 'enter') {
// Start of alignment value: set a new column.
// To do: `markdown-rs` uses `tableDelimiterCellValue`.
if (event[1].type === 'tableContent') {
align.push(events[index + 1][1].type === 'tableDelimiterMarker' ? 'left' : 'none');
}
}
// Exits:
// End of alignment value: change the column.
// To do: `markdown-rs` uses `tableDelimiterCellValue`.
else if (event[1].type === 'tableContent') {
if (events[index - 1][1].type === 'tableDelimiterMarker') {
const alignIndex = align.length - 1;
align[alignIndex] = align[alignIndex] === 'left' ? 'center' : 'right';
}
}
// Done!
else if (event[1].type === 'tableDelimiterRow') {
break;
}
} else if (event[0] === 'enter' && event[1].type === 'tableDelimiterRow') {
inDelimiterRow = true;
}
index += 1;
}
return align;
}