feat: add VALIDATE_LINKS env argument

This commit is contained in:
DuroCodes
2024-05-25 03:01:17 -04:00
parent b3b98676c4
commit 761579a09c
2 changed files with 13 additions and 6 deletions

4
.env.example Normal file
View File

@@ -0,0 +1,4 @@
# Set this to `true` to enable link validation, useful for development build to make sure all links are valid
# Broken since API routes generate links that are relative, so you can only validate links in development
# (You can ignore any errors that are generated by the API routes)
VALIDATE_LINKS=boolean

View File

@@ -4,8 +4,12 @@ import starlightBlog from "starlight-blog";
import tailwind from "@astrojs/tailwind";
import starlightTypeDoc, { typeDocSidebarGroup } from "starlight-typedoc";
import lunaria from "@lunariajs/starlight";
import { loadEnv } from "vite";
import { GITHUB_URL, DISCORD_URL } from "./src/utils/consts";
// import starlightLinksValidator from 'starlight-links-validator';
import starlightLinksValidator from 'starlight-links-validator';
const { VALIDATE_LINKS } = loadEnv(process.env.NODE_ENV, process.cwd(), "");
const validateLinks = VALIDATE_LINKS === "true";
export default defineConfig({
integrations: [
@@ -130,11 +134,10 @@ export default defineConfig({
sidebar: { collapsed: true },
}),
lunaria(),
// Uncomment to enable links validation when building locally; netlify crashes for API routes
// starlightLinksValidator({
// exclude: ['/plugins'],
// }),
],
validateLinks ? starlightLinksValidator({
exclude: ['/plugins'],
}) : null,
].filter(Boolean),
}),
tailwind(),
],