Skip to content

Commit

Permalink
feat(craigory-dev): add og images for blog posts and presentations
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Aug 25, 2024
1 parent f3db8fc commit 72578db
Show file tree
Hide file tree
Showing 12 changed files with 821 additions and 457 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
- name: Install dependencies
run: npm ci

# We use playwright to generate open graph images
- name: Install Playwright
run: npx playwright install --with-deps

- name: Setup Git User
run: |
git config --global user.name "${GITHUB_ACTOR}"
Expand Down
3 changes: 0 additions & 3 deletions apps/craigory-dev/pages/blog/view/+desc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ import { PageContext } from 'vike/types';

export default (pageContext: PageContext) => {
const blogPost = slugMap[pageContext.routeParams?.slug];

console.log('Returning', blogPost.description);

return blogPost.description;
};
7 changes: 7 additions & 0 deletions apps/craigory-dev/pages/blog/view/+title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { slugMap } from '@new-personal-monorepo/blog-posts';
import { PageContext } from 'vike/types';

export default (pageContext: PageContext) => {
const blogPost = slugMap[pageContext.routeParams?.slug];
return blogPost.title;
};
4 changes: 0 additions & 4 deletions apps/craigory-dev/pages/presentations/view/+config.ts

This file was deleted.

7 changes: 7 additions & 0 deletions apps/craigory-dev/pages/presentations/view/+desc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PRESENTATIONS } from '@new-personal-monorepo/presentations';
import { PageContext } from 'vike/types';

export default (pageContext: PageContext) => {
const presentation = PRESENTATIONS[pageContext.routeParams?.presentation];
return presentation.description;
};
7 changes: 7 additions & 0 deletions apps/craigory-dev/pages/presentations/view/+title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PRESENTATIONS } from '@new-personal-monorepo/presentations';
import { PageContext } from 'vike/types';

export default (pageContext: PageContext) => {
const presentation = PRESENTATIONS[pageContext.routeParams?.presentation];
return presentation.title;
};
6 changes: 5 additions & 1 deletion apps/craigory-dev/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"prepare": {
"executor": "nx:run-commands",
"options": {
"command": "sscli -b https://craigory.dev -r dist/apps/craigory-dev/client -c '**,weekly' 'blog/**,daily'"
"commands": [
"sscli -b https://craigory.dev -r dist/apps/craigory-dev/client -c '**,weekly' 'blog/**,daily'",
"npx vite-node -c tools/vite.config.js tools/generate-open-graph-images.ts"
],
"parallel": true
},
"dependsOn": ["build"],
"cache": true
Expand Down
9 changes: 9 additions & 0 deletions apps/craigory-dev/renderer/+image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { PageContext } from 'vike/types';

export default (pageContext: PageContext) => {
let base = new URL('https://craigory.dev');
if (import.meta.env.PUBLIC_ENV__BASE_URL) {
base = new URL(import.meta.env.PUBLIC_ENV__BASE_URL, base);
}
return new URL(pageContext.urlOriginal + '/og.png', base).href;
};
Loading

0 comments on commit 72578db

Please sign in to comment.