Skip to content

Commit

Permalink
Display title on Documentcloud.org embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
garmoncheg committed Nov 1, 2024
1 parent 0b71da8 commit 12537e0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions plugins/domains/documentcloud.org.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ export default {
"oembed-site",
"canonical",
"author",
"og-title",
"og-image",
"og-description"
],

// plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame
// https://www.documentcloud.org/help/api#oembed

getMeta: function(oembed, options) {
var title = options.getRequestOptions('documentcloud.title');
if (title && oembed.title) {
return {
title: oembed.title
}
}
},

getLink: function(url, oembed, options) {

if (oembed.type === 'rich' && oembed.html) { // else: fallback to generic
Expand All @@ -31,6 +39,7 @@ export default {

if (!/DC\-note/.test(html) && !/DC\-embed(?:\-page)?/.test(html)) {
var page = options.getRequestOptions('documentcloud.page', '1');
var title = !!options.getRequestOptions('documentcloud.title', true);

try {
var iframe = oembed.getIframe();
Expand All @@ -51,6 +60,10 @@ export default {
page: {
label: CONFIG.L.page,
value: parseInt (page)
},
title: {
label: 'Show Title',
value: title
}
}
} catch (ex) {}
Expand Down Expand Up @@ -94,7 +107,6 @@ export default {
'og-description',
'author',
'canonical',
'og-title',
'og-image'
]},
'https://www.documentcloud.org/documents/73991-day-three-documents',
Expand Down

0 comments on commit 12537e0

Please sign in to comment.