Skip to content

Commit

Permalink
Reload docs on save in dev-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
damianstasik committed Sep 26, 2024
1 parent 2a81d65 commit a59784d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion frontend/src/routes/Docs/loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { LoaderFunction } from "react-router-dom";
import { NotFoundPageError } from "@/utils/errors";
import { slugPathMap } from "./utils" with { type: "macro" };
import * as prodUtils from "./utils" with { type: "macro" };
import * as devUtils from "./utils";

const slugPathMap = import.meta.env.PROD
? prodUtils.getSlugPathMap()
: devUtils.getSlugPathMap();

export const docsLoader: LoaderFunction = async ({ params }) => {
const { "*": slug = "" } = params;
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/routes/Docs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import sidebar from "../../../docs/sidebar.json";
import { processor } from "@/components/Markdown/processor";
import { renderToStaticMarkup } from "react-dom/server";

const docs = import.meta.glob("../../../docs/**/*.md", {
eager: true,
as: "raw",
});
export function getSlugPathMap() {
const docs = import.meta.glob("../../../docs/**/*.md", {
eager: true,
as: "raw",
});

function getSlugPathMap() {
const processorWithFrontmatter = processor().use(() => {
return (_, file) => {
matter(file);
Expand Down Expand Up @@ -46,5 +46,3 @@ function getSlugPathMap() {

return slugPathMap;
}

export const slugPathMap = getSlugPathMap();

0 comments on commit a59784d

Please sign in to comment.