feat: group private apps into andreknie-privat
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Stub page creation for entities that don't yet have a NoteGraph page.
|
||||
|
||||
Creates minimal markdown pages in the appropriate directory (people/ or projects/)
|
||||
so that wiki-links resolve immediately after import.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from slugify import slugify
|
||||
|
||||
from ingestion.enrichment.models import Entity
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def create_stub_pages(entities: list[Entity], notes_dir: Path) -> list[Path]:
|
||||
"""Create stub pages for entities that don't have existing pages.
|
||||
|
||||
Args:
|
||||
entities: List of entities to check/create stubs for.
|
||||
notes_dir: Root notes directory (e.g., ./notes).
|
||||
|
||||
Returns:
|
||||
List of paths to newly created stub pages.
|
||||
"""
|
||||
notes_dir = Path(notes_dir)
|
||||
created: list[Path] = []
|
||||
|
||||
linkable = [e for e in entities if e.type in ("person", "project")]
|
||||
seen_slugs: set[str] = set()
|
||||
|
||||
for entity in linkable:
|
||||
slug = slugify(entity.value)
|
||||
if slug in seen_slugs:
|
||||
continue
|
||||
seen_slugs.add(slug)
|
||||
|
||||
if entity.type == "person":
|
||||
target = notes_dir / "people" / f"{slug}.md"
|
||||
elif entity.type == "project":
|
||||
target = notes_dir / "projects" / f"{slug}.md"
|
||||
else:
|
||||
continue
|
||||
|
||||
if target.exists():
|
||||
logger.debug("Page already exists: %s", target)
|
||||
continue
|
||||
|
||||
# Create stub page
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(f"# {entity.value}\n", encoding="utf-8")
|
||||
logger.info("Created stub page: %s", target)
|
||||
created.append(target)
|
||||
|
||||
return created
|
||||
Reference in New Issue
Block a user