mirror of
https://github.com/thiloho/thiloho.github.io.git
synced 2025-11-22 02:11:35 +01:00
Fix Date component for string from remark
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
export const remarkModifiedTime = () => {
|
export const remarkModifiedTime = () => {
|
||||||
return (tree, file) => {
|
return (file) => {
|
||||||
const filepath = file.history[0];
|
const filepath = file.history[0];
|
||||||
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`);
|
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`);
|
||||||
file.data.astro.frontmatter.lastModified = result.toString();
|
file.data.astro.frontmatter.lastModified = result.toString();
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
@@ -1,17 +1,29 @@
|
|||||||
---
|
---
|
||||||
interface Props {
|
interface Props {
|
||||||
date: Date;
|
date: Date | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { date } = Astro.props;
|
const { date } = Astro.props;
|
||||||
---
|
|
||||||
|
|
||||||
<time datetime={date.toISOString()}>
|
const isStringDate = typeof date === "string";
|
||||||
{
|
const transformedDate = isStringDate ? new Date(date) : date;
|
||||||
date.toLocaleString("en-us", {
|
|
||||||
|
// Create the base options object
|
||||||
|
const localeOptions = {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
})
|
};
|
||||||
|
|
||||||
|
// Conditionally add time options if it's a string date
|
||||||
|
if (isStringDate) {
|
||||||
|
Object.assign(localeOptions, {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
---
|
||||||
|
|
||||||
|
<time datetime={transformedDate.toISOString()}>
|
||||||
|
{transformedDate.toLocaleString("en-us", localeOptions)}
|
||||||
</time>
|
</time>
|
||||||
@@ -28,6 +28,8 @@ There are other great options, such as [FreeBSD](https://www.freebsd.org) and [O
|
|||||||
|
|
||||||
Your main choice here should probably be [GrapheneOS](https://grapheneos.org).
|
Your main choice here should probably be [GrapheneOS](https://grapheneos.org).
|
||||||
|
|
||||||
|
Wikipedia states the following:
|
||||||
|
|
||||||
> GrapheneOS is an open source, privacy and security-focused Android operating system that runs on selected Google Pixel devices, including smartphones, tablets and foldables.
|
> GrapheneOS is an open source, privacy and security-focused Android operating system that runs on selected Google Pixel devices, including smartphones, tablets and foldables.
|
||||||
|
|
||||||
As mentioned in the quote, note that you need a [supported Google Pixel device](https://grapheneos.org/faq#supported-devices) to use GrapheneOS and I would not recommend using any other privacy focused or hardened mobile operating system as they do not come close to its usability while maintaining these aspects.
|
As mentioned in the quote, note that you need a [supported Google Pixel device](https://grapheneos.org/faq#supported-devices) to use GrapheneOS and I would not recommend using any other privacy focused or hardened mobile operating system as they do not come close to its usability while maintaining these aspects.
|
||||||
|
|||||||
Reference in New Issue
Block a user