diff --git a/packages/docs/src/components/sidebar/sidebar.tsx b/packages/docs/src/components/sidebar/sidebar.tsx index 14e4c198c7b..3c9e36301a7 100644 --- a/packages/docs/src/components/sidebar/sidebar.tsx +++ b/packages/docs/src/components/sidebar/sidebar.tsx @@ -4,6 +4,33 @@ import { GlobalStore } from '../../context'; import { CloseIcon } from '../svgs/close-icon'; import styles from './sidebar.css?inline'; +const markdownItems = Object.fromEntries( + await Promise.all( + Object.entries(import.meta.glob<{ frontmatter?: MDX }>('../../routes/**/*.{md,mdx}')).map( + async ([k, v]) => { + // console.log(k, (await v())?.frontmatter); + return [ + k + .replace('../../routes', '') + .replace('(qwikcity)/', '') + .replace('(qwik)/', '') + .replaceAll(/([()])/g, '') + .replace('index.mdx', '') + .replace('index.md', ''), + await v(), + ] as const; + } + ) + ) +); + +type MDX = { + title: string; + contributors: string[]; + created_at: string; + updated_at: string; +}; + export const SideBar = component$((props: { allOpen?: boolean }) => { useStyles$(styles); @@ -59,6 +86,13 @@ export function Items({ }} > {item.text} + {markdownItems[item.href!]?.frontmatter?.updated_at + ? new Date(markdownItems[item.href!]?.frontmatter?.updated_at!).getTime() + + 5 * 24 * 60 * 60 * 1000 > + new Date().getTime() + ? 'new' + : null + : null} )} diff --git a/packages/docs/tsconfig.json b/packages/docs/tsconfig.json index c84c6b45327..6170523b82a 100644 --- a/packages/docs/tsconfig.json +++ b/packages/docs/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "incremental": true, - "target": "ES2020", - "module": "ES2020", + "target": "ES2022", + "module": "ES2022", "lib": ["es2021", "DOM", "webworker", "DOM.Iterable"], "resolveJsonModule": true, "jsx": "react-jsx",