| /** | |
| * Server-side bibliography formatting using citation-js. | |
| * | |
| * Formats CSL-JSON entries into HTML bibliography, independent | |
| * of any client-side rendering. | |
| */ | |
| import { Cite } from "@citation-js/core"; | |
| import "@citation-js/plugin-bibtex"; | |
| import "@citation-js/plugin-csl"; | |
| /** | |
| * Format an array of CSL-JSON entries into an HTML bibliography string. | |
| */ | |
| export async function formatBibliographyServer( | |
| entries: any[], | |
| style: string = "apa" | |
| ): Promise<string> { | |
| if (!entries.length) return ""; | |
| const cite = new Cite(entries); | |
| const html = cite.format("bibliography", { | |
| format: "html", | |
| template: style, | |
| lang: "en-US", | |
| }); | |
| return html as string; | |
| } | |