Skip to content

Commit

Permalink
ignore dir without .md file
Browse files Browse the repository at this point in the history
  • Loading branch information
niltor committed Apr 1, 2024
1 parent 6209b14 commit ea0effd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
7 changes: 4 additions & 3 deletions Lib/BuildSite/HtmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void BuildBlogs()
foreach (var file in files)
{
string markdown = File.ReadAllText(file);
string html = Markdig.Markdown.ToHtml(markdown, pipeline);
string html = Markdown.ToHtml(markdown, pipeline);
string relativePath = file.Replace(ContentPath, Path.Combine(Output, "blogs")).Replace(".md", ".html");

var title = GetTitleFromMarkdown(markdown);
Expand All @@ -86,6 +86,7 @@ public void BuildBlogs()
File.WriteAllText(relativePath, html, Encoding.UTF8);
}
Console.WriteLine("✅ generate blog html!");

foreach (var file in otherFiles)
{
string relativePath = file.Replace(ContentPath, Path.Combine(Output, "blogs"));
Expand Down Expand Up @@ -136,9 +137,7 @@ public void BuildData()

string blogData = Path.Combine(DataPath, "blogs.json");
File.WriteAllText(blogData, json, Encoding.UTF8);

Console.WriteLine("✅ update blogs.json!");

}

/// <summary>
Expand Down Expand Up @@ -175,6 +174,8 @@ private void TraverseDirectory(string directoryPath, Catalog parentCatalog)
{
foreach (string subDirectoryPath in Directory.GetDirectories(directoryPath))
{
var existMd = Directory.GetFiles(subDirectoryPath, "*.md").Length > 0;
if (!existMd) { continue; }
var catalog = new Catalog
{
Name = Path.GetFileName(subDirectoryPath),
Expand Down
2 changes: 1 addition & 1 deletion Lib/BuildSite/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static bool RunCommand(string command, string? args, out string output)
}
else
{
Console.WriteLine($"❌ {output}");
//Console.WriteLine($"❌ {output}");
return false;
}
}
Expand Down
9 changes: 1 addition & 8 deletions WebApp/data/blogs.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"Name": "Root",
"Children": [
{
"Name": "images",
"Children": [],
"Blogs": [],
"Parent": null
}
],
"Children": [],
"Blogs": [
{
"Title": "introduction",
Expand Down
3 changes: 0 additions & 3 deletions WebApp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
<span data-catalog="all" class="filter-item text-lg block py-2 text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100">
全部 [1]
</span>
<span data-catalog="images" class="filter-item text-lg block py-2 text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100">
images [0]
</span>
</div>
<div id="date-list" class="rounded-lg shadow-md p-4 dark:bg-neutral-800 mt-2">
<div class="text-xl font-semibold dark:text-neutral-300">存档</div>
Expand Down

0 comments on commit ea0effd

Please sign in to comment.