Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/starlight/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default defineConfig({
replacesTitle: true,
},
plugins: [starlightImageZoom()],
routeMiddleware: "./src/routeData.ts",
editLink: {
baseUrl: "https://github.com/RIOT-OS/RIOT/tree/master/doc/guides",
},
Expand Down
23 changes: 23 additions & 0 deletions doc/starlight/src/routeData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineRouteMiddleware } from "@astrojs/starlight/route-data";

/**
* Since we currently use a symlink to comply with the (broken)
* docs folder scanning of starlight, this will break the edit
* link since, while technically correct, our symlink will be
* shown as github.com/RIOT-OS/RIOT/doc/guides/src/content/docs/foobar
* Since github can't parse symlinks, we need to modify the editUrl
* through a route middleware in order for the edit link to still function
*
* As soon as base directory changes get fixed, this should be removed
* again! See: https://github.com/withastro/starlight/pull/3332
*/
export const onRequest = defineRouteMiddleware((context) => {
const { starlightRoute } = context.locals;

if (starlightRoute.editUrl) {
starlightRoute.editUrl = new URL(
starlightRoute.editUrl.href.replace("src/content/docs/", ""),
starlightRoute.editUrl,
);
}
});