Compare commits
3 Commits
2e8261241f
...
cb1a30881d
Author | SHA1 | Date |
---|---|---|
|
cb1a30881d | |
|
8dc0d2cbaf | |
|
398318cae2 |
|
@ -6,6 +6,7 @@ import starlightUtils from "@lorenzo_lewis/starlight-utils";
|
||||||
import wasm from "vite-plugin-wasm";
|
import wasm from "vite-plugin-wasm";
|
||||||
|
|
||||||
import shikiConfig from "./src/utils/shiki";
|
import shikiConfig from "./src/utils/shiki";
|
||||||
|
import remarkVersionBadges from "./src/remark-plugins/version-badges";
|
||||||
|
|
||||||
const playgroundSidebarEntry = {
|
const playgroundSidebarEntry = {
|
||||||
label: 'Playground',
|
label: 'Playground',
|
||||||
|
@ -28,9 +29,9 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
favicon: '/favicon.ico',
|
favicon: '/favicon.ico',
|
||||||
description: 'A simple and powerful scripting language for Minecraft datapacks.',
|
description: 'A simple and powerful scripting language for Minecraft datapacks.',
|
||||||
social: {
|
social: [
|
||||||
email: 'mailto:shulkerscript@hoelting.dev',
|
{ icon: 'email', label: 'E-Mail', href: 'mailto:shulkerscript@hoelting.dev' },
|
||||||
},
|
],
|
||||||
tableOfContents: { minHeadingLevel: 1, maxHeadingLevel: 3 },
|
tableOfContents: { minHeadingLevel: 1, maxHeadingLevel: 3 },
|
||||||
defaultLocale: 'root',
|
defaultLocale: 'root',
|
||||||
locales: {
|
locales: {
|
||||||
|
@ -67,6 +68,9 @@ export default defineConfig({
|
||||||
Pagination: "./src/components/override/Pagination.astro",
|
Pagination: "./src/components/override/Pagination.astro",
|
||||||
SocialIcons: './src/components/override/SocialIcons.astro',
|
SocialIcons: './src/components/override/SocialIcons.astro',
|
||||||
},
|
},
|
||||||
|
customCss: [
|
||||||
|
'./src/remark-plugins/version-badges.css',
|
||||||
|
],
|
||||||
sidebar: [
|
sidebar: [
|
||||||
{
|
{
|
||||||
label: "leadingNavLinks",
|
label: "leadingNavLinks",
|
||||||
|
@ -131,5 +135,10 @@ export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
wasm(),
|
wasm(),
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
|
markdown: {
|
||||||
|
remarkPlugins: [
|
||||||
|
remarkVersionBadges,
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
52
package.json
52
package.json
|
@ -11,32 +11,36 @@
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/check": "^0.9.3",
|
"@astrojs/check": "^0.9.4",
|
||||||
"@astrojs/react": "^3.6.0",
|
"@astrojs/react": "^4.3.0",
|
||||||
"@astrojs/starlight": "^0.28.2",
|
"@astrojs/starlight": "^0.35.2",
|
||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.11.5",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@lorenzo_lewis/starlight-utils": "^0.1.1",
|
"@lorenzo_lewis/starlight-utils": "^0.3.2",
|
||||||
"@monaco-editor/react": "^4.6.0",
|
"@monaco-editor/react": "^4.7.0",
|
||||||
"@mui/icons-material": "^6.1.1",
|
"@mui/icons-material": "^7.3.0",
|
||||||
"@mui/material": "^6.1.1",
|
"@mui/material": "^7.3.0",
|
||||||
"@shikijs/monaco": "^1.7.0",
|
"@shikijs/monaco": "^3.9.2",
|
||||||
"@types/react": "^18.3.3",
|
"@types/mdast": "^4.0.4",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react": "^19.1.9",
|
||||||
"astro": "^4.15.9",
|
"@types/react-dom": "^19.1.7",
|
||||||
"react": "^18.3.1",
|
"@types/unist": "^3.0.3",
|
||||||
"react-dom": "^18.3.1",
|
"astro": "^5.12.8",
|
||||||
"react-icons": "^5.2.1",
|
"react": "^19.1.1",
|
||||||
"sharp": "^0.33.5",
|
"react-dom": "^19.1.1",
|
||||||
"shiki": "^1.7.0",
|
"react-icons": "^5.5.0",
|
||||||
"starlight-links-validator": "^0.12.1",
|
"sharp": "^0.34.3",
|
||||||
"tm-themes": "^1.4.3",
|
"shiki": "^3.9.2",
|
||||||
"typescript": "^5.4.5",
|
"starlight-links-validator": "^0.17.0",
|
||||||
"use-immer": "^0.10.0",
|
"tm-themes": "^1.10.7",
|
||||||
"vite-plugin-wasm": "^3.3.0"
|
"typescript": "^5.9.2",
|
||||||
|
"unified": "^11.0.5",
|
||||||
|
"unist-util-visit": "^5.0.0",
|
||||||
|
"use-immer": "^0.11.0",
|
||||||
|
"vite-plugin-wasm": "^3.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"sass": "^1.77.6"
|
"sass": "^1.90.0"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.7.0"
|
"packageManager": "pnpm@9.7.0"
|
||||||
}
|
}
|
||||||
|
|
5386
pnpm-lock.yaml
5386
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
<script defer>
|
||||||
|
const isLinux = /Linux/.test(window.navigator.platform) || ["Macintosh", "MacIntel", "MacPOC", "Mac68K"].indexOf(window.navigator.platform) !== -1;
|
||||||
|
if (isLinux) {
|
||||||
|
(async () => {
|
||||||
|
function waitForElements(selector) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (document.querySelectorAll(selector).length > 0) {
|
||||||
|
return resolve(document.querySelectorAll(selector));
|
||||||
|
}
|
||||||
|
|
||||||
|
const observer = new MutationObserver(mutations => {
|
||||||
|
if (document.querySelector(selector)) {
|
||||||
|
observer.disconnect();
|
||||||
|
resolve(document.querySelectorAll(selector));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
waitForElements("starlight-tabs a").then(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
document.querySelectorAll("starlight-tabs a").values().filter(el => el.innerText === "Linux / macOS").forEach(el => el.click());
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,7 +1,7 @@
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useMonaco, type Monaco } from "@monaco-editor/react";
|
import { useMonaco, type Monaco } from "@monaco-editor/react";
|
||||||
import { useImmer, type Updater } from "use-immer";
|
import { useImmer, type Updater } from "use-immer";
|
||||||
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
import { ThemeProvider } from "@mui/material/styles";
|
||||||
import ErrorDisplay from "./playground/ErrorDisplay";
|
import ErrorDisplay from "./playground/ErrorDisplay";
|
||||||
import FileView from "./playground/FileView";
|
import FileView from "./playground/FileView";
|
||||||
import Editor from "./playground/Editor";
|
import Editor from "./playground/Editor";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { File } from "@utils/playground";
|
import type { File } from "@utils/playground";
|
||||||
import MonacoEditor, { useMonaco } from "@monaco-editor/react";
|
import MonacoEditor, { useMonaco } from "@monaco-editor/react";
|
||||||
import { getHighlighter, type Highlighter } from "shiki";
|
import { createHighlighter, type Highlighter } from "shiki";
|
||||||
import { shikiToMonaco } from "@shikijs/monaco";
|
import { shikiToMonaco } from "@shikijs/monaco";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import darkPlus from "tm-themes/themes/dark-plus.json";
|
import darkPlus from "tm-themes/themes/dark-plus.json";
|
||||||
|
@ -24,7 +24,7 @@ export default function Editor({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (monaco) {
|
if (monaco) {
|
||||||
if (highlighter == null) {
|
if (highlighter == null) {
|
||||||
getHighlighter({
|
createHighlighter({
|
||||||
themes: [darkPlus as any, lightPlus],
|
themes: [darkPlus as any, lightPlus],
|
||||||
langs: ["toml", shulkerscriptGrammar, mcfunctionGrammar],
|
langs: ["toml", shulkerscriptGrammar, mcfunctionGrammar],
|
||||||
}).then((highlighter) => {
|
}).then((highlighter) => {
|
||||||
|
|
|
@ -3,10 +3,10 @@ title: Getting Started
|
||||||
description: Get started with Shulkerscript
|
description: Get started with Shulkerscript
|
||||||
---
|
---
|
||||||
import { Steps, FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
|
import { Steps, FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
|
||||||
|
import OsTabSwitcher from '../../../components/OsTabSwitcher.astro';
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
||||||
To get started with Shulkerscript, you need to install the Shulkerscript CLI.
|
To get started with Shulkerscript, you need to install the Shulkerscript CLI.
|
||||||
You can either [download](#download-from-github) the latest release from the GitHub releases page or [build it from source](#building-from-source).
|
You can either [download](#download-from-github) the latest release from the GitHub releases page or [build it from source](#building-from-source).
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ If you want to try out Shulkerscript without installing anything, you can use th
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Quickinstall script *(recommended)*
|
### Quickinstall script *(recommended)*
|
||||||
|
<OsTabSwitcher />
|
||||||
<Steps>
|
<Steps>
|
||||||
1. <Tabs>
|
1. <Tabs>
|
||||||
<TabItem label="Windows" icon="seti:windows">
|
<TabItem label="Windows" icon="seti:windows">
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
.version-badges {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin: 0.5em 0 !important;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-badges + p {
|
||||||
|
margin-top: 0.5rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-badges span {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
white-space: nowrap;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='light'] .version-badges .since-badge {
|
||||||
|
background-color: #e0f7fa;
|
||||||
|
color: #00796b;
|
||||||
|
border-color: #b2ebf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='light'] .version-badges .changed-badge {
|
||||||
|
background-color: #fff8e1;
|
||||||
|
color: #795548;
|
||||||
|
border-color: #ffe082;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='light'] .version-badges .deprecated-badge {
|
||||||
|
background-color: #ffebee;
|
||||||
|
color: #b71c1c;
|
||||||
|
border-color: #ffcdd2;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='dark'] .version-badges .since-badge {
|
||||||
|
background-color: #004d40;
|
||||||
|
color: #b2dfdb;
|
||||||
|
border-color: #00695c;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='dark'] .version-badges .changed-badge {
|
||||||
|
background-color: #3e2723;
|
||||||
|
color: #ffe0b2;
|
||||||
|
border-color: #6d5037;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme='dark'] .version-badges .deprecated-badge {
|
||||||
|
background-color: #4a0000;
|
||||||
|
color: #ffcdd2;
|
||||||
|
border-color: #b71c1c;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
import { visit } from 'unist-util-visit';
|
||||||
|
import type { Plugin } from 'unified';
|
||||||
|
import type { Parent } from 'unist';
|
||||||
|
import type { Paragraph } from 'mdast';
|
||||||
|
|
||||||
|
const INLINE_REGEX = /!(since|changed|deprecated)\[([^\]]+)\]/g;
|
||||||
|
|
||||||
|
const remarkVersionBadges: Plugin = () => {
|
||||||
|
return (tree) => {
|
||||||
|
visit(tree, 'paragraph', (node, index, parent) => {
|
||||||
|
const paragraph = node as Paragraph;
|
||||||
|
const parentNode = parent as Parent;
|
||||||
|
|
||||||
|
if (!paragraph.children || paragraph.children.length !== 1) return;
|
||||||
|
|
||||||
|
const child = paragraph.children[0];
|
||||||
|
if(child.type !== 'text') return;
|
||||||
|
|
||||||
|
const value = child.value;
|
||||||
|
|
||||||
|
const matches = [...value.matchAll(INLINE_REGEX)];
|
||||||
|
if(matches.length === 0) return;
|
||||||
|
|
||||||
|
const isOnlyBadges = matches.reduce((allMatched, match) => {
|
||||||
|
return allMatched && match[0] === value.slice(match.index!, match.index! + match[0].length)
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
if (!isOnlyBadges) return;
|
||||||
|
|
||||||
|
const badges: string[] = matches.map(([_, type, version]) => {
|
||||||
|
let label = '';
|
||||||
|
let className = '';
|
||||||
|
let title = '';
|
||||||
|
switch(type) {
|
||||||
|
case 'since':
|
||||||
|
label = `Since v${version}`;
|
||||||
|
className = 'since-badge';
|
||||||
|
title = `This feature was added in v${version}`;
|
||||||
|
break;
|
||||||
|
case 'changed':
|
||||||
|
label = `Changed in v${version}`;
|
||||||
|
className = 'changed-badge';
|
||||||
|
title = `This feature was changed in v${version}`;
|
||||||
|
break;
|
||||||
|
case 'deprecated':
|
||||||
|
label = `Deprecated since v${version}`;
|
||||||
|
className = 'deprecated-badge'
|
||||||
|
title = `This feature is deprecated since v${version}`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return `<span class="${className}" title="${title}">${label}</span>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const htmlNode = {
|
||||||
|
type: 'html',
|
||||||
|
value: `<div class="version-badges">${badges.join('')}</div>`,
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
parentNode.children.splice(index!, 1, htmlNode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default remarkVersionBadges;
|
Loading…
Reference in New Issue