camelmasa / qiita-advent-calendar-2023-hatebu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TOP 100

Usage

import * as fs from "fs";
import { createCrawler } from ".";

(async () => {
  const crawler = createCrawler();
  const crawl = await crawler.crawl();

  const articles = crawl.categories.flatMap((category) =>
    category.calenders.flatMap((calendar) =>
      calendar.articles.map((article) => ({
        title: article.title,
        url: article.url,
        hatebu: article.hatebu,
      })),
    ),
  );

  const sortedArticles = articles.sort((a, b) => b.hatebu - a.hatebu);
  const filePath = "2023-12-29.json";
  fs.writeFileSync(filePath, JSON.stringify(sortedArticles, null, 2));
})();

About


Languages

Language:TypeScript 100.0%