|
| 1 | +import Breadcrumbs from '../../components/Breadcrumbs'; |
| 2 | +import { NextSeo } from 'next-seo'; |
| 3 | +import { getReleases } from '../../github/releases'; |
| 4 | + |
| 5 | +<NextSeo |
| 6 | + title="X-Ray Integration Changelog" |
| 7 | + description="Latest updates and releases for the Bref X-Ray integration package" |
| 8 | +/> |
| 9 | + |
| 10 | +export async function getStaticProps() { |
| 11 | + const releases = await getReleases('brefphp/xray-integration', 20); |
| 12 | + |
| 13 | + // Format dates consistently on the server |
| 14 | + const formattedReleases = releases ? releases.map(release => { |
| 15 | + const date = new Date(release.publishedAt); |
| 16 | + const months = ['January', 'February', 'March', 'April', 'May', 'June', |
| 17 | + 'July', 'August', 'September', 'October', 'November', 'December']; |
| 18 | + return { |
| 19 | + ...release, |
| 20 | + formattedDate: `${months[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}` |
| 21 | + }; |
| 22 | + }) : []; |
| 23 | + |
| 24 | + return { |
| 25 | + props: { |
| 26 | + releases: formattedReleases |
| 27 | + }, |
| 28 | + // The page will be considered as stale and regenerated every hour |
| 29 | + revalidate: 3600 |
| 30 | + }; |
| 31 | +} |
| 32 | + |
| 33 | +export default function ChangelogPage({ releases }) { |
| 34 | + function renderMarkdown(markdown) { |
| 35 | + // Remove Full Changelog links since the repo is private (handle both bold and non-bold versions) |
| 36 | + let cleaned = markdown |
| 37 | + .replace(/\*\*Full Changelog\*\*: https:\/\/github\.com\/brefphp\/xray-integration\/compare\/[^\s\n]+/g, '') |
| 38 | + .replace(/Full Changelog: https:\/\/github\.com\/brefphp\/xray-integration\/compare\/[^\s\n]+/g, ''); |
| 39 | + |
| 40 | + // Simple markdown to HTML conversion |
| 41 | + let html = cleaned |
| 42 | + // Headers |
| 43 | + .replace(/^#### (.+)$/gm, '<h4>$1</h4>') |
| 44 | + .replace(/^### (.+)$/gm, '<h3>$1</h3>') |
| 45 | + .replace(/^## (.+)$/gm, '<h2>$1</h2>') |
| 46 | + .replace(/^# (.+)$/gm, '<h1>$1</h1>') |
| 47 | + // Bold and italic |
| 48 | + .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>') |
| 49 | + .replace(/\*([^*]+)\*/g, '<em>$1</em>') |
| 50 | + // Code blocks and inline code |
| 51 | + .replace(/```[\s\S]*?```/g, (match) => { |
| 52 | + const code = match.slice(3, -3).trim(); |
| 53 | + return `<pre><code>${code}</code></pre>`; |
| 54 | + }) |
| 55 | + .replace(/`([^`]+)`/g, '<code>$1</code>') |
| 56 | + // Links |
| 57 | + .replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>') |
| 58 | + // Line breaks and paragraphs |
| 59 | + .replace(/\n\n/g, '</p><p>') |
| 60 | + .replace(/\n/g, '<br/>') |
| 61 | + // Lists |
| 62 | + .replace(/^\* (.+)$/gm, '<li>$1</li>') |
| 63 | + .replace(/^- (.+)$/gm, '<li>$1</li>') |
| 64 | + .replace(/(<li>.*<\/li>)/s, '<ul>$1</ul>'); |
| 65 | + |
| 66 | + // Wrap in paragraph tags if not already wrapped |
| 67 | + if (!html.startsWith('<')) { |
| 68 | + html = '<p>' + html + '</p>'; |
| 69 | + } |
| 70 | + |
| 71 | + return html; |
| 72 | + } |
| 73 | + |
| 74 | + if (!releases || releases.length === 0) { |
| 75 | + return ( |
| 76 | + <div> |
| 77 | + <Breadcrumbs pages={[ |
| 78 | + { name: 'X-Ray', href: '/xray' }, |
| 79 | + { name: 'Documentation', href: '/xray/docs' }, |
| 80 | + { name: 'Changelog', href: '/xray/changelog' }, |
| 81 | + ]} /> |
| 82 | + <h1 className="text-4xl font-bold tracking-tight text-gray-900 mt-8">X-Ray Integration Changelog</h1> |
| 83 | + <div className="mt-6 text-lg leading-8 text-gray-600"> |
| 84 | + Latest updates and releases for the Bref X-Ray integration package. |
| 85 | + </div> |
| 86 | + <div className="mt-12 text-center"> |
| 87 | + <p className="text-gray-500">No releases found or unable to fetch releases.</p> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + ); |
| 91 | + } |
| 92 | + |
| 93 | + return ( |
| 94 | + <div> |
| 95 | + <Breadcrumbs pages={[ |
| 96 | + { name: 'X-Ray', href: '/xray' }, |
| 97 | + { name: 'Documentation', href: '/xray/docs' }, |
| 98 | + { name: 'Changelog', href: '/xray/changelog' }, |
| 99 | + ]} /> |
| 100 | + <h1 className="text-4xl font-bold tracking-tight text-gray-900 mt-8">X-Ray Integration Changelog</h1> |
| 101 | + <div className="mt-6 text-lg leading-8 text-gray-600"> |
| 102 | + Latest updates and releases for the Bref X-Ray integration package. |
| 103 | + </div> |
| 104 | + <div className="mt-8"> |
| 105 | + {releases.map(release => ( |
| 106 | + <div key={release.id} className="mb-12"> |
| 107 | + <h2 className="text-2xl font-bold mb-2"> |
| 108 | + {release.name || release.tagName} |
| 109 | + </h2> |
| 110 | + <p className="text-sm text-gray-500 mb-4"> |
| 111 | + {release.formattedDate} |
| 112 | + </p> |
| 113 | + <div className="prose prose-sm max-w-none" |
| 114 | + dangerouslySetInnerHTML={{ __html: renderMarkdown(release.body || 'No release notes provided.') }} /> |
| 115 | + </div> |
| 116 | + ))} |
| 117 | + </div> |
| 118 | + </div> |
| 119 | + ); |
| 120 | +} |
0 commit comments