mirror of
https://github.com/github/awesome-copilot.git
synced 2026-06-15 20:34:59 +00:00
More website tweaks (#977)
* Some layout tweaks * SSR resource listing pages Render resource listing pages in Astro for first paint and hydrate client filtering/search behavior on top. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fixing font path * removing feature plugin reference as we don't track that anymore * button alignment * rendering markdown * Improve skills modal file browsing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Improving the layout of the search/filter section --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const embeddedDataCache = new Map<string, unknown>();
|
||||
|
||||
export function getEmbeddedDataElementId(filename: string): string {
|
||||
return `page-data-${filename.replace(/[^a-z0-9]+/gi, "-").toLowerCase()}`;
|
||||
}
|
||||
|
||||
export function serializeEmbeddedData(data: unknown): string {
|
||||
return JSON.stringify(data).replace(/</g, "\\u003c");
|
||||
}
|
||||
|
||||
export function getEmbeddedData<T>(filename: string): T | null {
|
||||
if (typeof document === "undefined") return null;
|
||||
|
||||
if (embeddedDataCache.has(filename)) {
|
||||
return embeddedDataCache.get(filename) as T;
|
||||
}
|
||||
|
||||
const element = document.getElementById(getEmbeddedDataElementId(filename));
|
||||
if (!(element instanceof HTMLScriptElement)) return null;
|
||||
|
||||
try {
|
||||
const data = JSON.parse(element.textContent || "null") as T;
|
||||
embeddedDataCache.set(filename, data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(`Error parsing embedded data for ${filename}:`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user