Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/PageMeta.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Head from 'next/head';
import { type PropsWithChildren } from 'react';

const site = {
title: 'React Native Directory',
Expand All @@ -7,17 +8,18 @@ const site = {

const BASE_OG_URL = 'https://og.expo.dev/?theme=rnd';

type PageMetaProps = {
type PageMetaProps = PropsWithChildren<{
title?: string;
description?: string;
path?: string;
searchQuery?: string | string[];
};
}>;

export default function PageMeta({
title,
searchQuery,
path,
children,
description = site.description,
}: PageMetaProps) {
const pageTitle = `${title ? title + ' β€’ ' : ''}${site.title}`;
Expand Down Expand Up @@ -45,6 +47,8 @@ export default function PageMeta({
<meta name="twitter:image" content={socialImage} />

<link rel="canonical" href={`https://reactnative.directory${path ? `/${path}` : ''}`} />

{children}
</Head>
);
}
5 changes: 3 additions & 2 deletions pages/rss/added.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export async function getServerSideProps(ctx: NextPageContext) {
return { notFound: true };
}

res.setHeader('Content-Type', 'text/xml; charset=utf-8');
res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=300');

try {
const response = await ssrFetch(
'/libraries',
Expand All @@ -35,8 +38,6 @@ export async function getServerSideProps(ctx: NextPageContext) {
res.write('Error: Cannot generate RSS feed');
}

res.setHeader('Content-Type', 'text/xml; charset=utf-8');
res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=300');
res.end();

return { props: {} };
Expand Down
5 changes: 3 additions & 2 deletions pages/rss/updated.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export async function getServerSideProps(ctx: NextPageContext) {
return { notFound: true };
}

res.setHeader('Content-Type', 'text/xml; charset=utf-8');
res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=300');

try {
const response = await ssrFetch(
'/libraries',
Expand All @@ -35,8 +38,6 @@ export async function getServerSideProps(ctx: NextPageContext) {
res.write('Error: Cannot generate RSS feed');
}

res.setHeader('Content-Type', 'text/xml; charset=utf-8');
res.setHeader('Cache-Control', 'public, s-maxage=600, stale-while-revalidate=300');
res.end();

return { props: {} };
Expand Down
15 changes: 14 additions & 1 deletion scenes/HomeScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ export default function HomeScene({

return (
<>
<PageMeta />
<PageMeta>
<link
rel="alternate"
type="application/rss+xml"
title="RSS: Recently added libraries"
href="/rss/added.xml"
/>
<link
rel="alternate"
type="application/rss+xml"
title="RSS: Recently updated libraries"
href="/rss/updated.xml"
/>
</PageMeta>
<Navigation
title="React Native packages registry"
description="Browse thousands of open-source packages and find the best ones for your current or next project.">
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-and-score-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const DATASET: LibraryDataEntryType[] = USE_DEBUG_REPOS ? debugGithubRepos : git
const DATA_PATH = path.resolve('assets', 'data.json');
const CHECK_DATA_PATH = path.resolve('assets', 'check-data.json');

const CHUNK_SIZE = 25;
const CHUNK_SIZE = 20;
const NPM_STATS_CHUNK_SIZE = 10;
const SLEEP_TIME = 250;
const SLEEP_TIME = 500;

const invalidRepos: string[] = [];
const mismatchedRepos: LibraryType[] = [];
Expand Down
22 changes: 15 additions & 7 deletions scripts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ export async function makeGraphqlQuery(query: string, variables = {}) {
variables,
}),
});
try {
return await result.json();
} catch (error: unknown) {
console.error('GitHub GraphQL response parse failed!', {
if (result.ok) {
try {
return await result.json();
} catch (error: unknown) {
console.error('GitHub GraphQL response parse failed!', {
status: result.status,
statusText: result.statusText,
error: error instanceof Error ? error.message : String(error),
});
throw error;
}
} else {
console.error('GitHub GraphQL invalid response!', {
status: result.status,
statusText: result.statusText,
error: error instanceof Error ? error.message : String(error),
body: result.body,
body: result?.body ? await result.text() : undefined,
});
throw error;
throw new Error(`GitHub GraphQL invalid response: ${result.status}`);
}
}

Expand Down