diff --git a/.vscode/settings.json b/.vscode/settings.json index 89a7604..af6a9db 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,4 @@ "asciidoc.preview.asciidoctorAttributes": { "skip-front-matter": true }, - "asciidoc.antora.enableAntoraSupport": false, } diff --git a/adocx/config.ts b/adocx/config.ts index f03ea4b..5453c47 100644 --- a/adocx/config.ts +++ b/adocx/config.ts @@ -1,17 +1,20 @@ import path from 'node:path'; +import type { + AdocNodeConverters, + AdocOptions, + AstroAdocxOptions, +} from '@sransara/astro-adocx/types'; // @ts-ignore: Types are not available import { register as krokiPluginRegisterHandle } from 'asciidoctor-kroki'; -import type { AdocOptions, AstroAdocxOptions, Template } from '@sransara/astro-adocx/types.js'; import { register as inlineMacroCalloutRegisterHandle } from './extensions/inlineMacroCallout'; -const templates = Object.fromEntries( - Object.entries(import.meta.glob('./templates/*.ts', { eager: true })).map(([key, value]) => [ - path.basename(key, '.ts'), - value as Template, - ]), -); +const nodeConverters = Object.fromEntries( + Object.entries(import.meta.glob('./nodeConverters/*.ts', { eager: true, import: 'convert' })).map( + ([key, value]) => [path.basename(key, '.ts'), value], + ), +) as AdocNodeConverters; const astroFenced = ` // For astro-layout-args @@ -29,7 +32,13 @@ export const adocxConfig = { // useful for asciidoctor-diagrams/kroki document.setAttribute('outdir', path.dirname(filePath)); }, - templates, + nodeConverters, + astroLayouts: { + note: { + path: '@/src/layouts/adocNoteLayout/AdocNoteLayout.astro', + args: 'poster={poster} metadata={metadata}', + }, + }, } satisfies AstroAdocxOptions; export const asciidoctorConfig = { @@ -45,7 +54,5 @@ export const asciidoctorConfig = { imagesdir: './_assets/', 'kroki-fetch-diagram': true, 'kroki-default-format': 'png', - 'astro-layout-path': '@/src/layouts/adocNoteLayout/AdocNoteLayout.astro', - 'astro-layout-args': '{...{ metadata, poster, docattrs, outline }}', }, } satisfies AdocOptions; diff --git a/adocx/extensions/inlineMacroCallout.ts b/adocx/extensions/inlineMacroCallout.ts index bccdaf5..8358849 100644 --- a/adocx/extensions/inlineMacroCallout.ts +++ b/adocx/extensions/inlineMacroCallout.ts @@ -1,6 +1,6 @@ import type { Extensions } from 'asciidoctor'; -import { isExtensionSingleton } from '@sransara/astro-adocx/types.js'; +import { isExtensionSingleton } from '@sransara/astro-adocx/types'; export function register(registry: typeof Extensions | Extensions.Registry) { if (isExtensionSingleton(registry)) { diff --git a/adocx/templates/inline_quoted.ts b/adocx/nodeConverters/inline_quoted.ts similarity index 69% rename from adocx/templates/inline_quoted.ts rename to adocx/nodeConverters/inline_quoted.ts index bf302da..5c20214 100644 --- a/adocx/templates/inline_quoted.ts +++ b/adocx/nodeConverters/inline_quoted.ts @@ -1,8 +1,8 @@ +import { UnsupportedNode, type AdocNodeConverter } from '@sransara/astro-adocx/types'; +import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence'; import type { Inline } from 'asciidoctor'; -import { UnsupportedNode, type Template } from '@sransara/astro-adocx/types.js'; -import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence.js'; -export const convert: Template['convert'] = (node: Inline, _opts?: any) => { +export const convert: AdocNodeConverter = (node: Inline, _opts?: any) => { const nodeType = node.getType(); if (['asciimath', 'latexmath'].includes(nodeType)) { addOnceToAstroFence(node, "import Mathtex from '@/src/lib/astro/mathtex/Mathtex.astro';"); diff --git a/adocx/templates/listing.ts b/adocx/nodeConverters/listing.ts similarity index 80% rename from adocx/templates/listing.ts rename to adocx/nodeConverters/listing.ts index d6fb46d..ef59883 100644 --- a/adocx/templates/listing.ts +++ b/adocx/nodeConverters/listing.ts @@ -1,12 +1,12 @@ // Reference: // - https://github.com/asciidoctor/asciidoctor-backends/blob/master/erb/html5/block_math.html.erb +import { type AdocNodeConverter } from '@sransara/astro-adocx/types'; +import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence'; +import { atag } from '@sransara/astro-adocx/utils/asx'; import type { Block } from 'asciidoctor'; -import { type Template } from '@sransara/astro-adocx/types.js'; -import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence.js'; -import { atag } from '@sransara/astro-adocx/utils/asx.js'; -export const convert: Template['convert'] = (node: Block, _opts?: any) => { +export const convert: AdocNodeConverter = (node: Block, _opts?: any) => { const id = node.getId(); const title = node.getCaptionedTitle(); const roles = node.getRoles().join(' '); diff --git a/adocx/templates/stem.ts b/adocx/nodeConverters/stem.ts similarity index 80% rename from adocx/templates/stem.ts rename to adocx/nodeConverters/stem.ts index 355dfd4..2ae911e 100644 --- a/adocx/templates/stem.ts +++ b/adocx/nodeConverters/stem.ts @@ -2,11 +2,11 @@ // - https://github.com/asciidoctor/asciidoctor-backends/blob/master/erb/html5/block_math.html.erb import type { Block } from 'asciidoctor'; -import { type Template } from '@sransara/astro-adocx/types.js'; -import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence.js'; -import { atag } from '@sransara/astro-adocx/utils/asx.js'; +import { type AdocNodeConverter } from '@sransara/astro-adocx/types'; +import { addOnceToAstroFence } from '@sransara/astro-adocx/utils/astroFence'; +import { atag } from '@sransara/astro-adocx/utils/asx'; -export const convert: Template['convert'] = (node: Block, _opts?: any) => { +export const convert: AdocNodeConverter = (node: Block, _opts?: any) => { const id = node.getId(); const title = node.getCaptionedTitle(); const roles = node.getRoles().join(' '); diff --git a/astro.config.js b/astro.config.js index 22ded70..83c76b2 100644 --- a/astro.config.js +++ b/astro.config.js @@ -1,7 +1,7 @@ import sitemap from '@astrojs/sitemap'; import solid from '@astrojs/solid-js'; import tailwind from '@astrojs/tailwind'; -import { adocx } from '@sransara/astro-adocx/integration.js'; +import { adocx } from '@sransara/astro-adocx/integration'; import { defineConfig } from 'astro/config'; import { adocxConfig, asciidoctorConfig } from './adocx/config'; diff --git a/package.json b/package.json index 2311149..564720c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@astrojs/solid-js": "^4.4.0", "@astrojs/tailwind": "^5.1.0", "@eslint/js": "^9.6.0", - "@sransara/astro-adocx": "^0.0.13", + "@sransara/astro-adocx": "^0.0.14", "@types/eslint": "^8.56.10", "@types/eslint__js": "^8.42.3", "@types/katex": "^0.16.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5c6db6..59b0b5e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: ^9.6.0 version: 9.6.0 '@sransara/astro-adocx': - specifier: ^0.0.13 - version: 0.0.13(asciidoctor@3.0.4(chokidar@3.6.0))(astro@4.11.5(@types/node@20.14.10)(typescript@5.5.3))(vite@5.3.3(@types/node@20.14.10)) + specifier: ^0.0.14 + version: 0.0.14(asciidoctor@3.0.4(chokidar@3.6.0))(astro@4.11.5(@types/node@20.14.10)(typescript@5.5.3))(vite@5.3.3(@types/node@20.14.10)) '@types/eslint': specifier: ^8.56.10 version: 8.56.10 @@ -841,8 +841,8 @@ packages: peerDependencies: solid-js: ^1.6.12 - '@sransara/astro-adocx@0.0.13': - resolution: {integrity: sha512-/sywXxTsF3IDEvpXiKKUOmtT2E1KO1dwlqm6AbGDFnjrzLBlJrBoRBxNvUxhLZeq3lsTX8/JP4YBAscb9TxLRg==, tarball: https://registry.npmjs.org/@sransara/astro-adocx/-/astro-adocx-0.0.13.tgz} + '@sransara/astro-adocx@0.0.14': + resolution: {integrity: sha512-E68KHftr+aPSvrGFXTGBF61HBlXu8OY7AVbf8q0VnyGc1di3oMFwJyATcFUtNhkRleeqUli1HEtCJpMiRAsPUg==, tarball: https://registry.npmjs.org/@sransara/astro-adocx/-/astro-adocx-0.0.14.tgz} peerDependencies: asciidoctor: ^3.0.4 astro: ^4.10.2 @@ -3812,7 +3812,7 @@ snapshots: dependencies: solid-js: 1.8.18 - '@sransara/astro-adocx@0.0.13(asciidoctor@3.0.4(chokidar@3.6.0))(astro@4.11.5(@types/node@20.14.10)(typescript@5.5.3))(vite@5.3.3(@types/node@20.14.10))': + '@sransara/astro-adocx@0.0.14(asciidoctor@3.0.4(chokidar@3.6.0))(astro@4.11.5(@types/node@20.14.10)(typescript@5.5.3))(vite@5.3.3(@types/node@20.14.10))': dependencies: app-root-path: 3.1.0 asciidoctor: 3.0.4(chokidar@3.6.0) diff --git a/src/layouts/adocNoteLayout/AdocNoteLayout.astro b/src/layouts/adocNoteLayout/AdocNoteLayout.astro index 1226f82..494e4df 100644 --- a/src/layouts/adocNoteLayout/AdocNoteLayout.astro +++ b/src/layouts/adocNoteLayout/AdocNoteLayout.astro @@ -1,6 +1,6 @@ --- import type { ImageMetadata } from 'astro'; -import type { Outline } from '@sransara/astro-adocx/utils/outline.js'; +import type { Outline } from '@sransara/astro-adocx/utils/outline'; import type { Metadata } from '@/src/lib/types/notes'; import NoteLayout from '@/src/layouts/noteLayout/NoteLayout.astro'; diff --git a/src/lib/astro/codeListing/CodeListing.astro b/src/lib/astro/codeListing/CodeListing.astro index d73e437..ffc5d1c 100644 --- a/src/lib/astro/codeListing/CodeListing.astro +++ b/src/lib/astro/codeListing/CodeListing.astro @@ -1,6 +1,6 @@ --- import { codeToHtml, bundledLanguages } from 'shiki'; -import { decodeSpecialChars } from '@sransara/astro-adocx/utils/string.js'; +import { decodeSpecialChars } from '@sransara/astro-adocx/utils/string'; interface Props { lang: string; diff --git a/src/lib/astro/mathtex/Mathtex.astro b/src/lib/astro/mathtex/Mathtex.astro index c769858..39daf2c 100644 --- a/src/lib/astro/mathtex/Mathtex.astro +++ b/src/lib/astro/mathtex/Mathtex.astro @@ -1,6 +1,6 @@ --- import AsciiMathParser from 'asciimath2tex'; -import { decodeSpecialChars } from '@sransara/astro-adocx/utils/string.js'; +import { decodeSpecialChars } from '@sransara/astro-adocx/utils/string'; import katex, { type KatexOptions } from 'katex'; import 'katex/dist/katex.min.css'; diff --git a/src/pages/notes/2019/build-yourself-a-git/index.adoc b/src/pages/notes/2019/build-yourself-a-git/index.adoc index 39c8633..dda90b9 100644 --- a/src/pages/notes/2019/build-yourself-a-git/index.adoc +++ b/src/pages/notes/2019/build-yourself-a-git/index.adoc @@ -1,5 +1,6 @@ = Conceptually building up to the fundamentals datastructures of Git. :sectnums: +:astro-layout: note Have you ever wondered how Git works? In this note we will incrementally build a version control system while taking inspiration from Git. diff --git a/src/pages/notes/2019/hello-world/index.adoc b/src/pages/notes/2019/hello-world/index.adoc index 89b9623..1851d53 100644 --- a/src/pages/notes/2019/hello-world/index.adoc +++ b/src/pages/notes/2019/hello-world/index.adoc @@ -2,6 +2,7 @@ import { Counter } from './_islands/Counter.jsx'; --- = Hello from another world. +:astro-layout: note This is first contact. diff --git a/src/pages/notes/2023/bazel-python-venv/index.adoc b/src/pages/notes/2023/bazel-python-venv/index.adoc index 8b1d62a..7e7ec1d 100644 --- a/src/pages/notes/2023/bazel-python-venv/index.adoc +++ b/src/pages/notes/2023/bazel-python-venv/index.adoc @@ -1,5 +1,5 @@ = Missing guide for creating a Python virtual environment in Bazel -:astro-layout-path: @/src/layouts/asciidocNoteLayout/AsciidocNoteLayout.astro +:astro-layout: note Bazel provides great tooling for building and testing Python code, but https://github.com/bazelbuild/rules_python[rules_python] as of this note (2023-05-05) do not provide an obvious way to create a Python shell with the `PYTHONPATH` footnote:[A Python shell with the `PYTHONPATH` is what I call a Python virtual environment in this guide.]. As we venture outside the norms like `venv` by using Bazel, having access to a Python shell/enviroment lets us: diff --git a/src/pages/notes/2023/power-to-tail-recursion/index.adoc b/src/pages/notes/2023/power-to-tail-recursion/index.adoc index cb76ef4..e8189f1 100644 --- a/src/pages/notes/2023/power-to-tail-recursion/index.adoc +++ b/src/pages/notes/2023/power-to-tail-recursion/index.adoc @@ -1,4 +1,5 @@ = Step by step tail recursion elimination of power function as an example +:astro-layout: note [discrete] === TLDR diff --git a/tsconfig.json b/tsconfig.json index 93d9b06..927298f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "baseUrl": ".", "paths": { - "@/*": ["*"] + "@/*": ["./*"] }, "checkJs": true, "jsx": "preserve",