Skip to content

Commit 99e6145

Browse files
committed
Link directly to individual global enums/structs in documentation
Previously, we sent users to the top of the page whenever they click on a property that refers to a global enum/struct in our documentation. However the page is already filled with permalinks we can use, so I made it so we assume there's a permalink. If the permalink doesn't exist, it would just send them back to the top of the page anyway which was the previous status quo.
1 parent 5ba8206 commit 99e6145

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/common/src/components/SlintProperty.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ const typeInfo = getTypeInfo(typeName);
5757
if (typeInfo.href !== "") {
5858
const base = import.meta.env.BASE_URL;
5959
typeInfo.href = `${base}${typeInfo.href}`;
60+
61+
// For enums and structs, we can assume they have a permalink to their header on the target page.
62+
// (These permalinks are also always lower-case.)
63+
if (typeName == "enum") {
64+
typeInfo.href += "#" + enumName.toLowerCase();
65+
} else if (typeName == "struct") {
66+
typeInfo.href += "#" + structName.toLowerCase();
67+
}
6068
}
6169
const enumContent = await getEnumContent(enumName);
6270
const structContent = await getStructContent(structName);

0 commit comments

Comments
 (0)