seo
This commit is contained in:
@@ -784,15 +784,15 @@ async function runAllTests() {
|
||||
() => test('Download API endpoint exists', () => {
|
||||
const apiPath = path.join(process.cwd(), 'src/pages/api/download-zip.ts');
|
||||
const content = fs.readFileSync(apiPath, 'utf8');
|
||||
|
||||
|
||||
if (!content.includes('export const POST')) {
|
||||
throw new Error('API endpoint missing POST handler');
|
||||
}
|
||||
|
||||
|
||||
if (!content.includes('export const GET')) {
|
||||
throw new Error('API endpoint missing GET handler');
|
||||
}
|
||||
|
||||
|
||||
if (!content.includes('FileExampleManager')) {
|
||||
throw new Error('API endpoint does not use FileExampleManager');
|
||||
}
|
||||
@@ -883,21 +883,104 @@ async function runAllTests() {
|
||||
'src/components/FileExample.astro',
|
||||
'src/components/FileExamplesList.astro'
|
||||
];
|
||||
|
||||
|
||||
for (const component of components) {
|
||||
const componentPath = path.join(process.cwd(), component);
|
||||
if (!fs.existsSync(componentPath)) {
|
||||
throw new Error(`Component ${component} does not exist`);
|
||||
}
|
||||
|
||||
|
||||
const content = fs.readFileSync(componentPath, 'utf8');
|
||||
|
||||
|
||||
// Check for common issues
|
||||
if (content.includes('children.trim') && !content.includes('children?.trim')) {
|
||||
throw new Error(`${component}: uses children.trim without null check`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
() => test('OG image API route exists', () => {
|
||||
const ogApiPath = path.join(process.cwd(), 'src/pages/api/og/[...slug].svg.ts');
|
||||
|
||||
if (!fs.existsSync(ogApiPath)) {
|
||||
throw new Error('OG image API route does not exist');
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(ogApiPath, 'utf8');
|
||||
|
||||
if (!content.includes('export async function getStaticPaths')) {
|
||||
throw new Error('OG API route missing getStaticPaths function');
|
||||
}
|
||||
|
||||
if (!content.includes('export const GET')) {
|
||||
throw new Error('OG API route missing GET handler');
|
||||
}
|
||||
|
||||
if (!content.includes('blogPosts')) {
|
||||
throw new Error('OG API route does not use blogPosts data');
|
||||
}
|
||||
}),
|
||||
|
||||
() => test('OG images are generated in dist', () => {
|
||||
const ogDir = path.join(process.cwd(), 'dist/api/og');
|
||||
|
||||
if (!fs.existsSync(ogDir)) {
|
||||
throw new Error('OG images directory does not exist in dist');
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(ogDir);
|
||||
const expectedFiles = ['home.svg', 'first-note.svg', 'debugging-tips.svg', 'architecture-patterns.svg', 'docker-deployment.svg', 'embed-demo.svg'];
|
||||
|
||||
for (const expectedFile of expectedFiles) {
|
||||
if (!files.includes(expectedFile)) {
|
||||
throw new Error(`Missing OG image: ${expectedFile}`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
() => test('OG images have correct content', () => {
|
||||
const ogDir = path.join(process.cwd(), 'dist/api/og');
|
||||
const homeOgPath = path.join(ogDir, 'home.svg');
|
||||
|
||||
if (!fs.existsSync(homeOgPath)) {
|
||||
throw new Error('Home OG image does not exist');
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(homeOgPath, 'utf8');
|
||||
|
||||
if (!content.includes('<svg')) {
|
||||
throw new Error('OG image is not valid SVG');
|
||||
}
|
||||
|
||||
if (!content.includes('Marc Mintel')) {
|
||||
throw new Error('OG image does not contain expected title');
|
||||
}
|
||||
|
||||
if (!content.includes('mintel.me')) {
|
||||
throw new Error('OG image does not contain site branding');
|
||||
}
|
||||
|
||||
if (!content.includes('system-ui')) {
|
||||
throw new Error('OG image does not use system fonts');
|
||||
}
|
||||
}),
|
||||
|
||||
() => test('BaseLayout uses OG images', () => {
|
||||
const baseLayoutPath = path.join(process.cwd(), 'src/layouts/BaseLayout.astro');
|
||||
const content = fs.readFileSync(baseLayoutPath, 'utf8');
|
||||
|
||||
if (!content.includes('ogImage')) {
|
||||
throw new Error('BaseLayout does not set og:image meta tag');
|
||||
}
|
||||
|
||||
if (!content.includes('twitterImage')) {
|
||||
throw new Error('BaseLayout does not set twitter:image meta tag');
|
||||
}
|
||||
|
||||
if (!content.includes('/api/og/')) {
|
||||
throw new Error('BaseLayout does not use OG image API route');
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
// Run all sync tests
|
||||
|
||||
Reference in New Issue
Block a user