SilasBerger / teaching-website

My teaching website 👨‍🏫
https://teach.silasberger.ch
1 stars 0 forks source link

Unexpected sync behavior with marked file in renamed section #11

Closed SilasBerger closed 8 months ago

SilasBerger commented 8 months ago

Works:

  "creative-corner": {
    "markers": {
      "cc": 1
    },
    "mappings": [
      {"section": "index.md", "material": "/ScriptLandingPages/creative-corner.md"},
      {
        "section": "/Components-Gallery",
        "material": "/Components-Gallery"
      }
    ]
  }

Does not work properly; uses both index.mdx and index.[cc].mdx and creates directories 01-Komponentengalerie and Components-Gallery:

  "creative-corner": {
    "markers": {
      "cc": 1
    },
    "mappings": [
      {"section": "index.md", "material": "/ScriptLandingPages/creative-corner.md"},
      {
        "section": "/01-Komponentengalerie",
        "material": "/Components-Gallery"
      }
    ]
  }
SilasBerger commented 8 months ago

Likely root cause: applyMarkers does not know that the target directory has been renamed to 01-Komponentengalerie by the previous mapping.

// sync-tree-processing.ts@53-55
const canonicalPathSegments = _splitPathSegments(markedNode.treePath)
    .map(segment => canonicalNameFrom(segment));
const destNode = destTree.ensureNode(canonicalPathSegments);

markedNode.treePath will receive /Components-Gallery/index.[cc].md and thus ensure a dest node /Components-Gallery/index.md, rather than 01-Komponentengalerie/index.md.