// src/routes/articles/[slug].tsx
import { component$, Resource, useResource$, useStore } from '@builder.io/qwik';
import { useLocation } from '@builder.io/qwik-city';
import { marked } from "marked";
import articles from '~/data/articles';
import styles from './article.module.css';
export default component$(() => {
const location = useLocation();
const store = useStore({ article: null, notFound: false });
const slug = location.params.slug;
const article = articles.find(a => a.slug === slug);
const parseMarkdown = (text: string | undefined): string => {
if (!text) return '';
// Custom renderer
const renderer = new marked.Renderer();
// Override function to handle headings
renderer.heading = (text, level) => {
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return `${text}`;
};
// Override function to handle links
renderer.link = (href, title, text) => {
if (href.startsWith('/')) {
href = `https://github.com/Lissy93/personal-security-checklist/blob/old-version/${href}`;
}
title = title ? `title="${title}"` : '';
return `${text}`;
};
// Sanitize the input to remove