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,47 @@
/**
* @typedef {import('nlcst').Paragraph} Paragraph
*/
import {toString} from 'nlcst-to-string'
import {modifyChildren} from 'unist-util-modify-children'
// Closing or final punctuation, or terminal markers that should still be
// included in the previous sentence, even though they follow the sentences
// terminal marker.
import {affixSymbol} from '../expressions.js'
// Move certain punctuation following a terminal marker (thus in the next
// sentence) to the previous sentence.
export const mergeAffixSymbol = modifyChildren(
/**
* @type {import('unist-util-modify-children').Modifier<Paragraph>}
*/
function (child, index, parent) {
if ('children' in child && child.children.length > 0 && index > 0) {
const previous = parent.children[index - 1]
const first = child.children[0]
const second = child.children[1]
if (
previous &&
previous.type === 'SentenceNode' &&
(first.type === 'SymbolNode' || first.type === 'PunctuationNode') &&
affixSymbol.test(toString(first))
) {
child.children.shift() // Remove `first`.
previous.children.push(first)
// Update position.
if (first.position && previous.position) {
previous.position.end = first.position.end
}
if (second && second.position && child.position) {
child.position.start = second.position.start
}
// Next, iterate over the previous node again.
return index - 1
}
}
}
)