Skip to content

Commit 1c9e043

Browse files
committed
refactor: extract editLink pattern into named function
1 parent 20411a5 commit 1c9e043

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

docs/.vitepress/config.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ function buildProjectNavItems() {
156156
}));
157157
}
158158

159+
function buildEditLink({ filePath }) {
160+
const repoUrl = "https://github.com/BlueLua";
161+
const parts = filePath.split("/");
162+
const [project, section, file] = parts;
163+
164+
if (parts.length === 3 && section === "api" && file.endsWith(".md")) {
165+
const stem = file.replace(/\.md$/, "");
166+
return `${repoUrl}/${project}/edit/main/types/${stem}.d.lua`;
167+
}
168+
169+
return `${repoUrl}/bluelua.github.io/edit/main/docs/src/${filePath}`;
170+
}
171+
159172
export default defineConfig({
160173
srcDir: "./src",
161174
title: "BlueLua",
@@ -220,21 +233,7 @@ export default defineConfig({
220233
},
221234
},
222235
},
223-
editLink: {
224-
pattern: ({ filePath }) => {
225-
const repoUrl = "https://github.com/BlueLua";
226-
const parts = filePath.split("/");
227-
const [project, section, file] = parts;
228-
229-
if (parts.length === 3 && section === "api" && file.endsWith(".md")) {
230-
const stem = file.replace(/\.md$/, "");
231-
return `${repoUrl}/${project}/edit/main/types/${stem}.d.lua`;
232-
}
233-
234-
return `${repoUrl}/bluelua.github.io/edit/main/docs/src/${filePath}`;
235-
},
236-
text: "Edit this page",
237-
},
236+
editLink: { pattern: buildEditLink },
238237
socialLinks: [{ icon: "github", link: repoUrl }],
239238
nav: [
240239
{ text: "Home", link: "/" },

0 commit comments

Comments
 (0)