Skip to content

Commit

Permalink
support top readme as home
Browse files Browse the repository at this point in the history
  • Loading branch information
wassfila committed May 27, 2024
1 parent eb6c781 commit ee10b73
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions content/examples/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Examples
order: 2
---
All examples are listed in this section
34 changes: 17 additions & 17 deletions content/home/readme.md → content/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
```

Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions integrations/create_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -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){
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/content-structure
7 changes: 3 additions & 4 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
<Layout title={entry.data.title} headings={headings} >
{not_empty&&
{!empty&&
<AstroMarkdown node={entry.tree} data={entry.data} />
}
</Layout>

0 comments on commit ee10b73

Please sign in to comment.