diff --git a/.vscode/launch.json b/.vscode/launch.json index be16dc5..683f04f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,15 +1,12 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "request": "launch", - "name": "Launch Program", + "name": "Debug", "type": "node", "cwd": "${workspaceFolder}", - "runtimeExecutable": "C:\\Users\\Adam\\scoop\\shims\\deno.EXE", + "runtimeExecutable": "deno", "runtimeArgs": [ "task", "debug" diff --git a/_components/NavLevel.tsx b/_components/NavLevel.tsx index 6d800c1..9879e2e 100644 --- a/_components/NavLevel.tsx +++ b/_components/NavLevel.tsx @@ -1,48 +1,54 @@ import { Finder } from "../_plugins/finder.ts"; export interface NavItem { - title?: string; - href?: string; - children?: NavItem[]; + title?: string; + href?: string; + children?: NavItem[]; } export default function NavLevel({ - items, - depth, - maxDepth, - finder, + items, + depth, + maxDepth, + finder, }: { - items?: NavItem[]; - depth?: number; - maxDepth?: number; - finder: Finder; + items?: NavItem[]; + depth?: number; + maxDepth?: number; + finder: Finder; }) { - if (items === null || items === undefined) { - return <>; - } + if (items === null || items === undefined) { + return <>; + } - if (items.length === 0) { - return ; - } + if (items.length === 0) { + return ; + } - depth ??= 0; - if (maxDepth && depth > maxDepth) { - return <>; - } - return ( - - ); + depth ??= 0; + if (maxDepth && depth > maxDepth) { + return <>; + } + return ( + + ); } diff --git a/_config.ts b/_config.ts index 4941791..d09b2d2 100644 --- a/_config.ts +++ b/_config.ts @@ -1,5 +1,11 @@ import lume from "lume/mod.ts"; -import markdown from "lume/plugins/markdown.ts"; +import remark from "lume/plugins/remark.ts"; +import remarkAlert from "./_plugins/remark-alerts.ts"; +import { remarkDefinitionList, defListHastHandlers } from "npm:remark-definition-list"; +import remarkTextr from "npm:remark-textr"; +import remarkTitle from "./_plugins/remark-title.ts"; +import rehypeSlug from "npm:rehype-slug"; +import rehypeAutolinkHeadings from "npm:rehype-autolink-headings"; import jsx from "lume/plugins/jsx.ts"; import sass from "lume/plugins/sass.ts"; import postcss from "lume/plugins/postcss.ts"; @@ -8,17 +14,17 @@ import picture from "lume/plugins/picture.ts"; import katex from "./_plugins/katex.ts"; import metas from "lume/plugins/metas.ts"; import resolveUrls from "lume/plugins/resolve_urls.ts"; -import codeHighlight from "./_plugins/shiki.ts"; +import shiki from "./_plugins/shiki.ts"; import sitemap from "lume/plugins/sitemap.ts"; import inline from "lume/plugins/inline.ts"; import pagefind from "lume/plugins/pagefind.ts"; -import { linkInsideHeader } from "lume_markdown_plugins/toc/anchors.ts"; -import toc from "lume_markdown_plugins/toc.ts"; import esbuild from "lume/plugins/esbuild.ts"; +import typographicBase from "npm:typographic-base"; +import tailwindcss from "lume/plugins/tailwindcss.ts"; import { AsciidoctorEngine, asciidocLoader } from "./_plugins/asciidoc.ts"; -import { default as markdownItAlerts } from "npm:markdown-it-github-alerts"; import finder from "./_plugins/finder.ts"; +import git from "./_plugins/git.ts"; const site = lume({ dest: "public/", @@ -26,31 +32,61 @@ const site = lume({ }); site.ignore("readme.md", "contributing.md", "public", "deps.ts", "_plugins"); -site.use(markdown({ - plugins: [[markdownItAlerts, { - titles: { - "tip": "", - "note": "", - "important": "", - "warning": "", - "caution": "" - }, - icons: { - "tip": " ", - "note": " ", - "important": " ", - "warning": " ", - "caution": " " - }, - classPrefix: "alert" - }]] -})); -site.use(toc({ - tabIndex: false, - // anchor: false, - anchor: linkInsideHeader({ - placement: "before" - }) +site.use(remark({ + remarkPlugins: [ + [ + remarkAlert, + { + classPrefix: "alert", + icons: { + "TIP": "", + "NOTE": "", + "WARNING": "" + }, + titles: { + "TIP": "Tip", + "NOTE": "Poznámka", + "WARNING": "Varování", + "IMPORTANT": "Důležitost", + "CAUTION": "Bacha!" + } + } + ], + [remarkDefinitionList], + [ + remarkTextr, + { + options: { + locale: "cs" + }, + plugins: [ + typographicBase + ] + } + ], + [remarkTitle] + ], + rehypePlugins: [ + [rehypeSlug], + [ + rehypeAutolinkHeadings, + { + content: { + type: "text", + value: "#" + }, + properties: { + tabIndex: -1, + class: "header-anchor" + } + } + ] + ], + rehypeOptions: { + handlers: { + ...defListHastHandlers + } + } })); site.use(jsx()); site.use(esbuild({ @@ -64,7 +100,16 @@ site.use(esbuild({ globalName: "fi" } })); -site.use(sass()); +site.use(sass({ + options: { + silenceDeprecations: [ + "mixed-decls", + "color-functions", + "global-builtin" + ] + } +})); +site.use(tailwindcss()); site.use(postcss()); site.use(metas()); site.use(resolveUrls()); @@ -102,10 +147,21 @@ site.use(katex({ fleqn: true, throwOnError: false, output: "html", - strict: false + strict: false, + delimiters: [ + { left: "$", right: "$", display: false }, + { left: "$$", right: "$$", display: true }, + { left: "\\(", right: "\\)", display: false }, + { left: "\\begin{equation}", right: "\\end{equation}", display: true }, + { left: "\\begin{align}", right: "\\end{align}", display: true }, + { left: "\\begin{alignat}", right: "\\end{alignat}", display: true }, + { left: "\\begin{gather}", right: "\\end{gather}", display: true }, + { left: "\\begin{CD}", right: "\\end{CD}", display: true }, + { left: "\\[", right: "\\]", display: true } + ] } })); -// .use(await codeHighlight()) +site.use(shiki()) site.loadPages([".ad"], { loader: asciidocLoader, engine: new AsciidoctorEngine() }) site.copy("fonts"); site.add("icons"); @@ -115,13 +171,13 @@ site.add("styles"); site.add([".md", ".ad"]); site.add([".png", ".jpg", ".jpeg", ".gif", ".svg"]) site.use(finder()); +site.use(git()); site.use(pagefind({ - indexing: { - rootSelector: "main" - }, ui: { - showSubResults: true - } + showSubResults: true, + autofocus: true, + containerId: "search" + }, })); export default site; diff --git a/_includes/layouts/base.tsx b/_includes/layouts/base.tsx index ed07f8d..863d2a6 100644 --- a/_includes/layouts/base.tsx +++ b/_includes/layouts/base.tsx @@ -1,41 +1,45 @@ export interface FrontPageData extends Lume.Data { - styles?: string[]; - useNewStyle?: boolean; + styles?: string[]; + useNewStyle?: boolean; } export default function ( - { title, children, styles, useNewStyle }: FrontPageData, + { title, children, styles, useNewStyle }: FrontPageData, ) { - return ( - // dark theme is not ready yet - - - - - - - - {title ? `${title} | Poznámky z FI` : "Poznámky z FI"} + const timestamp = Math.floor(Date.now() / 1000); + return ( + // dark theme is not ready yet + + + + + + + + {title ? `${title} | Poznámky z FI` : "Poznámky z FI"} - {!useNewStyle && - (styles ?? []).map((style) => ( - - ))} - {useNewStyle && } + {!useNewStyle && + (styles ?? []).map((style) => )} + {useNewStyle && ( + <> + + + + )} - -