GitHub Action commited on
Commit
4ba78be
·
1 Parent(s): 811fb95

Sync from GitHub with Git LFS

Browse files
Files changed (1) hide show
  1. scripts/AI_friendly.py +14 -16
scripts/AI_friendly.py CHANGED
@@ -95,30 +95,28 @@ def generate_json_ld(content, front_matter, ftype, title, rel_path):
95
  ).replace("}}", f',\n "url": "{url}"\n}}', 1)
96
 
97
  def mirror_md_files():
98
- files = []
99
- for md_path in ROOT_DIR.rglob("*.md"):
100
- if not is_md_file(md_path):
101
  continue
102
 
103
- rel_path = md_path.relative_to(ROOT_DIR)
104
- target_path = STRUCTURED_DIR / rel_path
105
-
106
  target_path.parent.mkdir(parents=True, exist_ok=True)
107
 
108
- with open(md_path, "r", encoding="utf-8") as f:
109
  content = f.read()
110
 
111
- front_matter = parse_front_matter(content)
112
- ftype = determine_type(content, front_matter)
113
- title = front_matter.get("title", md_path.stem)
114
-
115
- json_ld = generate_json_ld(content, front_matter, ftype, title)
116
 
117
- with open(target_path, "w", encoding="utf-8") as f:
118
- f.write(json_ld + content)
119
 
120
- files.append(rel_path)
121
- return files
 
 
122
 
123
  def generate_index(files):
124
  index_lines = ["# ИИ-дружелюбные версии файлов\n"]
 
95
  ).replace("}}", f',\n "url": "{url}"\n}}', 1)
96
 
97
  def mirror_md_files():
98
+ for path in REPO_ROOT.rglob("*.md"):
99
+ # пропускаем structured_md и index.md
100
+ if "structured_md" in path.parts or path.name.lower() == "index.md":
101
  continue
102
 
103
+ rel_path = path.relative_to(REPO_ROOT)
104
+ target_path = STRUCTURED_MD / rel_path
 
105
  target_path.parent.mkdir(parents=True, exist_ok=True)
106
 
107
+ with path.open("r", encoding="utf-8") as f:
108
  content = f.read()
109
 
110
+ front_matter, clean_content = extract_front_matter(content)
111
+ ftype = detect_file_type(clean_content)
112
+ title = front_matter.get("title", path.stem)
 
 
113
 
114
+ json_ld = generate_json_ld(clean_content, front_matter, ftype, title, rel_path)
 
115
 
116
+ with target_path.open("w", encoding="utf-8") as f:
117
+ f.write(clean_content)
118
+ f.write("\n\n")
119
+ f.write(json_ld)
120
 
121
  def generate_index(files):
122
  index_lines = ["# ИИ-дружелюбные версии файлов\n"]