-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some changes that work in document MD navigation
- Loading branch information
Showing
18 changed files
with
757 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,163 @@ | ||
import { signal, useSignal } from "@preact/signals"; | ||
import type { Signal } from "@preact/signals"; | ||
import * as C from "@std/fmt/colors"; | ||
import * as TOML from "@std/toml"; | ||
|
||
interface NavDocsEntry { | ||
title: string; | ||
category?: string; | ||
href: string; | ||
} | ||
|
||
interface DocMD { | ||
interface RouteDocMD { | ||
address: string; | ||
title: string; | ||
category?: string; | ||
href: string; | ||
file: string; | ||
} | ||
|
||
type DocsMD = Record<string, DocMD>; | ||
type RoutesDocsMD = Record<string, RouteDocMD>; | ||
|
||
const DOCS_MD: DocsMD = { | ||
"skanoteka-pobieracz": { | ||
address: "skanoteka-pobieracz", | ||
title: "skanoteka - pobieracz", | ||
href: "/docs/skanoteka-pobieracz", | ||
file: "docs/pl/skanoteka-pobieracz/index.md", | ||
}, | ||
"skanoteka-pobieracz/v0.0.2": { | ||
address: "skanoteka-pobieracz/v0.0.2", | ||
title: "skanoteka-pobieracz@0.0.x", | ||
href: "/docs/skanoteka-pobieracz/v0.0.2", | ||
file: "docs/pl/skanoteka-pobieracz/v0.0.2/index.md", | ||
}, | ||
"skanoteka-pobieracz/v0.0.2/instalacja": { | ||
address: "skanoteka-pobieracz/v0.0.2/instalacja", | ||
title: "skanoteka-pobieracz@0.0.x > instalacja", | ||
href: "/docs/skanoteka-pobieracz/v0.0.2/instalacja", | ||
file: "docs/pl/skanoteka-pobieracz/v0.0.2/instalacja.md", | ||
}, | ||
"skanoteka-pobieracz/v0.0.2/instrukcja": { | ||
address: "skanoteka-pobieracz/v0.0.2/instrukcja", | ||
title: "skanoteka-pobieracz@0.0.x > instrukcja", | ||
href: "/docs/skanoteka-pobieracz/v0.0.2/instrukcja", | ||
file: "docs/pl/skanoteka-pobieracz/v0.0.2/instrukcja.md", | ||
}, | ||
"skanoteka-pobieracz/v0.0.2/konfiguracja": { | ||
address: "skanoteka-pobieracz/v0.0.2/konfiguracja", | ||
title: "skanoteka-pobieracz@0.0.x > konfiguracja", | ||
href: "/docs/skanoteka-pobieracz/v0.0.2/konfiguracja", | ||
file: "docs/pl/skanoteka-pobieracz/v0.0.2/konfiguracja.md", | ||
}, | ||
"skanoteka-pobieracz/v0.0.2/nowe-zadanie": { | ||
address: "skanoteka-pobieracz/v0.0.2/nowe-zadanie", | ||
title: "skanoteka-pobieracz@0.0.x > nowe - zadanie", | ||
href: "/docs/skanoteka-pobieracz/v0.0.2/nowe-zadanie", | ||
file: "docs/pl/skanoteka-pobieracz/v0.0.2/nowe-zadanie.md", | ||
}, | ||
"skanoteka-pobieracz/v0.1.0": { | ||
address: "skanoteka-pobieracz/v0.1.0", | ||
title: "skanoteka-pobieracz@0.1.x", | ||
href: "/docs/skanoteka-pobieracz/v0.1.0", | ||
file: "docs/pl/skanoteka-pobieracz/v0.1.0/index.md", | ||
}, | ||
zanim_zaczniesz: { | ||
address: "zanim_zaczniesz", | ||
title: "zanim zaczniesz", | ||
href: "/docs/zanim_zaczniesz", | ||
file: "docs/pl/zanim_zaczniesz/index.md", | ||
}, | ||
"zanim_zaczniesz/srodowisko_deno": { | ||
address: "zanim_zaczniesz/srodowisko_deno", | ||
title: "srodowisko deno", | ||
href: "/docs/zanim_zaczniesz/srodowisko_deno", | ||
file: "docs/pl/zanim_zaczniesz/srodowisko_deno/index.md", | ||
}, | ||
"zanim_zaczniesz/srodowisko_deno/instalacja": { | ||
address: "zanim_zaczniesz/srodowisko_deno/instalacja", | ||
title: "instalacja", | ||
href: "/docs/zanim_zaczniesz/srodowisko_deno/instalacja", | ||
file: "docs/pl/zanim_zaczniesz/srodowisko_deno/instalacja.md", | ||
}, | ||
"zanim_zaczniesz/edytor_vscode": { | ||
address: "zanim_zaczniesz/edytor_vscode", | ||
title: "edytor vscode", | ||
href: "/docs/zanim_zaczniesz/edytor_vscode", | ||
file: "docs/pl/zanim_zaczniesz/edytor_vscode/index.md", | ||
}, | ||
"zanim_zaczniesz/edytor_vscode/instalacja": { | ||
address: "zanim_zaczniesz/edytor_vscode/instalacja", | ||
title: "instalacja", | ||
href: "/docs/zanim_zaczniesz/edytor_vscode/instalacja", | ||
file: "docs/pl/zanim_zaczniesz/edytor_vscode/instalacja.md", | ||
}, | ||
"zanim_zaczniesz/przegladarka": { | ||
address: "zanim_zaczniesz/przegladarka", | ||
title: "przegladarka", | ||
href: "/docs/zanim_zaczniesz/przegladarka", | ||
file: "docs/pl/zanim_zaczniesz/przegladarka/index.md", | ||
}, | ||
"zanim_zaczniesz/przegladarka/instalacja": { | ||
address: "zanim_zaczniesz/przegladarka/instalacja", | ||
title: "instalacja", | ||
href: "/docs/zanim_zaczniesz/przegladarka/instalacja", | ||
file: "docs/pl/zanim_zaczniesz/przegladarka/instalacja.md", | ||
}, | ||
"zanim_zaczniesz/terminal": { | ||
address: "zanim_zaczniesz/terminal", | ||
title: "terminal", | ||
href: "/docs/zanim_zaczniesz/terminal", | ||
file: "docs/pl/zanim_zaczniesz/terminal/index.md", | ||
}, | ||
"zanim_zaczniesz/terminal/instalacja": { | ||
address: "zanim_zaczniesz/terminal/instalacja", | ||
title: "instalacja", | ||
href: "/docs/zanim_zaczniesz/terminal/instalacja", | ||
file: "docs/pl/zanim_zaczniesz/terminal/instalacja.md", | ||
}, | ||
}; | ||
interface TreeDocsMD { | ||
path: string[]; | ||
name: string; | ||
show: Signal<boolean>; | ||
nest: TreeDocsMD[] | never[]; | ||
} | ||
|
||
const dirHREF: string = "/docs/"; | ||
const dirFILE: string = "docs/pl/"; | ||
const extFILE: [string, string] = ["/index.md", ".md"]; | ||
const v_0_0_x: string = "v0.0.2"; | ||
const v_0_1_x: string = "v0.1.0"; | ||
|
||
const DOCS_MD:TreeDocsMD[] = [ | ||
{ | ||
path: [`zanim_zaczniesz`], | ||
name: "Zanim zaczniesz!", | ||
show: signal(false), | ||
nest: [ | ||
{ | ||
path: [`zanim_zaczniesz`, `srodowisko_deno`], | ||
name: "Środowisko wykonawcze DeNo", | ||
show: signal(false), | ||
nest: [ | ||
{ | ||
path: [`zanim_zaczniesz`, `srodowisko_deno`,`instalacja`], | ||
name: "instalacja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
], | ||
}, | ||
{ | ||
path: [`zanim_zaczniesz`, `edytor_vscode`], | ||
name: "Rozbudowany edytor tekstu vsCODE", | ||
show: signal(false), | ||
nest: [ | ||
{ | ||
path: [`zanim_zaczniesz`, `edytor_vscode`,`instalacja`], | ||
name: "instalacja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
], | ||
}, | ||
{ | ||
path: [`zanim_zaczniesz`, `przegladarka`], | ||
name: "Przeglądarka internetowa", | ||
show: signal(false), | ||
nest: [ | ||
{ | ||
path: [`zanim_zaczniesz`, `przegladarka`,`instalacja`], | ||
name: "instalacja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
], | ||
}, | ||
{ | ||
path: [`zanim_zaczniesz`, `terminal`], | ||
name: "terminal", | ||
show: signal(false), | ||
nest: [ | ||
{ | ||
path: [`zanim_zaczniesz`, `terminal`,`instalacja`], | ||
name: "instalacja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
path: [`skanoteka-pobieracz`], | ||
name: "skanoteka - pobieracz", | ||
show: signal(true), | ||
nest: [ | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_0_x], | ||
name: "v0.0.x", | ||
show: signal(true), | ||
nest: [ | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_0_x,`instalacja`], | ||
name: "instalacja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_0_x,`instrukcja`], | ||
name: "instrukcja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_0_x,`konfiguracja`], | ||
name: "konfiguracja", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_0_x,`nowe-zadanie`], | ||
name: "nowe - zadanie", | ||
show: signal(false), | ||
nest: [ ] | ||
}, | ||
], | ||
}, | ||
{ | ||
path: [`skanoteka-pobieracz`, v_0_1_x], | ||
name: "v0.1.x", | ||
show: signal(false), | ||
nest: [ ], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const ROUTES_DOCS_MD: RoutesDocsMD = routesForDocsMD(DOCS_MD); | ||
|
||
function routesForDocsMD(docsMD:TreeDocsMD[]): RoutesDocsMD { | ||
const out = <RoutesDocsMD> {}; | ||
rekurencyjneCzytanieListyMD(docsMD); | ||
function rekurencyjneCzytanieListyMD(docsMD:TreeDocsMD[]) { | ||
for (const L of docsMD) { | ||
const outIntern = <RouteDocMD> {}; | ||
outIntern.address = L.path.join("/"); | ||
outIntern.title = L.name; | ||
outIntern.href = dirHREF + L.path.join("/"); | ||
outIntern.file = `${dirFILE}${L.path.join("/")}${(L.nest.length!==0) ? extFILE[0] : extFILE[1]}`; | ||
out[L.path.join("/")] = outIntern; | ||
if(L.nest.length>0){ | ||
rekurencyjneCzytanieListyMD(L.nest); | ||
} | ||
} | ||
} | ||
return out; | ||
} | ||
|
||
export default DOCS_MD; | ||
export type {DocMD, DocsMD, NavDocsEntry}; | ||
export { ROUTES_DOCS_MD, DOCS_MD, dirHREF }; | ||
export type {RouteDocMD, RoutesDocsMD, NavDocsEntry}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.