Skip to content

Commit

Permalink
Add new docs website
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jul 2, 2023
1 parent fbea7e6 commit b4f2bb5
Show file tree
Hide file tree
Showing 1,573 changed files with 121,055 additions and 8,305 deletions.
6 changes: 6 additions & 0 deletions MyApp/Configure.AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public AppHost() : base("MyApp", typeof(MyServices).Assembly) {}

public override void Configure(Funq.Container container)
{
SetConfig(new HostConfig {
IgnorePathInfoPrefixes = {
"/templates",
}
});
Plugins.RemoveAll(x => x is UiFeature);
}
}

Expand Down
17 changes: 8 additions & 9 deletions MyApp/Configure.Ssg.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using ServiceStack.IO;
using ServiceStack.Logging;

[assembly: HostingStartup(typeof(MyApp.ConfigureSsg))]

Expand All @@ -14,29 +15,22 @@ public void Configure(IWebHostBuilder builder) => builder
services.AddSingleton(AppConfig.Instance);
services.AddSingleton<RazorPagesEngine>();
services.AddSingleton<MarkdownPages>();
services.AddSingleton<MarkdownWhatsNew>();
services.AddSingleton<MarkdownVideos>();
services.AddSingleton<MarkdownBlog>();
services.AddSingleton<MarkdownMeta>();
})
.ConfigureAppHost(
appHost => appHost.Plugins.Add(new CleanUrlsFeature()),
afterPluginsLoaded: appHost =>
{
var pages = appHost.Resolve<MarkdownPages>();
var whatsNew = appHost.Resolve<MarkdownWhatsNew>();
var videos = appHost.Resolve<MarkdownVideos>();
var blogPosts = appHost.Resolve<MarkdownBlog>();
var meta = appHost.Resolve<MarkdownMeta>();
blogPosts.Authors = AppConfig.Instance.Authors;
meta.Features = new() { pages, whatsNew, videos, blogPosts };
meta.Features = new() { pages, videos };
meta.Features.ForEach(x => x.VirtualFiles = appHost.VirtualFiles);
pages.LoadFrom("_pages");
whatsNew.LoadFrom("_whatsnew");
videos.LoadFrom("_videos");
blogPosts.LoadFrom("_posts");
},
afterAppHostInit: appHost =>
{
Expand All @@ -50,9 +44,15 @@ public void Configure(IWebHostBuilder builder) => builder
var distDir = appHost.ContentRootDirectory.RealPath.CombineWith("dist");
if (Directory.Exists(distDir))
FileSystemVirtualFiles.DeleteDirectory(distDir);
FileSystemVirtualFiles.CopyAll(
new DirectoryInfo(appHost.ContentRootDirectory.RealPath.CombineWith("wwwroot")),
new DirectoryInfo(distDir));
// Render .html redirect files
RazorSsg.PrerenderRedirectsAsync(appHost.ContentRootDirectory.GetFile("redirects.json"), distDir)
.GetAwaiter().GetResult();
var razorFiles = appHost.VirtualFiles.GetAllMatchingFiles("*.cshtml");
RazorSsg.PrerenderAsync(appHost, razorFiles, distDir).GetAwaiter().GetResult();
});
Expand All @@ -64,7 +64,6 @@ public class AppConfig
public static AppConfig Instance { get; } = new();
public string LocalBaseUrl { get; set; }

Check warning on line 65 in MyApp/Configure.Ssg.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LocalBaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string PublicBaseUrl { get; set; }

Check warning on line 66 in MyApp/Configure.Ssg.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'PublicBaseUrl' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public List<AuthorInfo> Authors { get; set; } = new();
}

// Add additional frontmatter info to include
Expand Down
171 changes: 0 additions & 171 deletions MyApp/Markdown.Blog.cs

This file was deleted.

12 changes: 9 additions & 3 deletions MyApp/Markdown.Pages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public List<MarkdownFileInfo> GetVisiblePages(string? prefix=null, bool allDirec
.Where(x => allDirectories || (x.Slug.CountOccurrencesOf('/') == prefix.CountOccurrencesOf('/') + 1))
.OrderBy(x => x.Order).ToList();

public MarkdownFileInfo? GetBySlug(string slug) =>
Fresh(Pages.Where(IsVisible).FirstOrDefault(x => x.Slug == slug));
public MarkdownFileInfo? GetBySlug(string slug)
{
slug = slug.Trim('/');
return Fresh(Pages.Where(IsVisible).FirstOrDefault(x => x.Slug == slug));
}

public Dictionary<string, List<MarkdownMenu>> Sidebars { get; set; } = new();

Expand Down Expand Up @@ -57,7 +60,6 @@ public void LoadFrom(string fromDirectory)
{
var virtualPath = file.VirtualPath.Substring(fromDirectory.Length);
var folder = virtualPath.Substring(0, virtualPath.Length - "sidebar.json".Length).Trim('/');
Console.WriteLine($"sidebar :: {folder}");
var sidebarJson = file.ReadAllText();
var sidebar = sidebarJson.FromJson<List<MarkdownMenu>>();

Expand All @@ -75,6 +77,10 @@ public void LoadFrom(string fromDirectory)
log.Error(e, "Couldn't load {0}: {1}", file.VirtualPath, e.Message);
}
}
if (Sidebars.Count > 0)
{
log.Info($"Loaded {Sidebars.Count} sidebars: {Sidebars.Keys.Join(", ")}");
}
}

public override List<MarkdownFileBase> GetAll() => Pages.Where(IsVisible).Map(doc => ToMetaDoc(doc, x => x.Url = $"/{x.Slug}"));
Expand Down
73 changes: 0 additions & 73 deletions MyApp/Markdown.WhatsNew.cs

This file was deleted.

Loading

0 comments on commit b4f2bb5

Please sign in to comment.