示例#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);
            }
        }
示例#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);
        }
示例#3
0
文件: Paths.cs 项目: lanicon/acblog
 public static string GetDataFile(string rootPath, string id) => Path.Join(GetDataRoot(rootPath), $"{NameUtility.Encode(id)}.json");
示例#4
0
文件: Paths.cs 项目: lanicon/acblog
 public static string GetRouteFile(string rootPath, string route) => Path.Join(GetRouteRoot(rootPath), $"{NameUtility.Encode(route)}.json");
示例#5
0
 protected override string GetPath(string id) => Path.Join(RootPath, $"{NameUtility.Encode(id)}.json");