Skip to content
Open
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
44 changes: 32 additions & 12 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions libs/services/terragrunt-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export class TerragruntDocs {

/**
* Get all documentation categories from the Terragrunt repository
* Categories are represented as folders in the docs/_docs path
* Categories are represented as folders in the docs-starlight/src/content/docs path
* @returns Promise with an array of documentation categories
*/
async getDocCategories(): Promise<DocCategory[]> {
// The docs are stored in the 'docs/_docs' directory of the repo
const path = "docs/_docs";
// The docs are stored in the 'docs-starlight/src/content/docs' directory of the repo
const path = "docs-starlight/src/content/docs";

try {
const response = await this.client.get<GitHubContent[]>(
Expand Down Expand Up @@ -117,7 +117,7 @@ export class TerragruntDocs {
}

/**
* List all markdown documents in a specific category
* List all markdown/mdx documents in a specific category
* @param category The category name to list documents from
* @returns Promise with an array of document summaries
*/
Expand All @@ -143,9 +143,9 @@ export class TerragruntDocs {

const contents = response as GitHubContent[];

// Find and return only markdown files
// Find and return only markdown/mdx files
const mdFiles = contents
.filter((item) => item.type === "file" && item.name.endsWith(".md"))
.filter((item) => item.type === "file" && (item.name.endsWith(".md") || item.name.endsWith(".mdx")))
.map((file) => ({
name: file.name,
path: file.path,
Expand All @@ -165,7 +165,7 @@ export class TerragruntDocs {
}

/**
* Get a specific markdown document from a category
* Get a specific markdown/mdx document from a category
* @param options The category and document to fetch
* @returns Promise with the document content and metadata
*/
Expand Down Expand Up @@ -194,9 +194,9 @@ export class TerragruntDocs {

const contents = response as GitHubContent[];

// Find markdown files
// Find markdown/mdx files
const mdFiles = contents.filter(
(item) => item.type === "file" && item.name.endsWith(".md"),
(item) => item.type === "file" && (item.name.endsWith(".md") || item.name.endsWith(".mdx")),
);

const docNames = mdFiles.map(file => file.name);
Expand Down Expand Up @@ -260,7 +260,7 @@ export class TerragruntDocs {
}

/**
* Get all markdown documents in a specific category and merge their content
* Get all markdown/mdx documents in a specific category and merge their content
* @param category The category name to get documents from
* @returns Promise with the merged content of all documents in the category
*/
Expand All @@ -283,14 +283,14 @@ export class TerragruntDocs {

// Format each document with a clear header - ensure consistent newline formatting
// Use a consistent header pattern that our test can reliably match
return `\n\n## ${doc.name.replace(".md", "")}\n\n${fullDoc.content}`;
return `\n\n## ${doc.name.replace(/\.(md|mdx)$/, "")}\n\n${fullDoc.content}`;
} catch (error) {
// If we can't fetch a specific document, include an error message instead
const errorMessage = error instanceof Error
? error.message
: String(error);
return `\n\n## ${
doc.name.replace(".md", "")
doc.name.replace(/\.(md|mdx)$/, "")
} (Error)\n\nFailed to fetch document: ${errorMessage}`;
}
});
Expand Down
10 changes: 5 additions & 5 deletions tests/terragrunt-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ Deno.test("TerragruntDocs - getDocCategories", async () => {
assertExists(category.url);
assertExists(category.html_url);

// Verify the path matches the expected format (docs/_docs/*)
// Verify the path matches the expected format (docs-starlight/src/content/docs/*)
assertEquals(
category.path.startsWith("docs/_docs/"),
category.path.startsWith("docs-starlight/src/content/docs/"),
true,
`Category path should start with "docs/_docs/": ${category.path}`,
`Category path should start with "docs-starlight/src/content/docs/": ${category.path}`,
);

// Check that names are properly formatted (capitalized words without numbers)
Expand Down Expand Up @@ -145,9 +145,9 @@ Deno.test("TerragruntDocs - listDocumentsInCategory", async () => {

// Verify the path matches the expected format
assertEquals(
doc.path.startsWith("docs/_docs/"),
doc.path.startsWith("docs-starlight/src/content/docs/"),
true,
`Document path should start with "docs/_docs/": ${doc.path}`,
`Document path should start with "docs-starlight/src/content/docs/": ${doc.path}`,
);
}
});
Expand Down