diff --git a/tools/update_wiki_common_js.py b/tools/update_wiki_common_js.py new file mode 100644 index 0000000..714c2fe --- /dev/null +++ b/tools/update_wiki_common_js.py @@ -0,0 +1,59 @@ +import re +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +with open('common/js/wiki_common.js', 'r', encoding='utf-8') as f: + content = f.read() + +# 1. globalNav にギャザクラ追加 +if "'crafter_gatherer/index.html'" not in content: + # globalNav の置換 + target_gnav = "{ title: '🐎 マウント完全攻略', path: 'mounts/index.html' }," + replace_gnav = "{ title: '🐎 マウント完全攻略', path: 'mounts/index.html' },\n { title: '🔨 ギャザクラ完全攻略', path: 'crafter_gatherer/index.html' }," + if target_gnav in content: + content = content.replace(target_gnav, replace_gnav, 1) + print("Updated globalNav") + else: + print("target_gnav not found!") + + # 2. sidebar のメインメニューにギャザクラ追加 + target_sb_main = "{ text: '🐎 マウント総合・全一覧', path: 'mounts/index.html' }," + replace_sb_main = "{ text: '🐎 マウント総合・全一覧', path: 'mounts/index.html' },\n { text: '🔨 ギャザクラ総合攻略・育成', path: 'crafter_gatherer/index.html' }," + if target_sb_main in content: + content = content.replace(target_sb_main, replace_sb_main, 1) + print("Updated sidebar main menu") + else: + print("target_sb_main not found!") + + # 3. sidebar に専用セクション追加 + crafter_section = ''' { + type: 'links', + title: '🔨 ギャザラー&クラフター', + links: [ + { text: 'ギャザクラ総合トップ・入門', path: 'crafter_gatherer/index.html' }, + { text: '爆速レベル上げロードマップ', path: 'crafter_gatherer/leveling_roadmap.html' }, + { text: 'リーヴ&GC調達納品攻略', path: 'crafter_gatherer/leves_gc_supply.html' }, + { text: '復興・オーシャン・お得意様', path: 'crafter_gatherer/ishgard_ocean_custom.html' }, + { text: '製作・採集おすすめマクロ', path: 'crafter_gatherer/macros.html' }, + { text: '全ギルド・主要NPC座標一覧', path: 'crafter_gatherer/npc_locations.html' } + ] + }, +''' + target_section = "{\n type: 'links',\n title: '🎮 XHB・操作設計'," + if target_section in content: + content = content.replace(target_section, crafter_section + " " + target_section, 1) + print("Added crafter_gatherer section to sidebar") + else: + # 改行の違いに対応 + pattern = r"(\{\s*type:\s*'links',\s*title:\s*'🎮 XHB・操作設計',)" + if re.search(pattern, content): + content = re.sub(pattern, crafter_section + r"\1", content, count=1) + print("Added crafter_gatherer section to sidebar via regex") + else: + print("target_section not found!") + + with open('common/js/wiki_common.js', 'w', encoding='utf-8') as f: + f.write(content) +else: + print("crafter_gatherer already in common/js/wiki_common.js")