Glanceway Glanceway
모든 소스

Hacker News

뉴스 v1.0.0

Top stories from Hacker News

@codytseng #news #tech #programming

Install and configure this source

  1. Install Glanceway and open it on your Mac before using the install link above.
  2. Choose Install in Glanceway. If the browser cannot open the app, download the .gwsrc file and import it through source management.
  3. Complete the required fields below, save, and choose a refresh interval. Check the source after its first successful fetch.

Configuration checklist

  • STORY_TYPE — Optional. Type of stories to display

If items are missing

  • Verify the field names, list entries, and credentials against the current version’s configuration table. Sample values below are examples, not active credentials.
  • Check network access and upstream service availability. Authentication failures and rate limits can prevent a refresh; use a slower interval when the provider limits requests.
  • An empty result can also mean there are no matching items. Fetched content and update timing depend on the provider and source implementation.

설정

이름 키 유형 필수 기본값 설명
Story Type STORY_TYPE select 아니오 top Type of stories to display
topnewbestaskshowjob

소스 코드

id: codytseng/hacker-news
version: 1.0.0
name: Hacker News
description: Top stories from Hacker News
author: codytseng
category: News
tags:
  - news
  - tech
  - programming

config:
  - key: STORY_TYPE
    name: Story Type
    type: select
    required: false
    default: top
    description: Type of stories to display
    options:
      - top
      - new
      - best
      - ask
      - show
      - job
module.exports = async (api) => {
  const storyType = api.config.get("STORY_TYPE") || "top";

  async function fetchData() {
    const endpoint = `https://hacker-news.firebaseio.com/v0/${storyType}stories.json`;
    const idsResponse = await api.fetch(endpoint);

    if (!idsResponse.ok || !idsResponse.json) {
      throw new Error(`Failed to fetch Hacker News story list (HTTP ${idsResponse.status})`);
    }

    const topIds = idsResponse.json.slice(0, 100);
    const items = [];

    await Promise.allSettled(
      topIds.map(async (id) => {
        const res = await api.fetch(
          `https://hacker-news.firebaseio.com/v0/item/${id}.json`,
        );
        if (res.json) {
          items.push(res.json);
          api.emit(
            items.map((item) => ({
              id: item.id.toString(),
              title: item.title,
              subtitle: `${item.score} points · ${item.descendants ?? 0} comments · by ${item.by}`,
              url: `https://news.ycombinator.com/item?id=${item.id}`,
              timestamp: item.time,
            })),
          );
        }
      }),
    );
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

관련 소스