rust parser working on local build. fix docker build

This commit is contained in:
ZockerKatze
2025-06-24 10:23:34 +02:00
parent 7e2ada529d
commit 5ad73485ce
10 changed files with 425 additions and 24 deletions

View File

@@ -14,6 +14,13 @@ interface Post {
createdAt: string;
}
// Runtime statistics for parser usage
const parserStats = {
rust: 0,
typescript: 0,
lastRustError: '',
};
export default function PostPage({ params }: { params: { slug: string[] } }) {
const [post, setPost] = useState<Post | null>(null);
// Modal state for zoomed image
@@ -648,6 +655,20 @@ export default function PostPage({ params }: { params: { slug: string[] } }) {
const loadPost = async () => {
try {
const response = await fetch(`/api/posts/${encodeURIComponent(slugPath)}`);
const parser = response.headers.get('X-Parser');
const rustError = response.headers.get('X-Rust-Parser-Error');
if (parser === 'rust') {
parserStats.rust++;
console.log('%c[Rust Parser] Used for this post.', 'color: green; font-weight: bold');
} else {
parserStats.typescript++;
console.log('%c[TypeScript Parser] Used for this post.', 'color: orange; font-weight: bold');
if (rustError) {
parserStats.lastRustError = rustError;
console.warn('[Rust Parser Error]', rustError);
}
}
console.info('[Parser Stats]', parserStats);
const data = await response.json();
setPost(data);
} catch (error) {