diff --git a/README.md b/README.md index 949ace1..2a0f177 100644 --- a/README.md +++ b/README.md @@ -198,3 +198,6 @@ Express authentication variables # Issues - title conflicting with path, url and slug in `create_raw_menu()` +- diagrams + - generate diagrams from image url and extension + - graph properties through code block arguments diff --git a/astro.config.mjs b/astro.config.mjs index cecb33e..b7d332a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,12 +1,15 @@ import { defineConfig } from 'astro/config'; import {config} from './config.js' import {collect_content} from './integrations/integration-content-structure.js' - +import yaml from '@rollup/plugin-yaml'; export default defineConfig({ integrations: [collect_content(config.collect_content)], output: "static", outDir: config.outDir, base: config.base, - trailingSlash: 'ignore' + trailingSlash: 'ignore', + vite: { + plugins: [yaml()] + } }); diff --git a/config.js b/config.js index 1abdcdf..0952c3b 100644 --- a/config.js +++ b/config.js @@ -16,7 +16,6 @@ const config = { base: base, content_path: contentdir, code_path: `${rootdir}/${outdir}/codes`, - plantuml_server: "https://www.plantuml.com/plantuml/svg", kroki_server: "https://kroki.io", client_menu:true, highlighter:{ @@ -32,7 +31,7 @@ config.collect_content = { rootdir:config.rootdir, contentdir:contentdir, content_ext:["md"], - assets_ext:["svg","webp","png","jpeg","jpg","xlsx","glb","hdr","ico"], + assets_ext:["svg","webp","png","jpeg","jpg","xlsx","glb","hdr","ico","puml"], outdir:structuredir,//dist does not persist before build out_menu:"public/menu.json",//used by src\layout\client_nav_menu.js debug:false diff --git a/content/examples/code/kroki/readme.md b/content/examples/code/kroki/readme.md deleted file mode 100644 index 52be0ef..0000000 --- a/content/examples/code/kroki/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -```blockdiag -blockdiag { - Kroki -> is -> Awesome; -} -``` diff --git a/content/examples/code/long_code.md b/content/examples/code/long_code.md deleted file mode 100644 index 81b7519..0000000 --- a/content/examples/code/long_code.md +++ /dev/null @@ -1,12 +0,0 @@ - -# Table of content title 1 - -```js -console.log("very long sentence with thousand words. very long sentence with thousand words. very long sentence with thousand words. very long sentence with thousand words.") -``` - -# generic language code - -``` -text code = alpha -``` diff --git a/content/examples/code/plantuml/readme.md b/content/examples/code/plantuml/readme.md deleted file mode 100644 index 4383878..0000000 --- a/content/examples/code/plantuml/readme.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: Plantuml -order: 10 ---- -# Plantuml Static integrations -These integrations use a markdown code block with specific languages -``` -@startuml -Michael -> Maria : Message(Hello) -@enduml -``` - -## Remark Plantuml Astro Component -This code is using `plantuml` code. The remark plugin associated with it is `remark-plantuml-astro` it generates an svg file out of the sequence and only passes a `` tag that will be replaced by an `SvgPz` astro component, which can enhance it with features like modal pan zoom or more. - -```plantuml my-puml -@startuml -Michael -> Maria : Message(Hello) -@enduml -``` - -## Remark Plantuml Svg -This code is using `plantumlsvg` code. The remark plugin associated with it is `remark-plantuml-svg`, it directly replaces the code block with an svg content. - -```plantumlsvg my-puml -@startuml -Michael -> Maria : Message(Hello) -@enduml -``` - -## Large sequence - -```plantuml my-puml-2 -@startuml -Michael -> Maria : Message(Hello) -Maria -> Marco : Message(Hi) -Marco -> Miranda : Message(Hi there) -Miranda -> Mario : Message(Hallo) -Mario -> Mathilda: Message(Hallo) -@enduml -``` diff --git a/content/examples/code/readme.md b/content/examples/code/readme.md index 0469830..34974f7 100644 --- a/content/examples/code/readme.md +++ b/content/examples/code/readme.md @@ -1 +1,16 @@ -code \ No newline at end of file +--- +title: Code Blocks +order: 1 +--- + +# long code + +```js +console.log("very long sentence with thousand words. very long sentence with thousand words. very long sentence with thousand words. very long sentence with thousand words.") +``` + +# generic language code + +``` +text code = alpha +``` diff --git a/content/examples/diagrams/readme.md b/content/examples/diagrams/readme.md new file mode 100644 index 0000000..7bc175c --- /dev/null +++ b/content/examples/diagrams/readme.md @@ -0,0 +1,72 @@ +--- +title: Code Diagrams +order: 2 +--- +# Block Diagram + +```blockdiag +blockdiag { + Kroki -> is -> Awesome; +} +``` +# Plantuml +## Sequence Diagram +```plantuml +@startuml +left to right direction +skinparam packageStyle rectangle +skinparam monochrome true +actor customer +actor clerk +rectangle checkout { + customer -- (checkout) + (checkout) .> (payment) : include + (help) .> (checkout) : extends + (checkout) -- clerk +} +@enduml +``` + +## Mind Map + +```plantuml my-mind-map +@startmindmap +skinparam monochrome true ++ OS +++ Ubuntu ++++ Linux Mint ++++ Kubuntu ++++ Lubuntu ++++ KDE Neon +++ LMDE +++ SolydXK +++ SteamOS +++ Raspbian +-- Windows 95 +-- Windows 98 +-- Windows NT +--- Windows 8 +--- Windows 10 +@endmindmap +``` + +## Work Breakout +Diagrams can also be linked from a separate file like this + +```md +[Work Breakout](./work-breakout.puml) +``` +Which will generate the same view as if it was embedded in a code block + +[Work Breakout](./work-breakout.puml) + +# Mermaid + +```mermaid +graph TD + A[ Anyone ] -->|Can help | B( Go to github.com/yuzutech/kroki ) + B --> C{ How to contribute? } + C --> D[ Reporting bugs ] + C --> E[ Sharing ideas ] + C --> F[ Advocating ] +``` diff --git a/content/examples/diagrams/work-breakout.puml b/content/examples/diagrams/work-breakout.puml new file mode 100644 index 0000000..525f554 --- /dev/null +++ b/content/examples/diagrams/work-breakout.puml @@ -0,0 +1,14 @@ +@startwbs +skinparam monochrome true +* Business Process Modelling WBS +** Launch the project +*** Complete Stakeholder Research +*** Initial Implementation Plan +** Design phase +*** Model of AsIs Processes Completed +**** Model of AsIs Processes Completed1 +**** Model of AsIs Processes Completed2 +*** Measure AsIs performance metrics +*** Identify Quick Wins +** Complete innovate phase +@endwbs diff --git a/content/examples/gallery/readme.md b/content/examples/gallery/readme.md index e7d0fb9..fada7fd 100644 --- a/content/examples/gallery/readme.md +++ b/content/examples/gallery/readme.md @@ -1,6 +1,6 @@ --- title: Gallery -order: 2 +order: 3 --- # Gallery diff --git a/content/home/readme.md b/content/home/readme.md index 7208b80..5dc9b0c 100644 --- a/content/home/readme.md +++ b/content/home/readme.md @@ -244,7 +244,7 @@ for item in my_list: # Links * external link Astro Markdown Render [github repo](https://github.com/MicroWebStacks/astro-markdown-render) link is external and opens in a new page. -* Link to the [Panzoom](/blog/panzoom) entry opens in the same page +* Link to the [Panzoom](/examples/panzoom) entry opens in the same page # Diagrams from code This is a concept where diagrams are generated from a code block that witholds the description needed to generate them. Note these sorts of diagrams are much more informative for automation and LLMs processing than usual bitmaps or vectorial images. diff --git a/integrations/create_menu.js b/integrations/create_menu.js index da98d48..45734c4 100644 --- a/integrations/create_menu.js +++ b/integrations/create_menu.js @@ -58,7 +58,6 @@ async function create_raw_menu(content_path,document_list){ })); const home_items = sorted_items.map(item => item.link === '/home' ? { ...item, link: '/' } : item); - console.log(home_items) const icons_file = join(content_path,"icons.yaml") if(await exists(icons_file)){ const icons_list = await load_yaml_abs(icons_file) diff --git a/package.json b/package.json index 127c17d..ef2eb6d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@google/model-viewer": "^3.4.0", "@svgdotjs/svg.js": "^3.1.2", "astro": "^4.5.10", - "content-structure": "^1.1.4", + "content-structure": "^1.1.7", "cookie-parser": "^1.4.6", "cors": "^2.8.5", "datatables.net-dt": "^1.13.7", @@ -32,7 +32,6 @@ "passport": "^0.6.0", "passport-github": "^1.1.0", "photoswipe": "^5.4.3", - "plantuml-encoder": "^1.4.0", "remark": "^15.0.1", "sharp": "^0.33.0", "shikiji": "^0.6.10", @@ -43,5 +42,8 @@ }, "engines": { "pnpm": ">=8.0.0" + }, + "devDependencies": { + "@rollup/plugin-yaml": "^4.1.2" } } diff --git a/src/components/markdown/Link.astro b/src/components/markdown/Link.astro index 84c59d3..544ba07 100644 --- a/src/components/markdown/Link.astro +++ b/src/components/markdown/Link.astro @@ -1,9 +1,11 @@ --- -import {relAssetToUrl} from '@/libs/assets.js' +import {relAssetToUrl, file_ext} from '@/libs/assets.js' import {toHast} from 'mdast-util-to-hast' import {toHtml} from 'hast-util-to-html' import ModelViewer from './model/ModelViewer.astro'; import TableXLSX from './table/TableXLSX.astro'; +import LinkCode from './code/LinkCode.astro'; +import kroki from './code/kroki.yaml' export interface Props { node: object; @@ -20,9 +22,15 @@ if(!external){ src = await relAssetToUrl(node.url,dirpath) } } -const is_model3d = node.url.endsWith(".glb") -const is_table = node.url.endsWith(".xlsx") -const is_link = !is_model3d && !is_table + +const ext = file_ext(node.url) +console.log("-----------------------") +console.log(ext) + +const is_model3d = (ext === "glb") +const is_table = (ext === "xlsx") +const is_diagram = Object.keys(kroki.formats).includes(ext) +const is_link = !is_model3d && !is_table && !is_diagram let title = "" if((node.children.length>0)&&(node.children[0].type == "text")){ title = node.children[0].value @@ -42,7 +50,9 @@ if((node.children.length>0)&&(node.children[0].type == "text")){ ))} } - +{is_diagram && + +}