mirror of
https://github.com/Xevion/utsa-handbook.git
synced 2025-12-07 07:16:52 -06:00
Last modified git-based remark plugin, site URL
This commit is contained in:
@@ -3,10 +3,16 @@ import mdx from '@astrojs/mdx';
|
|||||||
import sitemap from '@astrojs/sitemap';
|
import sitemap from '@astrojs/sitemap';
|
||||||
import tailwind from "@astrojs/tailwind";
|
import tailwind from "@astrojs/tailwind";
|
||||||
|
|
||||||
|
import { remarkModifiedTime } from './src/plugins/remark-last-modified';
|
||||||
import react from "@astrojs/react";
|
import react from "@astrojs/react";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'https://example.com',
|
markdown: {
|
||||||
|
remarkPlugins: [
|
||||||
|
remarkModifiedTime
|
||||||
|
]
|
||||||
|
},
|
||||||
|
site: 'https://handbook.xevion.dev',
|
||||||
integrations: [mdx(), sitemap(), tailwind(), react()]
|
integrations: [mdx(), sitemap(), tailwind(), react()]
|
||||||
});
|
});
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
"@types/react": "^18.2.64",
|
"@types/react": "^18.2.64",
|
||||||
"@types/react-dom": "^18.2.21",
|
"@types/react-dom": "^18.2.21",
|
||||||
"astro": "^4.4.15",
|
"astro": "^4.4.15",
|
||||||
|
"dayjs": "^1.11.10",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"sass": "^1.71.1",
|
"sass": "^1.71.1",
|
||||||
|
|||||||
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
@@ -35,6 +35,9 @@ dependencies:
|
|||||||
astro:
|
astro:
|
||||||
specifier: ^4.4.15
|
specifier: ^4.4.15
|
||||||
version: 4.4.15(@types/node@20.11.25)(sass@1.71.1)(typescript@5.4.2)
|
version: 4.4.15(@types/node@20.11.25)(sass@1.71.1)(typescript@5.4.2)
|
||||||
|
dayjs:
|
||||||
|
specifier: ^1.11.10
|
||||||
|
version: 1.11.10
|
||||||
react:
|
react:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0
|
version: 18.2.0
|
||||||
@@ -1665,6 +1668,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/dayjs@1.11.10:
|
||||||
|
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/debug@4.3.4:
|
/debug@4.3.4:
|
||||||
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||||
engines: {node: '>=6.0'}
|
engines: {node: '>=6.0'}
|
||||||
|
|||||||
18
src/plugins/remark-last-modified.ts
Normal file
18
src/plugins/remark-last-modified.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import type { RemarkPlugins } from "astro";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
|
export const remarkModifiedTime: RemarkPlugins[number] = () => {
|
||||||
|
return function (_, file) {
|
||||||
|
const filepath = file.history[0];
|
||||||
|
const command = `git log -1 --pretty="format:%cI" "${filepath}"`;
|
||||||
|
let result = execSync(command).toString();
|
||||||
|
|
||||||
|
// File is not in git yet
|
||||||
|
if (result === "") {
|
||||||
|
result = new Date().toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
file.data.astro.frontmatter.lastModified = result;
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user