File tree 2 files changed +36
-1
lines changed 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export default defineConfig({
35
35
baseUrl :
36
36
"https://github.com/splashkit/the-programmers-field-guide/edit/main/" ,
37
37
} ,
38
- plugins : [ starlightLinksValidator ( { errorOnRelativeLinks : false } ) ] ,
38
+ plugins : [ starlightLinksValidator ( { errorOnRelativeLinks : true } ) ] ,
39
39
sidebar : [
40
40
{
41
41
label : "Part 0: First Steps" ,
Original file line number Diff line number Diff line change
1
+ import os
2
+ rootdir = '/workspaces/the-programmers-field-guide/book'
3
+
4
+ for subdir , dirs , files in os .walk (rootdir ):
5
+ for file in files :
6
+ if file .endswith (".md" ) or file .endswith (".mdx" ):
7
+ fname = os .path .join (subdir , file )
8
+ print (f"Processing { fname } " )
9
+ bookPath = subdir .removeprefix ("/workspaces/the-programmers-field-guide/book" ).split ('/' )
10
+ depth = len (bookPath )
11
+ maxDepth = depth
12
+ # Opening the file in read and write mode
13
+ with open (fname ,'r+' ) as f :
14
+
15
+ # Reading the file into content
16
+ content = f .read ()
17
+
18
+ # Determine replacements
19
+ while depth > 0 :
20
+ search = f"]({ '../' * depth } "
21
+ depth -= 1
22
+ replacement = f"](/book{ '/' .join (bookPath [:(maxDepth - depth )])} /"
23
+ print (f" - searching for { search } -> { replacement } " )
24
+
25
+ # Replacing search text
26
+ content = content .replace (search , replacement )
27
+
28
+ # Move to the start of the file
29
+ f .seek (0 )
30
+
31
+ # Replace file content
32
+ f .write (content )
33
+
34
+ # Truncating the file size
35
+ f .truncate ()
You can’t perform that action at this time.
0 commit comments