mirror of
https://github.com/quartz-community/footer.git
synced 2026-07-22 02:50:23 +00:00
fix: display the version in the footer
This commit is contained in:
parent
fd8b652e6e
commit
76e398c9ad
1 changed files with 15 additions and 1 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { readFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import type {
|
||||
QuartzComponent,
|
||||
QuartzComponentConstructor,
|
||||
|
|
@ -6,11 +8,22 @@ import type {
|
|||
import { i18n } from "../i18n";
|
||||
import style from "./styles/footer.scss";
|
||||
|
||||
function getQuartzVersion(): string {
|
||||
try {
|
||||
const pkg = JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf-8"));
|
||||
return pkg.version ?? "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export interface FooterOptions {
|
||||
links: Record<string, string>;
|
||||
}
|
||||
|
||||
export default ((opts?: FooterOptions) => {
|
||||
const version = getQuartzVersion();
|
||||
|
||||
const Footer: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
||||
const year = new Date().getFullYear();
|
||||
const links = opts?.links ?? [];
|
||||
|
|
@ -18,7 +31,8 @@ export default ((opts?: FooterOptions) => {
|
|||
<footer class={`${displayClass ?? ""}`}>
|
||||
<p>
|
||||
{i18n(cfg?.locale ?? "en-US").components.footer.createdWith}{" "}
|
||||
<a href="https://quartz.jzhao.xyz/">Quartz</a> © {year}
|
||||
<a href="https://quartz.jzhao.xyz/">Quartz{version ? ` v${version}` : ""}</a> ©{" "}
|
||||
{year}
|
||||
</p>
|
||||
<ul>
|
||||
{Object.entries(links).map(([text, link]) => (
|
||||
|
|
|
|||
Loading…
Reference in a new issue