scrapboxのプロジェクトアイコンを取得する
Scrapboxの検索ではiconを取得できているのでapiからたたけないか?を試してみる
code:ProjectLinkItem.js
var ProjectLinkItem = ({
project: t, //どこから呼び出されてるんだ?
searchQuery: i
}) => {
var s = v.default.stringify({
q: i
}),
_ = "/".concat(t.name, "/search/page?").concat(s);
return m.default.createElement("li", {
className: "page-list-item list-style-item"
}, m.default.createElement("a", {
href: _,
target: "_blank",
rel: "noreferrer"
}, t.image && m.default.createElement("div", {
className: "icon"
}, m.default.createElement("img", {
src: t.image //ここがimgのsrc
})), m.default.createElement("div", {
className: "content"
}, m.default.createElement("div", {
className: "title-with-description"
}, t.displayName, " (/", t.name, ")"))))
};
code:m.default.createElement.js
return m.default.createElement("div", {
className: "project-search"
}, m.default.createElement("div", {
className: "project-search-count"
}, "Search from all projects"), s.data ? (Z = W.default.CurrentProject //ここのs
.get().name, X = s.data.projects.filter((t => t.name !== Z)).sort((( //Xになり
t, i) => t.name.toLowerCase() < i.name.toLowerCase() ? -1 : 1)), X.length <
1 ? m.default.createElement(m.default.Fragment, null, m.default.createElement(
j.default, {
kind: "project",
searchQuery: t
}), i) : m.default.createElement(m.default.Fragment, null, m.default
.createElement("div", {
className: "project-search-result"
}, m.default.createElement("ul", {
className: "list"
}, X.map((i => m.default.createElement(ProjectLinkItem, {
project: i, //Xのiが渡される
searchQuery: t,
key: i.name
}))))), i)) : (() => {
var i = s.waitingApiResponse,
{
errorMessage: v
} = s;
return m.default.createElement("form", {
onSubmit: Y
}, m.default.createElement("div", {
className: "text-center"
}, m.default.createElement("button", {
type: "submit",
className: "project-search-button btn btn-auto-block btn-default",
disabled: i
}, 'Search "', t, '"', " ", i ? m.default.createElement("i", {
className: "fa fa-spinner"
}) : null), v && m.default.createElement("div", {
className: "error alert alert-info"
}, v)))
})());
code:get.js
((function*(i) {
var m = W.default.ProjectsLastAccessed.get(),
j = W.default.ProjectList.getWatchProjects().sort(((t, i) => mt.id > mi.id ? -1 : 1)).map((t => t.id)); j.length > 50 && (j.length = 50), i && i.preventDefault();
var $ = v.default.stringify({
q: t,
ids: j
}),
Y = "/api/projects/search/watch-list?".concat($);
s({
waitingApiResponse: !0
});
try {
var Z = yield _.apiClient.get(Y, {
cancelToken: M.routeCanceller.token,
skipTrackLoading: !0
});
s({
data: Z.data,
waitingApiResponse: !1,
errorMessage: ""
})
} catch (ee) {
var X = ee.response ? ee.response.data.message : ee.message;
s({
waitingApiResponse: !1,
errorMessage: X
})
}
}));