-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate OpenGraph images with Satori Add OpenGraph tags Move to Picture instead of Image from astro:assets Remove the '...' in truncated MDX Add an x-cloak to avoid flicker on the mobile language selector
- Loading branch information
Timothée Rebours
committed
Feb 29, 2024
1 parent
f8e8698
commit 92d2625
Showing
34 changed files
with
1,826 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ pnpm-debug.log* | |
|
||
# Specific to the project | ||
public_to_encrypt/* | ||
public/og/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { AstroIntegration } from 'astro' | ||
import { fileURLToPath } from 'node:url' | ||
import { opendir, copyFile, mkdir } from 'node:fs/promises' | ||
import { existsSync } from 'node:fs' | ||
import AstroConfig, { PWD } from '../astro.config.ts' | ||
import path from 'node:path' | ||
|
||
export default function (): AstroIntegration { | ||
return { | ||
name: 'MoveOGImages', | ||
hooks: { | ||
'astro:build:done': async ({ dir, logger: _logger }) => { | ||
const logger = _logger.fork('MoveOGImages') | ||
const inputDir = await opendir(path.resolve(PWD, AstroConfig.publicDir ?? 'public', 'og')) | ||
const outputDirPath = path.resolve(fileURLToPath(dir), 'og') | ||
if (!existsSync(outputDirPath)) { | ||
logger.info('Creating directory /og') | ||
await mkdir(outputDirPath) | ||
} | ||
for await (const entry of inputDir) { | ||
if (entry.isFile()) { | ||
logger.info(`Copying /og/${entry.name}`) | ||
await copyFile(path.resolve(entry.path, entry.name), path.resolve(outputDirPath, entry.name)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.