Skip to content

Commit

Permalink
404 page, localisation improvements (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
its-miroma authored Jul 2, 2024
1 parent 1876258 commit 4ace231
Show file tree
Hide file tree
Showing 252 changed files with 2,843 additions and 2,025 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
.vitepress/sidebars/ @FabricMC/documentation
package-lock.json @FabricMC/developers
package.json @FabricMC/developers
LICENSE.md @FabricMC/developers
LICENSE @FabricMC/developers
4 changes: 1 addition & 3 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Run markdownlint
name: Lint

on:
pull_request:
branches:
- main
paths:
- '**/*.md'
- '!LICENSE.md'
- '!README.md'
- '!translated/**'
- '!versions/*/translated/**'
Expand Down Expand Up @@ -38,7 +37,6 @@ jobs:
config: .markdownlint-cli2.yaml
globs: |
**/*.md
!LICENSE.md
!README.md
!**/node_modules
!**/.git
Expand Down
45 changes: 41 additions & 4 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,49 @@ config:
style: asterisk
MD053: false
MD054:
# these link styles are not easily localizable
collapsed: false # A link to [keyword][].
shortcut: false # A link to [keyword].
# [keyword]: <https://example.com>
# A link to [keyword][].
collapsed: false
# A link to [keyword].
# [keyword]: <https://docs.fabricmc.net/>
shortcut: false
url_inline: false
MD055:
style: leading_and_trailing
search-replace:
rules:
- name: missing-heading-anchor
message: "Add anchors to headings. Use lowercase characters, numbers and dashes"
searchPattern: "/^#+.*$(?<!\\{#[a-z0-9-]+\\})/gm"
searchScope: text
- name: no-absolute-links
message: "Don't use absolute links"
searchPattern: "/\\[.*?\\]\\(/(?!assets|public|reference).*?\\)/g"
searchScope: text
- name: no-curly-quotes
message: "Don't use curly quotes"
search: [“, ”, ‘, ’]
replace: ['"', '"', "'", "'"]
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)"
searchScope: text
- name: no-multiple-spaces
message: "Don't use multiple spaces"
searchPattern: "/(?<!\\n| ) +(?! |\\|)/g"
replace: " "
searchScope: text
- name: no-punctuation-in-links
message: "Don't place punctuation inside of links"
searchPattern: "/(?<!@)\\[(.*?)([.,:;?!]+)\\]\\((.*?)\\)/g"
replace: "[$1]($3)$2"
searchScope: text
- name: no-trailing-whitespace
message: "Don't use trailing whitespace"
searchPattern: "/ +$/gm"
replace: ""
searchScope: code
customRules:
- ./node_modules/markdownlint-rule-search-replace/rule.js
- ./node_modules/markdownlint-rule-titlecase/rule.js
95 changes: 45 additions & 50 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,66 +1,61 @@
import { PageData, TransformPageContext } from 'vitepress'
import snippetPlugin from "markdown-it-vuepress-code-snippet-enhanced";
import defineVersionedConfig from "vitepress-versioning-plugin";

import snippetPlugin from 'markdown-it-vuepress-code-snippet-enhanced'
import defineVersionedConfig, { VersionedConfig } from 'vitepress-versioning-plugin'

import { loadLocales } from './i18n'
import { applySEO, removeVersionedItems } from './seo'
import { loadLocales } from "./i18n";
import { transformItems, transformPageData } from "./transform";

// https://vitepress.dev/reference/site-config
// https://www.npmjs.com/package/vitepress-versioning-plugin
export default defineVersionedConfig(__dirname, {
versioning: {
latestVersion: '1.20.4',
rewrites: {
localePrefix: 'translated'
}
},
export default defineVersionedConfig(
{
cleanUrls: true,

rewrites: {
'translated/:lang/(.*)': ':lang/(.*)'
},
head: [["link", { rel: "icon", sizes: "32x32", href: "/favicon.png" }]],

title: "Fabric Documentation",
description: "Comprehensive documentation for Fabric, the Minecraft modding toolchain.",
cleanUrls: true,
// Prevent dead links from being reported as errors - allows partially translated pages to be built.
ignoreDeadLinks: true,

head: [[
'link',
{ rel: 'icon', sizes: '32x32', href: '/favicon.png' },
]],
lastUpdated: true,

locales: loadLocales(__dirname),
locales: loadLocales(__dirname),

// Prevent dead links from being reported as errors - allows partially translated pages to be built.
ignoreDeadLinks: true,
markdown: {
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
lineNumbers: true,
math: true,
},

srcExclude: [
"README.md",
"LICENSE.md",
],
rewrites: {
"translated/:lang/(.*)": ":lang/(.*)",
},

transformPageData(pageData: PageData, _ctx: TransformPageContext) {
applySEO(pageData);
},
sitemap: {
hostname: "https://docs.fabricmc.net/",
transformItems,
},

sitemap: {
hostname: "https://docs.fabricmc.net/",
transformItems: items => removeVersionedItems(items)
},
srcExclude: ["README.md"],

lastUpdated: true,
themeConfig: {
search: {
provider: "local",
},
},

transformPageData,

themeConfig: {
search: {
provider: 'local'
versioning: {
latestVersion: "1.20.4",
rewrites: {
localePrefix: "translated",
},
},
},

markdown: {
lineNumbers: true,
math: true,
config(md) {
md.use(snippetPlugin);
}
}
} as VersionedConfig)
__dirname
);
Loading

0 comments on commit 4ace231

Please sign in to comment.