diff --git a/.pages b/.pages new file mode 100644 index 0000000..e319e72 --- /dev/null +++ b/.pages @@ -0,0 +1,15 @@ +title: SA6ANW +nav: + - Start: index.md + - HF: hf.md + - VHF/UHF DMR: vhfuhfdmr.md + - Satellite: satellite.md + - Portabel: portable.md + - AREDN: aredn.md + - MESHTASTIC: meshtastic.md + - Midsomer Murders: midsomer.md + - Services: + - Home Lab: homelab.md + - Caddy: caddy.md + - sa6anw.se: sa6anwse.md + - Smokeping: smokeping.md \ No newline at end of file diff --git a/clean_language_blocks.py b/clean_language_blocks.py index 16d15c0..8eb1843 100644 --- a/clean_language_blocks.py +++ b/clean_language_blocks.py @@ -1,43 +1,4 @@ -import os -import re -import shutil -import yaml - -SOURCE_DIR = "docs" -ENGLISH_DIR = "docs/en" -MKDOCS_YML = "mkdocs.yml" - -# Kopiera alla filer från docs/ till docs_en/ -if os.path.exists(ENGLISH_DIR): - shutil.rmtree(ENGLISH_DIR) -shutil.copytree(SOURCE_DIR, ENGLISH_DIR) - -def clean_file(path, keep_lang): - with open(path, "r", encoding="utf-8") as f: - content = f.read() - - if keep_lang == "sv": - content = re.sub(r":::\s*en\n.*?\n:::", "", content, flags=re.DOTALL) - elif keep_lang == "en": - content = re.sub(r":::\s*sv\n.*?\n:::", "", content, flags=re.DOTALL) - - content = re.sub(r":::\s*(sv|en)", "", content) - content = re.sub(r":::", "", content) - - with open(path, "w", encoding="utf-8") as f: - f.write(content.strip() + "\n") - -# Rensa svenska versioner -for filename in os.listdir(SOURCE_DIR): - if filename.endswith(".md"): - clean_file(os.path.join(SOURCE_DIR, filename), keep_lang="sv") - -# Rensa engelska versioner -for filename in os.listdir(ENGLISH_DIR): - if filename.endswith(".md"): - clean_file(os.path.join(ENGLISH_DIR, filename), keep_lang="en") - -# Skapa .pages i docs/en/ baserat på nav i mkdocs.yml +# Skapa .pages i docs/ och docs/en/ baserat på nav i mkdocs.yml def extract_nav_from_mkdocs_yml(path): with open(path, "r", encoding="utf-8") as f: data = yaml.safe_load(f) @@ -46,8 +7,13 @@ def extract_nav_from_mkdocs_yml(path): "nav": data.get("nav", []) } -english_pages = extract_nav_from_mkdocs_yml(MKDOCS_YML) +# Hämta navigation från mkdocs.yml +pages = extract_nav_from_mkdocs_yml(MKDOCS_YML) -os.makedirs(os.path.join(ENGLISH_DIR), exist_ok=True) +# Skriv till svenska .pages +with open(os.path.join(SOURCE_DIR, ".pages"), "w", encoding="utf-8") as f: + yaml.dump(pages, f, allow_unicode=True) + +# Skriv till engelska .pages with open(os.path.join(ENGLISH_DIR, ".pages"), "w", encoding="utf-8") as f: - yaml.dump(english_pages, f, allow_unicode=True) + yaml.dump(pages, f, allow_unicode=True) diff --git a/mkdocs.yml b/mkdocs.yml index ed8ffc1..349d2e1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,19 +1,4 @@ site_name: SA6ANW -nav: - - Start: index.md - - HF: hf.md - - VHF/UHF DMR: vhfuhfdmr.md - - Satellite: satellite.md - - Portabel: portable.md - - AREDN: aredn.md - - MESHTASTIC: meshtastic.md - - Midsomer Murders: midsomer.md - - Services: - - Home Lab: homelab.md - - Caddy: caddy.md - - sa6anw.se: sa6anwse.md - - Smokeping: smokeping.md - theme: name: 'material' language: sv