1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 02:25:09 +00:00

Link to latest commit in web footer

This commit is contained in:
Brenden Matthews 2024-04-24 16:02:35 -04:00
parent 224c5ebd72
commit 4c2969778b
2 changed files with 34 additions and 10 deletions

View File

@ -1,9 +1,10 @@
import getConfig from 'next/config'
import CopyleftIcon from './CopyleftIcon'
import Link from 'next/link'
const Footer: React.FunctionComponent = () => {
const { publicRuntimeConfig } = getConfig()
const { modifiedDate, modifiedYear } = publicRuntimeConfig
const { modifiedDate, modifiedYear, gitHash } = publicRuntimeConfig
return (
<div className="max-w-3xl mx-auto flex py-4 items-center">
<div className="px-2 lg:px-4">
@ -13,6 +14,17 @@ const Footer: React.FunctionComponent = () => {
<p>
{modifiedYear} Conky developers, updated{' '}
{new Date(modifiedDate).toLocaleString()} UTC
{gitHash && (
<span>
{' '}
<Link
target="_blank"
href={`https://github.com/brndnmtthws/conky/commit/${gitHash}`}
>
{`(${gitHash})`}
</Link>
</span>
)}
</p>
</div>
</div>

View File

@ -1,13 +1,25 @@
// @ts-check
import { spawn } from 'child_process'
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
publicRuntimeConfig: {
modifiedDate: new Date().toISOString(),
modifiedYear: new Date().getFullYear(),
},
const config = async (_phase, { _defaultConfig }) => {
const gitHash = await new Promise((resolve) => {
const git = spawn('git', ['rev-parse', '--short', 'HEAD'])
git.stdout.on('data', (data) => {
resolve(data.toString().trim())
})
})
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
publicRuntimeConfig: {
modifiedDate: new Date().toISOString(),
modifiedYear: new Date().getFullYear(),
gitHash,
},
}
return nextConfig
}
export default nextConfig
export default config