Enable more customisation for editLink #1468
Replies: 2 comments 1 reply
-
|
Managed to set it up using |
Beta Was this translation helpful? Give feedback.
-
|
Adding an updated approach to entirely customize the edit link by relying on route data. Route data is an object containing all the information required to render a single page, including the // src/routeData.ts
import { defineRouteMiddleware } from "@astrojs/starlight/route-data";
export const onRequest = defineRouteMiddleware((context) => {
const { starlightRoute } = context.locals;
if (starlightRoute.editUrl) {
starlightRoute.editUrl = new URL(
// Update the edit URL
starlightRoute.editUrl.href.replace("src/content/docs/", ""),
starlightRoute.editUrl
);
}
});Depending on the needs, all route data properties can be accessed to help customize the edit link. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What version of
starlightare you using?0.17.2
What is your idea?
Enable additional customisations for generating the editLink when the content files are not in the default location or are part of a custom setup. This can be achieved by offering more options in astro.config.js for the edit link or by calling a function, for instance.
Why is this feature necessary?
We have a unique setup: our content (.md files) resides in a separate repository from the website/starlight app. This arrangement serves various purposes. In our pipeline, before generating different doc versions, we extract the necessary "content" from the other repo and copy it to the required location.
As a result, the base
src/content/dataportion added to the editUrl does not align with our structure, given the differing file organisation.Do you have examples of this feature in other projects?
No response
Participation
Beta Was this translation helpful? Give feedback.
All reactions