Skip to content

Commit 7081ec0

Browse files
fsecada01claude
andcommitted
fix(docs): fix JS URL detection, root index links, and lint
- frame.html.jinja2: replace pathParts.indexOf("component_framework") with pathParts.indexOf("component-framework") (the repo name). The old approach returned -1 on component_framework.html (filename, not directory), wrongly treating all root package pages as local dev and breaking Home/Example nav links. New approach finds the repo segment → version is always pathParts[repoIdx+1]. - update_gh_pages.py: split single long Google Fonts <link> (139 chars) into two <link> tags to satisfy ruff E501 (100-char limit). - update_gh_pages.py: change root version index hrefs from component_framework.html to index.html so clicking a version lands on the home page, not the raw API docs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 65b35e3 commit 7081ec0

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

docs/pdoc_templates/frame.html.jinja2

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,16 @@ main#content { background: var(--cfx-bg); }
521521
"use strict";
522522
523523
var pathParts = window.location.pathname.split("/");
524-
var pkgIdx = pathParts.indexOf("component_framework");
525-
var isLocal = pkgIdx < 2;
526-
var repoSegment = isLocal ? "" : pathParts[1];
527-
var currentVersion = isLocal ? "local" : pathParts[pkgIdx - 1];
528-
var afterPkg = pathParts.slice(pkgIdx).join("/");
524+
var REPO = "component-framework";
525+
var repoIdx = pathParts.indexOf(REPO);
526+
var isLocal = repoIdx < 0;
527+
var repoSegment = REPO;
528+
var currentVersion = isLocal ? "local" : (pathParts[repoIdx + 1] || "main");
529+
// Path within the version dir — used by version switcher to keep the same page.
530+
// Falls back to component_framework.html (the package root) when at the version root.
531+
var afterPkg = isLocal
532+
? "component_framework.html"
533+
: (pathParts.slice(repoIdx + 2).join("/") || "component_framework.html");
529534
530535
/* ── Compute base URLs ─────────────────────────────────────────────────── */
531536
var baseUrl = isLocal

docs/update_gh_pages.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ def write_versions_json(
8888
<title>component-framework — Documentation</title>
8989
<link rel="preconnect" href="https://fonts.googleapis.com">
9090
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
91-
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Inter:wght@400;500&display=swap" rel="stylesheet">
91+
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
92+
rel="stylesheet">
93+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap"
94+
rel="stylesheet">
9295
<style>
9396
:root {{
9497
--bg: #0c1117;
@@ -237,7 +240,7 @@ def write_root_index(
237240
if has_main:
238241
items.append(
239242
_LI_TEMPLATE.format(
240-
href="main/component_framework.html",
243+
href="main/index.html",
241244
label="main",
242245
tag_class="tag-dev",
243246
tag_text="dev",
@@ -247,7 +250,7 @@ def write_root_index(
247250
if latest:
248251
items.append(
249252
_LI_TEMPLATE.format(
250-
href="latest/component_framework.html",
253+
href="latest/index.html",
251254
label=f"latest ({latest})",
252255
tag_class="tag-latest",
253256
tag_text="stable",
@@ -259,7 +262,7 @@ def write_root_index(
259262
tag_text = "latest" if version == latest else "release"
260263
items.append(
261264
_LI_TEMPLATE.format(
262-
href=f"{version}/component_framework.html",
265+
href=f"{version}/index.html",
263266
label=version,
264267
tag_class=tag_class,
265268
tag_text=tag_text,

0 commit comments

Comments
 (0)