Skip to content

Commit

Permalink
updated from main branch and fixed wording & typos in the new dynamic…
Browse files Browse the repository at this point in the history
…-sounds page
  • Loading branch information
JR1811 committed Dec 28, 2024
2 parents 7373dfc + ad06683 commit 64b6045
Show file tree
Hide file tree
Showing 668 changed files with 16,000 additions and 3,224 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ concurrency:

jobs:
docs:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: ".nvmrc"
- run: npm i
- run: npm run build

mod:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '21'
distribution: "microsoft"
java-version: "21"
- run: ./gradlew build --stacktrace --warning-mode fail
working-directory: ./reference
- run: ./gradlew runDatagen --stacktrace --warning-mode fail
Expand All @@ -32,4 +32,4 @@ jobs:
if: ${{ failure() }}
with:
reports: |
reference/**/build/reports/checkstyle/*.xml
reference/**/build/reports/checkstyle/*.xml
10 changes: 5 additions & 5 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
branches:
- main
paths:
- '**/*.md'
- '!README.md'
- '!translated/**'
- '!versions/*/translated/**'
- "**/*.md"
- "!README.md"
- "!translated/**"
- "!versions/*/translated/**"
workflow_dispatch: # Manual run

concurrency:
Expand All @@ -17,7 +17,7 @@ concurrency:

jobs:
markdownlint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- id: checkout
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ permissions:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: ".nvmrc"
- run: npm i
- run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './.vitepress/dist'
path: "./.vitepress/dist"

deploy:
environment:
Expand All @@ -40,4 +40,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
70 changes: 61 additions & 9 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ config:
style: atx
MD004:
style: dash
MD007:
indent: 2
MD009:
br_spaces: 0
MD013: false
Expand All @@ -21,7 +19,6 @@ config:
MD033: false
MD035:
style: ---
MD044: false
MD046:
style: fenced
MD048:
Expand All @@ -44,11 +41,18 @@ config:
rules:
- name: missing-heading-anchor
message: "Add anchors to headings. Use lowercase characters, numbers and dashes"
searchPattern: "/^#+.*$(?<!\\{#[a-z0-9-]+\\})/gm"
information: https://vitepress.dev/guide/markdown#header-anchors
searchPattern: "/^#+ .*$(?<!\\{#[a-z0-9-]+\\})/gm"
searchScope: text
- name: missing-space-before-anchor
message: "Add a space before the heading's anchor."
information: https://vitepress.dev/guide/markdown#header-anchors
searchPattern: "/^(#+ .*)(?<! )(\\{#[a-z0-9-]+\\})$/gm"
replace: "$1 $2"
searchScope: text
- name: no-absolute-links
message: "Don't use absolute links"
searchPattern: "/\\[.*?\\]\\(/(?!assets|public|reference).*?\\)/g"
searchPattern: "/\\[[^\\]]*\\]\\(/(?!assets|public|reference)[^\\)]*\\)/g"
searchScope: text
- name: no-curly-quotes
message: "Don't use curly quotes"
Expand All @@ -57,17 +61,65 @@ config:
searchScope: text
- name: no-file-extension-in-links
message: "Don't add the file extension to links"
searchPattern: "/\\[(.*?)\\]\\((.*?)\\.(?:md|html)((?:#[a-z0-9-]+)?)\\)/g"
replace: "[$1]($2$3)"
information: https://vitepress.dev/guide/routing#linking-between-pages
searchPattern: "/(\\[[^\\]]*\\])\\(([^\\)]*)\\.(?:md|html)((?:#[a-z0-9-]+)?)\\)/g"
replace: "$1($2$3)"
searchScope: text
- name: no-github-flavored-alerts
message: "Don't use GitHub-favored Alerts"
information: https://vitepress.dev/guide/markdown#custom-containers
searchPattern:
- "/^> \\[!NOTE\\]/gm"
- "/^> \\[!TIP\\]/gm"
- "/^> \\[!IMPORTANT\\]/gm"
- "/^> \\[!WARNING\\]/gm"
- "/^> \\[!CAUTION\\]/gm"
replace:
- "::: info"
- "::: tip"
- "::: warning IMPORTANT"
- "::: warning"
- "::: danger"
searchScope: text
- name: no-images-in-text
message: "Don't place images in text"
searchPattern: "/(?:(?<!^)!\\[[^\\]]*\\]\\([^\\)]*\\).*$)|(?:^!\\[[^\\]]*\\]\\([^\\)]*\\)(?!$))/gm"
searchScope: text
- name: no-invalid-containers
message: "Don't use invalid containers"
information: https://vitepress.dev/guide/markdown#custom-containers
searchPattern: "/^::: (?!(?:info|tip|warning|danger|details|raw|code-group|v-pre)(?: |$))/gm"
replace: "::: info "
searchScope: text
- name: no-links-to-public
message: "Don't add /public to links"
information: https://vitepress.dev/guide/asset-handling#the-public-directory
searchPattern: "/(\\[[^\\]]*\\]\\()/public([^\\)]*\\))/g"
replace: "$1$2"
searchScope: text
- name: no-multiple-spaces
message: "Don't use multiple spaces"
searchPattern: "/(?<!\\n| ) +(?! |\\|)/g"
searchPattern: "/(?<!\\n|\\|| ) +(?! |\\|)/g"
replace: " "
searchScope: text
- name: no-nbsp
message: "Don't use no-break spaces"
searchPattern: "/\\xa0/gu"
replace: " "
searchScope: all
- name: no-padding-for-keybinds
message: "Don't put spaces around pluses in keybinds"
searchPattern: "/(<\\/kbd *>)(?:(?: +\\+ *)|(?:\\+ +))(<kbd[^>]*>)/g"
replace: "$1+$2"
searchScope: text
- name: no-punctuation-after-images
message: "Don't place punctuation after images"
searchPattern: "/^(!\\[[^\\]]*\\]\\([^\\)]*\\))[.,:;?!]+/gm"
replace: "$1"
searchScope: text
- name: no-punctuation-in-links
message: "Don't place punctuation inside of links"
searchPattern: "/(?<!@)\\[(.*?)([.,:;?!]+)\\]\\((.*?)\\)/g"
searchPattern: "/(?<!@)\\[([^\\]]*)([.,:;?!]+)\\]\\(([^\\)]*)\\)/g"
replace: "[$1]($3)$2"
searchScope: text
- name: no-trailing-whitespace
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v21.4.0
v22.8.0
26 changes: 14 additions & 12 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import snippetPlugin from "markdown-it-vuepress-code-snippet-enhanced";
import defineVersionedConfig from "vitepress-versioning-plugin";

import { getLocalisedSidebar, loadLocales, processExistingEntries } from "./i18n";
import { loadLocales, processExistingEntries } from "./i18n";
import { transformItems, transformPageData } from "./transform";
import { DefaultTheme } from "vitepress";
import { readdirSync } from "node:fs";
import { resolve } from "node:path";

// https://vitepress.dev/reference/site-config
// https://www.npmjs.com/package/vitepress-versioning-plugin
Expand All @@ -26,10 +23,15 @@ export default defineVersionedConfig(
config(md) {
md.use(snippetPlugin);
},
// TODO: load `mcfunction`
// - https://vitepress.dev/guide/markdown#syntax-highlighting-in-code-blocks
// - https://shiki.style/guide/load-lang
// - https://github.com/MinecraftCommands/syntax-mcfunction/blob/main/mcfunction.tmLanguage.json
languages: [
async () =>
await import("syntax-mcfunction/mcfunction.tmLanguage.json", {
with: { type: "json" },
}).then((lang) => ({ ...(lang.default as any), name: "mcfunction" })),
],
async shikiSetup(shiki) {
await shiki.loadTheme("github-light", "github-dark");
},
lineNumbers: true,
math: true,
},
Expand Down Expand Up @@ -59,10 +61,10 @@ export default defineVersionedConfig(
localePrefix: "translated",
},
sidebars: {
sidebarContentProcessor(sidebar: DefaultTheme.SidebarMulti) {
return processExistingEntries(sidebar);
},
}
sidebarContentProcessor: processExistingEntries,
sidebarUrlProcessor: (url: string, version: string) =>
url.startsWith("/") ? `/${version}${url}` : url,
},
},
},
__dirname
Expand Down
66 changes: 49 additions & 17 deletions .vitepress/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { existsSync, readdirSync, readFileSync } from "fs";
import { resolve } from "path/posix";
import { DefaultTheme, LocaleConfig } from "vitepress";
import { LocaleConfig } from "vitepress";
import { Versioned } from "vitepress-versioning-plugin";

import DevelopSidebar from "./sidebars/develop";
import PlayersSidebar from "./sidebars/players";
Expand Down Expand Up @@ -34,9 +35,13 @@ export const getWebsiteResolver = (localeFolder: string) =>
export const getSidebarResolver = (localeFolder: string) =>
getTranslationsResolver(localeFolder, "sidebar_translations.json");

export function processExistingEntries(sidebar: DefaultTheme.SidebarMulti): DefaultTheme.SidebarMulti {
export function processExistingEntries(
sidebar: Versioned.Sidebar
): Versioned.Sidebar {
// Get locales from __dirname/../translated/* folder names.
const localeFolders = readdirSync(resolve(__dirname, "..", "translated"), { withFileTypes: true })
const localeFolders = readdirSync(resolve(__dirname, "..", "translated"), {
withFileTypes: true,
})
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);

Expand All @@ -45,7 +50,11 @@ export function processExistingEntries(sidebar: DefaultTheme.SidebarMulti): Defa

const keys = Object.keys(sidebar);
const versionedEntries = keys.filter((key) => {
return !key.includes("/players") && !key.includes("/develop") && localeFolders.some((locale) => key.includes(locale));
return (
!key.includes("/players") &&
!key.includes("/develop") &&
localeFolders.some((locale) => key.includes(locale))
);
});

const versionsMet = new Set<string>();
Expand All @@ -57,21 +66,35 @@ export function processExistingEntries(sidebar: DefaultTheme.SidebarMulti): Defa

versionsMet.add(version);

const playersToCopy = JSON.parse(JSON.stringify(sidebar[`/${version}/players/`]));
const developToCopy = JSON.parse(JSON.stringify(sidebar[`/${version}/develop/`]));
const playersToCopy = JSON.parse(
JSON.stringify(sidebar[`/${version}/players/`])
);
const developToCopy = JSON.parse(
JSON.stringify(sidebar[`/${version}/develop/`])
);

sidebar[`/${locale}/${version}/players/`] = getLocalisedSidebar(playersToCopy, locale);
sidebar[`/${locale}/${version}/develop/`] = getLocalisedSidebar(developToCopy, locale);
sidebar[`/${locale}/${version}/players/`] = getLocalisedSidebar(
playersToCopy,
locale
);
sidebar[`/${locale}/${version}/develop/`] = getLocalisedSidebar(
developToCopy,
locale
);

// Delete the original entry.
delete sidebar[entry];
}

for (const version of versionsMet) {
// @ts-ignore
sidebar[`/${version}/players/`] = getLocalisedSidebar(sidebar[`/${version}/players/`], "root");
// @ts-ignore
sidebar[`/${version}/develop/`] = getLocalisedSidebar(sidebar[`/${version}/develop/`], "root");
sidebar[`/${version}/players/`] = getLocalisedSidebar(
sidebar[`/${version}/players/`] as Fabric.SidebarItem[],
"root"
);
sidebar[`/${version}/develop/`] = getLocalisedSidebar(
sidebar[`/${version}/develop/`] as Fabric.SidebarItem[],
"root"
);
}

return sidebar;
Expand Down Expand Up @@ -160,7 +183,6 @@ function generateTranslatedThemeConfig(localeCode: string): Fabric.ThemeConfig {
if (localeCode === "root") {
return null;
} else {
// @ts-ignore
return crowdinOverrides[localeCode] ?? localeCode.split("_")[0];
}
};
Expand All @@ -187,6 +209,10 @@ function generateTranslatedThemeConfig(localeCode: string): Fabric.ThemeConfig {
prev: websiteResolver("footer.prev"),
},

download: {
text: websiteResolver("download"),
},

editLink: {
pattern: "https://github.com/FabricMC/fabric-docs/edit/main/:path",
text: websiteResolver("github_edit"),
Expand Down Expand Up @@ -225,6 +251,9 @@ function generateTranslatedThemeConfig(localeCode: string): Fabric.ThemeConfig {
},
],
},
{
component: "VersionSwitcher",
},
],

notFound: {
Expand Down Expand Up @@ -304,9 +333,12 @@ function generateTranslatedThemeConfig(localeCode: string): Fabric.ThemeConfig {
},
],

versionSwitcher: {
text: websiteResolver("version_switcher"),
version: {
reminder: websiteResolver("version.reminder"),
switcher: websiteResolver("version.switcher"),
},

versionSwitcher: false,
};
}

Expand Down Expand Up @@ -357,8 +389,8 @@ export function loadLocales(dirname: string): LocaleConfig<Fabric.ThemeConfig> {
language === region.toLowerCase()
? localeNameInEnglish.of(language)!
: localeNameInEnglish.of(language)! +
" - " +
regionNameInEnglish.of(region);
" - " +
regionNameInEnglish.of(region);

const localisedName =
localeNameInLocale.of(language)![0].toUpperCase() +
Expand Down
Loading

0 comments on commit 64b6045

Please sign in to comment.