すべてのソース
StackOverflow Hot
開発者 v1.0.0Hot questions from StackOverflow
@codytseng #stackoverflow #programming #qa
設定項目
| 名前 | キー | タイプ | 必須 | デフォルト | 説明 |
|---|---|---|---|---|---|
| Tag | TAG | string | いいえ | — | Filter by tag, comma-separated for multiple (e.g., javascript,python,react). Leave empty for all tags. |
| Sort | SORT | select | いいえ | hot | Sort order for questions hotactivityvotescreationweekmonth |
ソースコード
version: 1.0.0
name: StackOverflow Hot
description: Hot questions from StackOverflow
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- stackoverflow
- programming
- qa
config:
- key: TAG
name: Tag
type: string
required: false
description: Filter by tag, comma-separated for multiple (e.g., javascript,python,react). Leave empty for all tags.
- key: SORT
name: Sort
type: select
required: false
default: hot
description: Sort order for questions
options:
- hot
- activity
- votes
- creation
- week
- month version: 1.0.0
name: StackOverflow Hot
description: Hot questions from StackOverflow
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- stackoverflow
- programming
- qa
config:
- key: TAG
name: Tag
type: string
required: false
description: Filter by tag, comma-separated for multiple (e.g., javascript,python,react). Leave empty for all tags.
- key: SORT
name: Sort
type: select
required: false
default: hot
description: Sort order for questions
options:
- hot
- activity
- votes
- creation
- week
- month import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
type Question = {
question_id: number;
title: string;
link: string;
score: number;
answer_count: number;
view_count: number;
tags: string[];
creation_date: number;
};
const tagConfig = api.config.get("TAG");
const sort = api.config.get("SORT") || "hot";
const tags = tagConfig
? tagConfig.split(",").map((t) => t.trim()).filter(Boolean)
: [];
const toItems = (questions: Question[]) =>
questions.map((q) => ({
id: q.question_id.toString(),
title: q.title,
subtitle: `${q.score} votes · ${q.answer_count} answers · ${q.tags.slice(0, 3).join(", ")}`,
url: q.link,
timestamp: q.creation_date,
}));
if (tags.length > 0) {
const pageSize = Math.min(30, Math.floor(150 / tags.length));
await Promise.all(
tags.map(async (tag) => {
const res = await api.fetch<{ items: Question[] }>(
`https://api.stackexchange.com/2.3/questions?order=desc&sort=${sort}&site=stackoverflow&pagesize=${pageSize}&tagged=${encodeURIComponent(tag)}`,
);
if (res.ok && res.json) {
api.emit(toItems(res.json.items));
}
}),
);
} else {
const res = await api.fetch<{ items: Question[] }>(
`https://api.stackexchange.com/2.3/questions?order=desc&sort=${sort}&site=stackoverflow&pagesize=30`,
);
if (res.ok && res.json) {
api.emit(toItems(res.json.items));
}
}
},
};
}; import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
type Question = {
question_id: number;
title: string;
link: string;
score: number;
answer_count: number;
view_count: number;
tags: string[];
creation_date: number;
};
const tagConfig = api.config.get("TAG");
const sort = api.config.get("SORT") || "hot";
const tags = tagConfig
? tagConfig.split(",").map((t) => t.trim()).filter(Boolean)
: [];
const toItems = (questions: Question[]) =>
questions.map((q) => ({
id: q.question_id.toString(),
title: q.title,
subtitle: `${q.score} votes · ${q.answer_count} answers · ${q.tags.slice(0, 3).join(", ")}`,
url: q.link,
timestamp: q.creation_date,
}));
if (tags.length > 0) {
const pageSize = Math.min(30, Math.floor(150 / tags.length));
await Promise.all(
tags.map(async (tag) => {
const res = await api.fetch<{ items: Question[] }>(
`https://api.stackexchange.com/2.3/questions?order=desc&sort=${sort}&site=stackoverflow&pagesize=${pageSize}&tagged=${encodeURIComponent(tag)}`,
);
if (res.ok && res.json) {
api.emit(toItems(res.json.items));
}
}),
);
} else {
const res = await api.fetch<{ items: Question[] }>(
`https://api.stackexchange.com/2.3/questions?order=desc&sort=${sort}&site=stackoverflow&pagesize=30`,
);
if (res.ok && res.json) {
api.emit(toItems(res.json.items));
}
}
},
};
};