public async Task Build() { FsBuilder.EnsureDirectoryEmpty(); Data = (from x in Data orderby x.CreationTime descending select x).ToArray(); await BuildIndexType().ConfigureAwait(false); await BuildIndexKeyword().ConfigureAwait(false); await BuildIndexCategory().ConfigureAwait(false); foreach (var v in Data) { Post post = v; using var st = FsBuilder.GetFileRewriteStream($"{NameUtility.Encode(post.Id)}.json"); await JsonSerializer.SerializeAsync(st, post).ConfigureAwait(false); } { PagingProvider <string> paging = new PagingProvider <string>(Path.Join(RootPath, "pages")); await paging.Build(Data.Select(x => x.Id).ToArray(), PagingConfig).ConfigureAwait(false); } }
async Task BuildIndexKeyword() { FsBuilder.EnsureDirectoryEmpty("keywords"); var(collection, map) = KeywordCollectionBuilder.BuildFromPosts(Data); foreach (var v in collection.Items) { string subdir = Path.Join("keywords", NameUtility.Encode(v.OneName())); PagingProvider <string> paging = new PagingProvider <string>(Path.Join(RootPath, subdir)); await paging.Build(map[v.OneName()].Select(x => x.Id).ToArray(), PagingConfig).ConfigureAwait(false); } using var st = FsBuilder.GetFileRewriteStream("keywords/all.json"); await JsonSerializer.SerializeAsync(st, collection).ConfigureAwait(false); }
public static string GetDataFile(string rootPath, string id) => Path.Join(GetDataRoot(rootPath), $"{NameUtility.Encode(id)}.json");
public static string GetRouteFile(string rootPath, string route) => Path.Join(GetRouteRoot(rootPath), $"{NameUtility.Encode(route)}.json");
protected override string GetPath(string id) => Path.Join(RootPath, $"{NameUtility.Encode(id)}.json");