mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-07-24 02:36:07 +10:00
more testing
This commit is contained in:
11
index.html
11
index.html
@@ -15,14 +15,6 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-tomorrow.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-tomorrow.min.css">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css">
|
||||||
|
|
||||||
<script>
|
|
||||||
var link = document.createElement('meta');
|
|
||||||
link.setAttribute('property', 'twitter:title');
|
|
||||||
link.content = "Litruv Documentation Test OG Tags";
|
|
||||||
document.getElementsByTagName('head')[0].appendChild(link);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -62,7 +54,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="github-link">
|
<div class="github-link">
|
||||||
<a href="https://github.com/litruv/Docs-Viewer" target="_blank" title="Docs Viewer GitHub">
|
<a href="https://github.com/litruv/docs" target="_blank" title="Docs Viewer GitHub">
|
||||||
<i class="fab fa-github"></i> Docs Viewer
|
<i class="fab fa-github"></i> Docs Viewer
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,7 +69,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked@4.3.0/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked@4.3.0/marked.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// Fallback in case CDN fails
|
|
||||||
window.addEventListener('error', function(e) {
|
window.addEventListener('error', function(e) {
|
||||||
if (e.target.src && e.target.src.includes('marked.min.js')) {
|
if (e.target.src && e.target.src.includes('marked.min.js')) {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
|
|||||||
14
index.js
14
index.js
@@ -280,6 +280,20 @@ async function loadDocument(path) {
|
|||||||
document.title = `Litruv / ${titleContent}`;
|
document.title = `Litruv / ${titleContent}`;
|
||||||
document.querySelector('.title-text .page-title').textContent = titleContent;
|
document.querySelector('.title-text .page-title').textContent = titleContent;
|
||||||
|
|
||||||
|
// Update Twitter meta tags dynamically
|
||||||
|
document.querySelector('meta[name="twitter:title"]').setAttribute('content', titleContent);
|
||||||
|
document.querySelector('meta[name="twitter:description"]').setAttribute('content', metadata.description || `Documentation for ${titleContent}`);
|
||||||
|
if (metadata.image) {
|
||||||
|
const imageUrl = `${window.location.origin}${window.location.pathname}${basePath}/images/${metadata.image}`;
|
||||||
|
let twitterImageMeta = document.querySelector('meta[name="twitter:image"]');
|
||||||
|
if (!twitterImageMeta) {
|
||||||
|
twitterImageMeta = document.createElement('meta');
|
||||||
|
twitterImageMeta.setAttribute('name', 'twitter:image');
|
||||||
|
document.head.appendChild(twitterImageMeta);
|
||||||
|
}
|
||||||
|
twitterImageMeta.setAttribute('content', imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
documentContent.className = 'markdown-content';
|
documentContent.className = 'markdown-content';
|
||||||
documentContent.innerHTML = marked.parse(finalContent);
|
documentContent.innerHTML = marked.parse(finalContent);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user