class PaperCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
static get observedAttributes() {
return ['title', 'summary', 'authors', 'date', 'pdf-link', 'abs-link'];
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this.render();
}
}
render() {
const title = this.getAttribute('title') || 'No Title';
const summary = this.getAttribute('summary') || 'No summary available.';
const authors = this.getAttribute('authors') || 'Unknown';
const date = this.getAttribute('date') || '';
const pdfLink = this.getAttribute('pdf-link') || '#';
const absLink = this.getAttribute('abs-link') || '#';
// Truncate summary if too long
const shortSummary = summary.length > 200 ? summary.substring(0, 200) + '...' : summary;
this.shadowRoot.innerHTML = `
${date}
${title}
${authors}
${shortSummary}
`;
// Re-initialize icons inside Shadow DOM
if(window.feather) {
feather.replace();
}
}
}
customElements.define('paper-card', PaperCard);