Skip to content

Commit 0b8d440

Browse files
committed
add
1 parent 6e11d46 commit 0b8d440

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

pages/courses/[...slug].tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
161161
// Find course from data file
162162
const course = courses.find(c => c.slug === courseSlug);
163163
if (!course) {
164+
console.log(`Course not found: ${courseSlug}`);
164165
return { notFound: true };
165166
}
166167

@@ -169,11 +170,13 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
169170
const moduleSlug = params.slug[1];
170171

171172
try {
173+
console.log(`Loading module: ${moduleSlug} for course: ${courseSlug}`);
172174
// Attempt to load the specific module
173175
const { frontmatter, content } = getContentFileBySlug(`courses/${courseSlug}`, moduleSlug);
174176

175177
// Get all modules for this course for navigation
176178
const modules = getModuleFiles(courseSlug);
179+
console.log(`Found ${modules.length} modules for course ${courseSlug}`);
177180

178181
// Find current module in the list
179182
const currentModule = modules.find(m => m.slug === moduleSlug) || {
@@ -203,6 +206,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
203206
try {
204207
const { frontmatter, content } = getContentFileBySlug('courses', courseSlug);
205208
const modules = getModuleFiles(courseSlug);
209+
console.log(`Found ${modules.length} modules for course ${courseSlug}`);
206210

207211
const mdxSource = await serializeMdx(content);
208212

pages/courses/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export default function CoursesIndex() {
219219
Our courses offer practical, hands-on learning with real-world projects to help you become proficient in Go.
220220
</p>
221221
<Link
222-
href="/courses/quick-start-with-golang-modules/01-introduction-to-go"
222+
href="/courses/quick-start-with-golang-modules/02-lets-start-with-first-hello-world-program"
223223
className="px-6 py-3 bg-white text-blue-600 font-medium rounded-md hover:bg-blue-50 transition-colors inline-flex items-center"
224224
>
225225
Start Learning Now

src/lib/mdx.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ export function getContentFileBySlug(type: string, slug: string) {
4949
// Check if file exists
5050
if (!fs.existsSync(filePath)) {
5151
console.log(`File exists: false`);
52+
53+
// Special case for quick-start-with-golang-modules
54+
if (type === 'courses/quick-start-with-golang-modules') {
55+
const directPath = path.join(contentDirectory, 'courses/quick-start-with-golang-modules', `${slug}.mdx`);
56+
console.log(`Trying quick-start-with-golang-modules direct path: ${directPath}`);
57+
58+
if (fs.existsSync(directPath)) {
59+
console.log(`Found file at direct path: ${directPath}`);
60+
const fileContents = fs.readFileSync(directPath, 'utf8');
61+
const { data, content } = matter(fileContents);
62+
63+
console.log(`File exists: true`);
64+
console.log(`File size: ${fileContents.length} bytes`);
65+
66+
return {
67+
frontmatter: data as Frontmatter,
68+
slug,
69+
content,
70+
};
71+
}
72+
}
73+
5274
// If direct path doesn't exist, try course-specific directory for modules
5375
if (type.includes('courses/')) {
5476
const courseSlug = type.split('/')[1];
@@ -199,6 +221,12 @@ export function getModuleFiles(courseSlug: string) {
199221
if (!fs.existsSync(moduleDirectory)) {
200222
console.log(`Module directory not found: ${moduleDirectory}`);
201223

224+
// Special case for quick-start-with-golang-modules
225+
if (courseSlug === 'quick-start-with-golang-modules') {
226+
console.log(`Using special case for quick-start-with-golang-modules`);
227+
return getModuleFiles('quick-start-with-golang-modules');
228+
}
229+
202230
// Last resort - if the courseSlug is 'quick-start-with-golang', try 'quick-start-with-golang-modules'
203231
if (courseSlug === 'quick-start-with-golang') {
204232
return getModuleFiles('quick-start-with-golang-modules');

0 commit comments

Comments
 (0)