From 4dab487d03c66462742920da4006cc87787fb83b Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Wed, 29 Jan 2025 11:59:22 +1100 Subject: [PATCH] Enhance documentation with dynamic meta tags and update Blueprint description --- docs/Blueprint Penetration Trace.md | 2 ++ index.html | 12 ++++++++++++ index.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/docs/Blueprint Penetration Trace.md b/docs/Blueprint Penetration Trace.md index 5cfb5ef..a5bac2b 100644 --- a/docs/Blueprint Penetration Trace.md +++ b/docs/Blueprint Penetration Trace.md @@ -1,5 +1,7 @@ --- title: Blueprint Depth Trace +description: A Blueprint Function Library for depth-based line traces in Unreal Engine, providing realistic penetration and bullet holes +image: TraceExample.png --- This is a `Blueprint Function Library` with a few functions that are callable in `AActors` to do depth trace results, for use in things like projectiles and tools. diff --git a/index.html b/index.html index cd61ab6..b207232 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,18 @@ Documentation Viewer + + + + + + + + + + + + diff --git a/index.js b/index.js index 7df66f3..ff3e438 100644 --- a/index.js +++ b/index.js @@ -179,6 +179,35 @@ async function loadDocument(path) { return `\n![${filename}](${mediaPath})\n\n`; }); + // Update meta tags + const description = metadata.description || `Documentation for ${titleContent}`; + const url = `${window.location.origin}${window.location.pathname}${window.location.search}`; + + document.title = `Litruv / ${titleContent}`; + document.querySelector('meta[name="description"]').setAttribute('content', description); + document.querySelector('meta[property="og:title"]').setAttribute('content', titleContent); + document.querySelector('meta[property="og:description"]').setAttribute('content', description); + document.querySelector('meta[property="og:url"]').setAttribute('content', url); + document.querySelector('meta[name="twitter:title"]').setAttribute('content', titleContent); + document.querySelector('meta[name="twitter:description"]').setAttribute('content', description); + + // If there's a cover image in metadata + if (metadata.image) { + const imageUrl = `${window.location.origin}${window.location.pathname}${basePath}/images/${metadata.image}`; + document.querySelector('meta[property="og:image"]')?.remove(); + document.querySelector('meta[name="twitter:image"]')?.remove(); + + const ogImage = document.createElement('meta'); + ogImage.setAttribute('property', 'og:image'); + ogImage.setAttribute('content', imageUrl); + document.head.appendChild(ogImage); + + const twitterImage = document.createElement('meta'); + twitterImage.setAttribute('name', 'twitter:image'); + twitterImage.setAttribute('content', imageUrl); + document.head.appendChild(twitterImage); + } + // Update page and title bar while preserving menu button and brand document.title = `Litruv / ${titleContent}`; document.querySelector('.title-text .page-title').textContent = titleContent;