44from afterpython .const import CONTENT_TYPES , PLACEHOLDER_INDEX_MARKER
55
66
7- def _legacy_placeholder_content (content_type : str ) -> str :
8- return f"""---
9- title: ← { content_type .capitalize ()}
10- ---
11-
12- This is a placeholder index page. The actual { content_type } landing page is rendered by SvelteKit.
13- """
14-
15-
16- def _legacy_welcome_content (content_type : str ) -> str :
17- return f"""# Welcome to AfterPython
7+ def _placeholder_content (content_type : str ) -> str :
8+ """Current placeholder body. Marker is an HTML comment so it embeds invisibly;
9+ _is_afterpython_placeholder_index keys off it to tell our files apart from
10+ user-authored ones."""
11+ return f"""{ PLACEHOLDER_INDEX_MARKER }
12+ # Welcome to AfterPython
1813
1914Welcome to your project's { content_type } ! This is a starter page to help you get started.
2015
@@ -35,6 +30,19 @@ def _legacy_welcome_content(content_type: str) -> str:
3530"""
3631
3732
33+ def _legacy_placeholder_content (content_type : str ) -> str :
34+ """Frozen fingerprint of the arrow-stub placeholder written between commits
35+ 49f30c1 and 3a560e2 (no marker). Kept solely so projects built in that window
36+ are still recognized as ours and cleaned up rather than blocking with the
37+ 'reserved' error. Do not edit — that would break recognition."""
38+ return f"""---
39+ title: ← { content_type .capitalize ()}
40+ ---
41+
42+ This is a placeholder index page. The actual { content_type } landing page is rendered by SvelteKit.
43+ """
44+
45+
3846def _is_afterpython_placeholder_index (index_md , content_type : str ) -> bool :
3947 """Return True only for non-doc index.md files generated by AfterPython."""
4048 content = index_md .read_text (encoding = "utf-8" , errors = "ignore" )
@@ -43,7 +51,6 @@ def _is_afterpython_placeholder_index(index_md, content_type: str) -> bool:
4351 return (
4452 PLACEHOLDER_INDEX_MARKER in content
4553 or normalized_content == _legacy_placeholder_content (content_type ).strip ()
46- or normalized_content == _legacy_welcome_content (content_type ).strip ()
4754 )
4855
4956
@@ -76,25 +83,15 @@ def create_placeholder_index_md_files():
7683 )
7784 continue
7885
79- content_path = ap .paths .afterpython_path / content_type
80- myst_yml_path = content_path / "myst.yml"
81-
82- # Prepend index.md to TOC in myst.yml
83- if myst_yml_path .exists ():
84- # Create placeholder index.md file
85- _write_index_file (content_type )
86- myst_data = read_yaml (myst_yml_path ) or {}
87- toc = myst_data .get ("project" , {}).get ("toc" , [])
86+ _write_index_file (content_type )
8887
89- # Check if index.md is already first in TOC
90- if not toc or toc [0 ].get ("file" ) != "index.md" :
91- # Prepend index.md to TOC in myst.yml
92- new_toc = [{"file" : "index.md" }, * toc ]
93- if "project" not in myst_data :
94- myst_data ["project" ] = {}
95- myst_data ["project" ]["toc" ] = new_toc
96- write_yaml (myst_yml_path , myst_data )
97- click .echo (f"Added index.md to TOC in { myst_yml_path } " )
88+ # Prepend index.md to TOC in myst.yml (skip if already first).
89+ myst_data = read_yaml (myst_yml_path ) or {}
90+ toc = myst_data .get ("project" , {}).get ("toc" , [])
91+ if not toc or toc [0 ].get ("file" ) != "index.md" :
92+ myst_data .setdefault ("project" , {})["toc" ] = [{"file" : "index.md" }, * toc ]
93+ write_yaml (myst_yml_path , myst_data )
94+ click .echo (f"Added index.md to TOC in { myst_yml_path } " )
9895
9996
10097def delete_placeholder_index_md_files ():
0 commit comments