diff --git a/README.md b/README.md index 4e0e42c..b04b234 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,8 @@ for development of content-structure it is possible to replace the registry vers # Ideas - support different icon types (.svg, .ico, .png) and allow it in content root -- top readme.md in content used as home - public folder inside content and ignored by content structure - .structureignore to allow e.g. .git/workflow/deploy.yaml -- test mixture of readme page with filenames and folders - fix consistency of top menu folder name different than slug - Code - keep separate plantuml and kroki (due to perf reason) @@ -53,6 +51,7 @@ for development of content-structure it is possible to replace the registry vers - PanZoom - URL params, zoom on text, multiple hits counter - update pan zoom status in url on mouse up +- watch and regenrate .structure on save for modified files only - check potential replacement of scrollspy with intersection Observer API - enhance intersection to cover a path of all visible sections from the page in the toc : start heading, stop heading diff --git a/content/examples/readme.md b/content/examples/readme.md index 997a913..e933d69 100644 --- a/content/examples/readme.md +++ b/content/examples/readme.md @@ -1,4 +1,5 @@ --- +title: Examples order: 2 --- All examples are listed in this section diff --git a/content/home/readme.md b/content/readme.md similarity index 88% rename from content/home/readme.md rename to content/readme.md index 574045a..04daeef 100644 --- a/content/home/readme.md +++ b/content/readme.md @@ -11,27 +11,27 @@ link to [svg image](#svg-image) Images are encapsulated inside a component that can open them in a Modal full view for Pan and zoom function ```markdown -![astro markdown render](./astro-markdown-render-small.png) +![astro markdown render](./home/astro-markdown-render-small.png) ``` will generate this image -![astro markdown render](./astro-markdown-render-small.png) +![astro markdown render](./home/astro-markdown-render-small.png) ## Advanced Image Directive In order to give more options, using the image directive allows to pass more arguments from markdown ```markdown -:image[]{src=./astro-markdown-render-small.png alt="Astro Markdown Render" height=200 center} +:image[]{src=./home/astro-markdown-render-small.png alt="Astro Markdown Render" height=200 center} ``` will generate this image height adjusted size. Aspect ratio is conserved even when giving either of width or height. It is also possible to center the image. -:image[]{src=./astro-markdown-render-small.png alt="Astro Markdown Render" height=200 center} +:image[]{src=./home/astro-markdown-render-small.png alt="Astro Markdown Render" height=200 center} ## SVG Image -![Tree](./tree.svg) +![Tree](./home/tree.svg) ## Gallery @@ -52,12 +52,12 @@ This is a Gallery Astro component, a yaml Code block with metadata 'gallery' is will generate this gallery ```yaml pz_gallery -- tree.svg -- images/gallery-tiger.svg -- images/gallery-long_diag.svg -- images/gallery-Linux_kernel_map.svg -- images/gallery-tiger.svg -- images/github-dark.png +- home/tree.svg +- home/images/gallery-tiger.svg +- home/images/gallery-long_diag.svg +- home/images/gallery-Linux_kernel_map.svg +- home/images/gallery-tiger.svg +- home/images/github-dark.png ``` ## Cards @@ -95,18 +95,18 @@ models from https://modelviewer.dev/editor/ just by inserting a link to a .glb file ```markdown -[Astronaut](./Astronaut.glb) +[Astronaut](./home/Astronaut.glb) ``` will generate this 3D model -[Astronaut](./Astronaut.glb) +[Astronaut](./home/Astronaut.glb) ## From code This piece of code using as code language `yaml` and code meta-data : `glb` as follows -![Code](./code.png) +![Code](./home/code.png) will generate this 3D model with the provided files. * poster : allows fast page load, by loading the image only first. @@ -115,7 +115,7 @@ will generate this 3D model with the provided files. ```yaml glb src: Lantern.glb title: Lantern -poster: Lantern.webp +poster: home/Lantern.webp environment-image: spruit_sunrise_1k_HDR.hdr ``` @@ -164,11 +164,11 @@ A table with a high number of lines gets a [data-table](https://datatables.net/) It is also possible to create tables in xlsx format. This link of `.xlsx` extension ```markdown -[Table1](./Table1.xlsx) +[Table1](./home/Table1.xlsx) ``` will generate this data table -[Table1](./Table1.xlsx) +[Table1](./home/Table1.xlsx) # Notes A note can be created like this and can have markdown inside diff --git a/integrations/create_menu.js b/integrations/create_menu.js index ce1f5a2..1d4ba57 100644 --- a/integrations/create_menu.js +++ b/integrations/create_menu.js @@ -47,7 +47,11 @@ async function get_section_menu(section,raw_menu){ } async function create_raw_menu(content_path,document_list){ - const top_items = document_list.filter((item)=> item.level === 2).sort((a,b)=> a.order-b.order) + let top_items = document_list.filter((item)=> item.level === 2).sort((a,b)=> a.order-b.order) + const home_item = document_list.find((item)=> item.level === 1) + if(home_item){ + top_items = [home_item,...top_items] + } const sorted_items = top_items.map(entry => ({ label: entry.title, link: `/${entry.url}`, @@ -56,13 +60,12 @@ async function create_raw_menu(content_path,document_list){ } })); - const home_items = sorted_items.map(item => item.link === '/home' ? { ...item, link: '/' } : item); const icons_file = join(content_path,"icons.yaml") if(await exists(icons_file)){ const icons_list = await load_yaml_abs(icons_file) - home_items.push(...icons_list) + sorted_items.push(...icons_list) } - return home_items; + return sorted_items; } async function create_menu(collect_config){ @@ -84,7 +87,9 @@ async function create_menu(collect_config){ } for(const menu_entry of base_menu){ const section = section_from_pathname(menu_entry.link); - menu.sections[section] = await get_section_menu(section,base_menu) + if(section != "home"){ + menu.sections[section] = await get_section_menu(section,base_menu) + } } const menu_text = JSON.stringify(menu) diff --git a/packages/content-structure b/packages/content-structure index 7816e42..51fb912 160000 --- a/packages/content-structure +++ b/packages/content-structure @@ -1 +1 @@ -Subproject commit 7816e428069a31579746fe799a276abc43218753 +Subproject commit 51fb91207cce718b26cfb85f68f5d784aaf90aad diff --git a/src/pages/index.astro b/src/pages/index.astro index 7f4d10e..a7cfb30 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,14 +4,13 @@ import AstroMarkdown from '@/components/markdown/AstroMarkdown.astro' import {getEntry} from 'content-structure' console.log(`index> home page`) -const entry = await getEntry({path:"home/readme.md"}) -const not_empty = !(Object.keys(entry.tree).length == 0) - +let entry = await getEntry({url:""}) +let empty = (Object.keys(entry.tree).length == 0) const headings = (Object.hasOwn(entry.data,"toc")&&entry.data.toc == false)?[]:entry.data.headings --- - {not_empty&& + {!empty&& }