Skip to content

Commit 01bead0

Browse files
authored
feat: file icon for references, wrap at / (FabricMC#542)
1 parent dcbbbc1 commit 01bead0

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

.vitepress/theme/components/References.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { Icon } from "@iconify/vue";
23
import { useData } from "vitepress";
34
import VPLink from "vitepress/dist/client/theme-default/components/VPLink.vue";
45
import { computed } from "vue";
@@ -39,6 +40,9 @@ const getFileHref = (path: string) =>
3940
4041
const getFileTitle = (path: string) =>
4142
path.replace(/^@[/]reference[/][^/]+[/]/, "").replace("com/example/docs", "...");
43+
44+
const getFileExtension = (path: string) =>
45+
path.replace(/^.*[.]([^.]+)$/, "$1").replace(/^classtweaker$/, "document");
4246
</script>
4347

4448
<template>
@@ -49,8 +53,13 @@ const getFileTitle = (path: string) =>
4953
</VPLink>
5054

5155
<h2 v-if="files.length">{{ options.files }}</h2>
52-
<VPLink v-for="(f, i) in files" :key="f" :href="getFileHref(f)" :title="getFileTitle(f)">
53-
<code>{{ shortestUniquePaths[i] }}</code>
56+
<VPLink v-for="(f, i) in files" :key="f" :href="getFileHref(f)" :title="getFileTitle(f)" noIcon>
57+
<Icon :icon="`material-icon-theme:${getFileExtension(f)}`" />
58+
<code>
59+
<template v-for="(seg, j) in shortestUniquePaths[i].split('/')" :key="j">
60+
<template v-if="j !== 0">/<wbr /></template>{{ seg }}
61+
</template>
62+
</code>
5463
</VPLink>
5564

5665
<div />
@@ -80,14 +89,15 @@ h2 {
8089
color: var(--vp-c-text-2);
8190
}
8291
83-
.VPLink:has(code) {
84-
align-items: center;
85-
}
86-
8792
.VPLink:hover {
8893
color: var(--vp-c-text-1);
8994
}
9095
96+
svg {
97+
flex-shrink: 0;
98+
margin-top: 2px;
99+
}
100+
91101
img {
92102
margin-top: 1px;
93103
}

.vitepress/theme/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ pre {
6161
scrollbar-color: var(--vp-c-gray-1) var(--vp-c-bg-alt);
6262
}
6363

64+
@media (min-width: 1525px) {
65+
.aside-container {
66+
width: 300px !important;
67+
}
68+
}
69+
6470
.aside-container::-webkit-scrollbar {
6571
display: block;
6672
}

0 commit comments

Comments
 (0)