Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static string GetDataFile(string rootPath, string id) => Path.Join(GetDataRoot(rootPath), $"{NameUtility.Encode(id)}.json");
Beispiel #4
0
 public static string GetRouteFile(string rootPath, string route) => Path.Join(GetRouteRoot(rootPath), $"{NameUtility.Encode(route)}.json");
Beispiel #5
0
 protected override string GetPath(string id) => Path.Join(RootPath, $"{NameUtility.Encode(id)}.json");