Skip to content

Commit f45beca

Browse files
committed
feat: add download links, add icon to index buttons
1 parent c8423a7 commit f45beca

File tree

15 files changed

+248
-11
lines changed

15 files changed

+248
-11
lines changed

docs/.vitepress/config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ const vitePressI18nOptions: VitePressI18nOptions = {
144144
link: '/intro'
145145
}, {
146146
component: 'VersionSwitcher'
147+
}, {
148+
component: 'DownloadCard'
147149
}
148150
]
149151
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<script setup lang="ts">
2+
// noinspection JSUnusedGlobalSymbols
3+
import {onMounted} from "vue";
4+
5+
const props = defineProps<{
6+
screenMenu?: boolean
7+
}>();
8+
9+
const modrinthUrl = "https://modrinth.com/plugin/commandapi";
10+
const spigotUrl = "https://www.spigotmc.org/resources/api-commandapi-1-16-5-1-21-4.62353/";
11+
const hangarUrl = "https://hangar.papermc.io/Skepter/CommandAPI";
12+
13+
onMounted(() => {
14+
document.querySelectorAll(".download-link").forEach((element) => {
15+
const a = element as HTMLLinkElement;
16+
a.onclick = function (){
17+
window.open(a.href, "_blank");
18+
return false;
19+
}
20+
});
21+
});
22+
23+
</script>
24+
25+
<template>
26+
<div class="container">
27+
<a class="hangar-link download-link" :href="hangarUrl"/>
28+
<a class="modrinth-link download-link" :href="modrinthUrl"/>
29+
<a class="spigot-link download-link" :href="spigotUrl"/>
30+
</div>
31+
</template>
32+
33+
<style scoped>
34+
.container {
35+
display: flex;
36+
flex-direction: row;
37+
justify-content: center;
38+
align-items: center;
39+
padding-left: 24px;
40+
padding-right: 24px;
41+
gap: 12px;
42+
}
43+
44+
.spigot-link {
45+
content: url("/images/index/spigot.png");
46+
}
47+
48+
.hangar-link {
49+
content: url("/images/index/hangar.svg");
50+
}
51+
52+
.modrinth-link {
53+
content: url("/images/index/modrinth-light.svg");
54+
}
55+
56+
.download-link {
57+
width: 24px;
58+
}
59+
60+
.dark {
61+
.modrinth-link {
62+
content: url("/images/index/modrinth-dark.svg");
63+
}
64+
}
65+
</style>

docs/.vitepress/theme/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'
1515
import VersionSwitcher from "./versioning/VersionSwitcher.vue";
1616
import TitleAnchor from "./anchor/TitleAnchor.vue";
1717
import NotFoundComponent from "./404/NotFoundComponent.vue";
18+
import DownloadCard from "./download/DownloadCard.vue";
1819

1920
// noinspection JSUnusedGlobalSymbols
2021
export default {
2122
extends: DefaultTheme,
2223
enhanceApp({app}) {
2324
provideTabsSharedState(app)
25+
app.component('DownloadCard', DownloadCard)
2426
app.component('VersionSwitcher', VersionSwitcher)
2527
app.component('PluginTabs', PluginTabs)
2628
app.component('PluginTabsTab', PluginTabsTab)
@@ -45,10 +47,12 @@ export default {
4547
const route = useRoute();
4648
onMounted(async () => {
4749
initZoom()
50+
injectIndexPageIcons()
4851
await nextTick(() => scrollToActiveSidebarItem())
4952
});
5053
watch(() => route.path, () => nextTick(() => {
5154
scrollToActiveSidebarItem()
55+
injectIndexPageIcons()
5256
initZoom()
5357
}));
5458
}
@@ -63,4 +67,16 @@ function scrollToActiveSidebarItem() {
6367
if (activeLink) {
6468
activeLink.scrollIntoView({behavior: 'smooth', block: 'center'})
6569
}
70+
}
71+
72+
function injectIndexPageIcons() {
73+
document.querySelectorAll("a.VPButton.medium").forEach((button) => {
74+
const a = button as HTMLLinkElement;
75+
const href = a.href;
76+
if (href.includes("CommandAPI/releases/latest")) {
77+
a.classList.add("index-download-button");
78+
} else if (href.includes("/intro")) {
79+
a.classList.add("index-docs-button");
80+
}
81+
})
6682
}

docs/.vitepress/theme/style/global.css

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ kbd:not(.DocSearch-Button-Key) {
3939
background-color: #eee !important;
4040
border-radius: 3px;
4141
border: 1px solid #b4b4b4;
42-
box-shadow:
43-
0 1px 1px rgba(0, 0, 0, 0.2),
44-
0 2px 0 0 rgba(255, 255, 255, 0.7) inset;
42+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2),
43+
0 2px 0 0 rgba(255, 255, 255, 0.7) inset;
4544
color: #333;
4645
display: inline-block;
4746
font-size: 0.85em;
@@ -59,16 +58,51 @@ kbd:not(.DocSearch-Button-Key) {
5958
display: none;
6059
}
6160

62-
.dark {
63-
.tip.custom-block > .danger.custom-block {
64-
background-color: #3e2129;
65-
}
66-
}
6761

6862
.tip.custom-block > .danger.custom-block {
6963
background-color: #fde4e8;
7064
}
7165

7266
.example-title-anchor > code {
7367
background-color: rgba(0, 0, 0, 0) !important;
68+
}
69+
70+
.index-download-button:before {
71+
display: block;
72+
float: left;
73+
width: 18px;
74+
height: 18px;
75+
padding-top: 4px;
76+
margin-left: -4px;
77+
margin-right: 6px;
78+
/*noinspection CssUnknownTarget*/
79+
content: url(/images/index/download-light.svg);
80+
}
81+
82+
.index-docs-button:before {
83+
display: block;
84+
float: left;
85+
width: 18px;
86+
height: 18px;
87+
padding-top: 5px;
88+
margin-left: -4px;
89+
margin-right: 6px;
90+
/*noinspection CssUnknownTarget*/
91+
content: url(/images/index/docs-light.svg);
92+
}
93+
94+
.dark {
95+
.tip.custom-block > .danger.custom-block {
96+
background-color: #3e2129;
97+
}
98+
99+
.index-download-button:before {
100+
/*noinspection CssUnknownTarget*/
101+
content: url(/images/index/download-dark.svg);
102+
}
103+
104+
.index-docs-button:before {
105+
/*noinspection CssUnknownTarget*/
106+
content: url(/images/index/docs-dark.svg);
107+
}
74108
}

docs/en/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ hero:
1010
text: Documentation
1111
link: /intro
1212
- theme: alt
13-
text: Download
13+
text: Latest Release
1414
link: https://github.com/CommandAPI/CommandAPI/releases/latest
1515

1616
features:
1717
- title: Safer commands with better arguments
1818
icon: 🔒
1919
details: Prevent players running invalid commands by picking from over 50 specialized arguments with built-in error checking, suggestions, tooltips, and permission checks.
2020
- title: Supports vanilla datapacks
21-
icon: { src: "images/commandblock.webp" }
21+
icon: { src: "images/index/commandblock.webp" }
2222
details: Let your command to be executed by the built-in <code>/execute</code> command, command blocks, and even datapack functions and tags.
2323
- title: Write code how <i>you</i> want to
24-
icon: { src: "images/kotlin.png" }
24+
icon: { src: "images/index/kotlin.png" }
2525
details: Want a Brigadier tree-like structure? Want to use Kotlin? Want an annotation-based command system? We've got you covered.
2626
---
2727

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)