Skip to content

Commit

Permalink
No index and sidebar links for deprecated bricks
Browse files Browse the repository at this point in the history
  • Loading branch information
weareoutman committed Aug 5, 2024
1 parent b781e4f commit ee3b413
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 13 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for (const dir of readdirSync(bricksDir, { withFileTypes: true })) {
}

bootstrapJson.settings.misc.local_editors = bootstrapJson.brickPackages.flatMap(
(pkg) => (pkg.id ? pkg.editors ?? [] : pkg.propertyEditors ?? [])
(pkg) => (pkg.id ? (pkg.editors ?? []) : (pkg.propertyEditors ?? []))
);

const bootstrapJsonContent = JSON.stringify(bootstrapJson);
Expand Down Expand Up @@ -129,6 +129,18 @@ const config = {
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
// editUrl: "https://github.com/easyops-cn/next-docs/tree/master/",
// Ignore deprecated bricks
async sidebarItemsGenerator({
defaultSidebarItemsGenerator,
docs,
...args
}) {
const sidebarItems = await defaultSidebarItemsGenerator({
...args,
docs: docs.filter((doc) => !doc.frontMatter.deprecated),
});
return sidebarItems;
},
},
blog: false,
theme: {
Expand Down
11 changes: 8 additions & 3 deletions scripts/pre-build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ for (const { path: pkgPath, manifest, types } of packages) {
brickDoc = brick.description ?? "";
}
const typeRefs = brick.types?.map((item) => item.name);
const deprecated = brick.deprecated ?? false;

const content =
`---
description: ${JSON.stringify(`<${brick.name}>`)}
description: ${JSON.stringify(`<${brick.name}>`)}${
deprecated ? `\ndeprecated: true` : ""
}
---
${deprecated ? `\n<head>
<meta name="robots" content="noindex, nofollow" />
</head>\n` : ""}
import BrickTagName from "@site/src/components/BrickTagName";
import BrickDocProperties from "@site/src/components/BrickDocProperties";
import BrickDocSlots from "@site/src/components/BrickDocSlots";
Expand All @@ -77,7 +82,7 @@ import { TypeReferencesContext } from "@site/src/components/GeneralType";
name={${JSON.stringify(brick.name)}}
alias={${JSON.stringify(brick.alias ?? null)}}
insider={${JSON.stringify(brick.insider ?? false)}}
deprecated={${JSON.stringify(brick.deprecated ?? false)}}
deprecated={${JSON.stringify(deprecated)}}
/>
${brickDoc}
Expand Down

0 comments on commit ee3b413

Please sign in to comment.