Skip to content

Commit

Permalink
Merge pull request #72 from Linaro/staging
Browse files Browse the repository at this point in the history
Display last edit date from git for games
  • Loading branch information
pcolmer authored May 22, 2024
2 parents 4d045de + 871e6d4 commit d189f7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
on:
pull_request:
pull_request_target:
branches: ["main", "staging"]

env:
NODE_VERSION: "20.x"
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/ProjectLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const title = "Games";
<span class="hidden" data-pagefind-sort="name">{name.toLowerCase()}</span>
<ProjectDetails project={project} type={type} />
<p class="w-full py-6">
Last updated {
import.meta.env.SSR ? (
<i>- not available on private staging site</i>
Report last updated: {
date ? (
dayjs(date).format("DD MMM YYYY")
) : (
dayjs(date.format("YYYY-MM-DD"))
<i>- not available on private staging site</i>
)
}
</p>
Expand Down
9 changes: 6 additions & 3 deletions src/pages/games/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ const reports = await getCollection("user_reports_games", ({ data }: any) => {
type Props = CollectionEntry<"games">;
let project;
if (import.meta.env.SSR) {
if (!import.meta.env.IS_PUBLIC) {
project = await getEntry("games", slug);
} else {
project = Astro.props;
try {
const { stdout } = await execAsync(
`git log -1 --pretty="format:%ci" ${process.cwd()}/src/content/games/${slug}.md`
`git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/games/${project.id}"`
);
if (stdout == "") {
throw new Error(`Failed to retrieve date for ${process.cwd()}/src/content/games/${project.id}`);
}
date = new Date(stdout);
} catch (e) {
throw new Error(`Failed to parse date for ${slug}.md.\n${e}`);
throw new Error(`Failed to parse date for ${project.id}.\n${e}`);
}
}
---
Expand Down

0 comments on commit d189f7e

Please sign in to comment.