mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 19:35:09 +08:00
3882722195
see: https://meta.discourse.org/t/mini-inline-onebox-support-rfc/66400?source_topic_id=66066
20 lines
453 B
JavaScript
20 lines
453 B
JavaScript
let _cache = {};
|
|
|
|
export function applyInlineOneboxes(inline, ajax) {
|
|
return ajax("/inline-onebox", {
|
|
data: { urls: Object.keys(inline) },
|
|
}).then(result => {
|
|
result['inline-oneboxes'].forEach(onebox => {
|
|
_cache[onebox.url] = onebox;
|
|
let links = inline[onebox.url] || [];
|
|
links.forEach(link => {
|
|
link.text(onebox.title);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
export function cachedInlineOnebox(url) {
|
|
return _cache[url];
|
|
}
|