Skip to content

Commit

Permalink
refactor: Add fundament to restructure pages (#179)
Browse files Browse the repository at this point in the history
* Implement plugin to log get json of all routes in postBuild lifecycle. Add file in sc so it creates diff to help check.
* Create new sidebar for release and link from there.
* Add redirects for CF and plugin to add them to build.
* Refactore sidebar to be more granular
* Extract postbuild scripts in separate file.

---------

Signed-off-by: Mirjam Aulbach <[email protected]>
  • Loading branch information
programmiri authored Feb 1, 2024
1 parent 2270915 commit 87cc540
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 18 deletions.
5 changes: 5 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/docs/category/Releases/* /docs/releases/:splat 301
/docs/category/Releases /docs/releases 301

/docs/category/concepts /docs/Concepts/clusters-environments 301
/docs/category/howto /docs/HowTo/analytics 301
141 changes: 141 additions & 0 deletions current-routes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
[
"/404.html",
"/__docusaurus/debug",
"/__docusaurus/debug/config",
"/__docusaurus/debug/content",
"/__docusaurus/debug/globalData",
"/__docusaurus/debug/metadata",
"/__docusaurus/debug/registry",
"/__docusaurus/debug/routes",
"/blog",
"/blog/archive",
"/blog/Effortless-Kafka-Governance-making-Life-Easier-for-Developers",
"/blog/high-availability-for-klaw",
"/blog/important-community-update-klaws-latest-actions-to-enhance-transparency",
"/blog/schema-management-disaster-recovery-in-klaw",
"/blog/tags",
"/blog/tags/2-5-2",
"/blog/tags/2-6-1",
"/blog/tags/acls",
"/blog/tags/active",
"/blog/tags/disaster-recovery",
"/blog/tags/evolution",
"/blog/tags/fault-tolerance",
"/blog/tags/governance",
"/blog/tags/high-availability",
"/blog/tags/kafka",
"/blog/tags/klaw",
"/blog/tags/migration",
"/blog/tags/passive",
"/blog/tags/schema-registry",
"/blog/tags/topics",
"/blog/tags/transparency",
"/docs/",
"/docs/Concepts/clusters-environments",
"/docs/Concepts/config",
"/docs/Concepts/high-availability",
"/docs/Concepts/metastore",
"/docs/Concepts/promotion",
"/docs/Concepts/switch-teams",
"/docs/Concepts/synchronize",
"/docs/Concepts/users-teams",
"/docs/Concepts/workflows",
"/docs/faq",
"/docs/features",
"/docs/getstarted",
"/docs/HowTo/analytics",
"/docs/HowTo/authentication/",
"/docs/HowTo/authentication/azure-ad",
"/docs/HowTo/authentication/google-account",
"/docs/HowTo/authentication/third-party-account",
"/docs/HowTo/authentication/userpwd-db",
"/docs/HowTo/authentication/windows-ad",
"/docs/HowTo/authorization",
"/docs/HowTo/clusterconnectivity/",
"/docs/HowTo/clusterconnectivity/aiven-kafka-cluster-sasl-ssl-protocol",
"/docs/HowTo/clusterconnectivity/aiven-kafka-cluster-ssl-protocol",
"/docs/HowTo/clusterconnectivity/aiven-kafka-connect-cluster-ssl-protocol",
"/docs/HowTo/clusterconnectivity/aiven-karapace-cluster-ssl-protocol",
"/docs/HowTo/clusterconnectivity/confluent-cloud-kafka-cluster-ssl-protocol",
"/docs/HowTo/clusterconnectivity/kafka-cluster-sasl-ssl-protocol",
"/docs/HowTo/clusterconnectivity/kafka-cluster-ssl-protocol",
"/docs/HowTo/clusterconnectivity/klaw-core-with-clusterapi",
"/docs/HowTo/clusterconnectivity/klaw-db-connection",
"/docs/HowTo/clusterconnectivity/sr-cluster-ssl-protocol",
"/docs/HowTo/clusters",
"/docs/HowTo/connectors/",
"/docs/HowTo/connectors/Approve-a-connector",
"/docs/HowTo/connectors/manage-connectors",
"/docs/HowTo/connectors/My-connector-requests",
"/docs/HowTo/connectors/Request-a-new-connector",
"/docs/HowTo/dashboard",
"/docs/HowTo/deployklaw",
"/docs/HowTo/environments",
"/docs/HowTo/exportimport/",
"/docs/HowTo/exportimport/exportdata",
"/docs/HowTo/exportimport/importdata",
"/docs/HowTo/installation/",
"/docs/HowTo/installation/configure-klaw-wizard",
"/docs/HowTo/installation/run-docker",
"/docs/HowTo/installation/run-source",
"/docs/HowTo/kafka-cluster-migration/",
"/docs/HowTo/kafka-cluster-migration/sync-acls-from-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-acls-to-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-connectors-from-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-schemas-from-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-schemas-to-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-topics-from-cluster",
"/docs/HowTo/kafka-cluster-migration/sync-topics-to-cluster",
"/docs/HowTo/kafka-cluster-migration/tenant-config",
"/docs/HowTo/notifications/",
"/docs/HowTo/notifications/email-notification",
"/docs/HowTo/notifications/slack-notification",
"/docs/HowTo/operational/",
"/docs/HowTo/operational/Reset-Consumer-Offsets",
"/docs/HowTo/rolespermissions",
"/docs/HowTo/schemas/",
"/docs/HowTo/schemas/manage-schemas",
"/docs/HowTo/schemas/My-schema-requests",
"/docs/HowTo/schemas/Promote-a-schema",
"/docs/HowTo/schemas/Request-a-schema",
"/docs/HowTo/settings",
"/docs/HowTo/subscriptions/",
"/docs/HowTo/subscriptions/Approve-a-subscription",
"/docs/HowTo/subscriptions/Delete-a-subscription",
"/docs/HowTo/subscriptions/My-subscription-requests",
"/docs/HowTo/subscriptions/Request-a-subscription",
"/docs/HowTo/teams/",
"/docs/HowTo/teams/manage-teams",
"/docs/HowTo/teams/switch-teams",
"/docs/HowTo/tenant",
"/docs/HowTo/topics/",
"/docs/HowTo/topics/Approve-a-topic",
"/docs/HowTo/topics/Claim-a-topic",
"/docs/HowTo/topics/Delete-a-topic",
"/docs/HowTo/topics/Edit-topic-request",
"/docs/HowTo/topics/My-topic-requests",
"/docs/HowTo/topics/Promote-a-topic",
"/docs/HowTo/topics/Request-a-new-topic",
"/docs/HowTo/topics/Topic-overview",
"/docs/HowTo/topics/View-consumer-lag",
"/docs/HowTo/topics/View-topic-events",
"/docs/HowTo/users",
"/docs/HowTo/zothers",
"/docs/quickstart",
"/docs/releases",
"/docs/releases/release100",
"/docs/releases/release110",
"/docs/releases/release120",
"/docs/releases/release200",
"/docs/releases/release210",
"/docs/releases/release220",
"/docs/releases/release230",
"/docs/releases/release240",
"/docs/releases/release250",
"/docs/releases/release251",
"/docs/releases/release252",
"/docs/releases/release260",
"/docs/releases/release261",
"/docs/releases/release270",
"/"
]
4 changes: 3 additions & 1 deletion docs/HowTo/deployklaw.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Learn how to deploy Klaw with an outline of steps and key points for a smooth up

## Klaw releases cycle

Our team, along with Klaw's contributors, is committed to enhancing the functionality and efficiency of Klaw, aiming to deliver new updates approximately every 1.5 months. You can access all past and the most recent releases [here](../../docs/category/Releases). Highlighted updates include versions such as 2.4.0, 2.5.0, among others.
Our team, along with Klaw's contributors, is committed to enhancing the functionality and efficiency of Klaw, aiming
to deliver new updates approximately every 1.5 months. You can access all past and the most recent releases [here](..
/../docs/releases). Highlighted updates include versions such as 2.4.0, 2.5.0, among others.

## Deployment strategy

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Releases",
"position": 5,
"position": 1,
"link": {
"type": "generated-index"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 15 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const { addRedirectsFile } = require("./plugins/add-redirects-file");
const { createLinkFile } = require("./plugins/create-link-file");

const lightCodeTheme = require("prism-react-renderer").themes.github;
const darkCodeTheme = require("prism-react-renderer").themes.dracula;
Expand Down Expand Up @@ -49,6 +51,7 @@ const config = {
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
debug: true,
}),
],
],
Expand All @@ -71,15 +74,16 @@ const config = {
items: [
{
type: "docSidebar",
sidebarId: "tutorialSidebar",
sidebarId: "docs",
position: "left",
label: "Docs",
},
{ to: "/blog", label: "Blog", position: "left" },
{
to: "/docs/category/Releases",
label: "Releases",
type: "docSidebar",
sidebarId: "releases",
position: "left",
label: "Releases",
},
{
href: "https://github.com/aiven/klaw",
Expand Down Expand Up @@ -138,6 +142,14 @@ const config = {
darkTheme: darkCodeTheme,
},
}),
plugins: [
() => ({
postBuild(props) {
createLinkFile(props);
addRedirectsFile(props);
},
}),
],
};

module.exports = config;
39 changes: 39 additions & 0 deletions plugins/add-redirects-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require("path");
const fs = require("fs");

/**
* function to add our redirects after build
* @param {object} props - the `props` object returned from postBuild
*/
function addRedirectsFile(props) {
const redirectFileName = "_redirects";
const redirectFilePath = path.basename(redirectFileName);

const destinationDirectory = props.outDir;

if (!redirectFilePath) {
console.error(`⚠️ Redirect file does not exist!`);
return;
}

if (!fs.existsSync(destinationDirectory)) {
console.error(
`⚠️ Build directory "${destinationDirectory} does not exist.`
);
return;
}

// Construct the destination file path
const destinationFilePath = path.join(destinationDirectory, redirectFileName);

// Copy the file
fs.copyFile(redirectFilePath, destinationFilePath, (err) => {
if (err) {
console.error(`Error copying file: ${err}`);
return;
}
console.log(`_redirects copied to ${destinationDirectory}`);
});
}

export { addRedirectsFile };
19 changes: 19 additions & 0 deletions plugins/create-link-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { writeFileSync } = require("fs");

/**
* function create a file with all links
* this is a temp plugin to help us restructure our page
* without missing any links that need redirects
* @param {object} props - the `props` object returned from postBuild
*/
function createLinkFile(props) {
const routes = JSON.stringify(props.routesPaths, null, 2);
const filePath = "./current-routes.json";

// Write the routes to the file
writeFileSync(filePath, routes, "utf-8");

console.log(`Routes paths have been saved to ${filePath}`);
}

export { createLinkFile };
55 changes: 42 additions & 13 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,48 @@

/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{ type: "autogenerated", dirName: "." }],

// But you can create a sidebar manually

// tutorialSidebar: [
// 'getstarted',
// {
// type: 'category',
// label: 'Concepts',
// items: ['Concepts/clusters-environments'],
// },
// ],
docs: [
"index",
"quickstart",
"features",
"getstarted",
{
type: "category",
label: "Concepts",
items: [
{
type: "autogenerated",
dirName: "Concepts", // Generate sidebar slice from docs/concepts
},
],
},
{
type: "category",
label: "HowTo",
items: [
{
type: "autogenerated",
dirName: "HowTo", // Generate sidebar slice from docs/howTo
},
],
},
"faq",
],
releases: [
{
type: "category",
label: "All releases",
link: { type: "generated-index", slug: "releases" },
collapsed: false,
collapsible: false,
items: [
{
type: "autogenerated",
dirName: "releases", // Generate sidebar slices from docs/releases
},
],
},
],
};

module.exports = sidebars;

0 comments on commit 87cc540

Please sign in to comment.