Skip to content

Commit d814874

Browse files
committed
Fixes to the build
1 parent e39ae71 commit d814874

File tree

7 files changed

+49
-8
lines changed

7 files changed

+49
-8
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ repos:
3939
- id: typos
4040
args: []
4141

42+
- repo: local
43+
hooks:
44+
- id: nextjs-lint
45+
name: Next.js Lint
46+
entry: bash -c 'cd catalog && npm run lint'
47+
language: system
48+
files: '^catalog/'
49+
types_or: [javascript, jsx, ts, tsx]
50+
pass_filenames: false
51+
4252
ci:
4353
autofix_commit_msg: |
4454
[pre-commit.ci] Add auto fixes from pre-commit.com hooks

catalog/app/layout.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Metadata } from "next";
22
import Script from "next/script";
33
import "./globals.css";
44

5+
const basePath = process.env.NEXT_PUBLIC_BASE_PATH === 'true' ? '/implementation-catalog' : '';
6+
57
export const metadata: Metadata = {
68
title: "Vector Institute Implementation Catalog",
79
description: "A curated collection of high-quality AI implementations developed by researchers and engineers at the Vector Institute",
@@ -12,6 +14,9 @@ export const metadata: Metadata = {
1214
description: "A curated collection of high-quality AI implementations",
1315
type: "website",
1416
},
17+
icons: {
18+
icon: `${basePath}/vector-logo.svg`,
19+
},
1520
};
1621

1722
export default function RootLayout({
@@ -21,13 +26,11 @@ export default function RootLayout({
2126
}>) {
2227
return (
2328
<html lang="en">
24-
<head>
25-
<link rel="icon" href="/vector-logo.svg" type="image/svg+xml" />
26-
</head>
29+
<head />
2730
<body className="antialiased">
2831
{children}
2932
{/* Pagefind UI - loads after static build */}
30-
<Script src="/_pagefind/pagefind-ui.js" strategy="afterInteractive" />
33+
<Script src={`${basePath}/_pagefind/pagefind-ui.js`} strategy="afterInteractive" />
3134
</body>
3235
</html>
3336
);

catalog/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import FilterTabs from "@/components/filter-tabs";
77
import RepositoryCard from "@/components/repository-card";
88
import SearchBar from "@/components/search-bar";
99
import type { RepositoryType, RepositoryData } from "@/types/repository";
10+
import { getAssetPath } from "@/lib/utils";
1011

1112
// Import the data at build time
1213
import repositoryData from "@/public/data/repositories.json";
@@ -95,7 +96,7 @@ export default function Home() {
9596
<div className="max-w-7xl mx-auto px-4 text-center">
9697
<div className="mb-4 flex justify-center">
9798
<Image
98-
src="/vector-logo.svg"
99+
src={getAssetPath("vector-logo.svg")}
99100
alt="Vector Institute"
100101
width={120}
101102
height={48}

catalog/components/hero.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { motion } from "framer-motion";
44
import { ArrowDown, TrendingUp, Layers } from "lucide-react";
55
import Image from "next/image";
6+
import { getAssetPath } from "@/lib/utils";
67

78
interface HeroProps {
89
totalImplementations: number;
@@ -127,7 +128,7 @@ export default function Hero({ totalImplementations, yearsOfResearch }: HeroProp
127128
className="mb-8 flex justify-center"
128129
>
129130
<Image
130-
src="/vector-logo.svg"
131+
src={getAssetPath("vector-logo.svg")}
131132
alt="Vector Institute"
132133
width={140}
133134
height={46}

catalog/components/search-bar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useEffect } from "react";
4+
import { getBasePath } from "@/lib/utils";
45

56
declare global {
67
interface Window {
@@ -10,6 +11,7 @@ declare global {
1011
showImages: boolean;
1112
excerptLength: number;
1213
placeholder: string;
14+
basePath?: string;
1315
}) => void;
1416
}
1517
}
@@ -18,14 +20,15 @@ export default function SearchBar() {
1820
useEffect(() => {
1921
// Find the hero-search container and render Pagefind there
2022
const heroSearchContainer = document.getElementById("hero-search");
23+
const basePath = getBasePath();
2124

2225
if (typeof window !== "undefined" && heroSearchContainer) {
2326
// Load Pagefind CSS dynamically
2427
const loadPagefindCSS = () => {
2528
if (!document.querySelector('link[href*="pagefind-ui.css"]')) {
2629
const link = document.createElement("link");
2730
link.rel = "stylesheet";
28-
link.href = "/_pagefind/pagefind-ui.css";
31+
link.href = `${basePath}/_pagefind/pagefind-ui.css`;
2932
document.head.appendChild(link);
3033
}
3134
};
@@ -41,6 +44,7 @@ export default function SearchBar() {
4144
showImages: false,
4245
excerptLength: 15,
4346
placeholder: "Search implementations...",
47+
basePath: basePath || undefined,
4448
});
4549
}
4650
}, 100);

catalog/lib/utils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Get the base path for the application
3+
* Returns '/implementation-catalog' in production (GitHub Pages)
4+
* Returns '' in development
5+
*/
6+
export function getBasePath(): string {
7+
return process.env.NEXT_PUBLIC_BASE_PATH === 'true' ? '/implementation-catalog' : '';
8+
}
9+
10+
/**
11+
* Get the full path for an asset, accounting for base path
12+
* @param path - The path to the asset (e.g., '/vector-logo.svg')
13+
* @returns The full path with base path prepended if in production
14+
*/
15+
export function getAssetPath(path: string): string {
16+
const basePath = getBasePath();
17+
// Remove leading slash from path if present to avoid double slashes
18+
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
19+
return basePath ? `${basePath}/${cleanPath}` : `/${cleanPath}`;
20+
}

catalog/scripts/generate-search-pages.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
* Each page includes all searchable content (implementations, datasets) and redirects to the main page.
66
*/
77

8+
// eslint-disable-next-line @typescript-eslint/no-require-imports
89
const fs = require('fs');
10+
// eslint-disable-next-line @typescript-eslint/no-require-imports
911
const path = require('path');
1012

1113
// Read the repositories data
@@ -24,7 +26,7 @@ if (!fs.existsSync(outputDir)) {
2426
const basePath = process.env.NEXT_PUBLIC_BASE_PATH === 'true' ? '/implementation-catalog' : '';
2527

2628
// Generate a page for each repository
27-
repositoryData.repositories.forEach((repo, index) => {
29+
repositoryData.repositories.forEach((repo) => {
2830
const repoSlug = repo.name.toLowerCase().replace(/[^a-z0-9]+/g, '-');
2931
const repoDir = path.join(outputDir, repoSlug);
3032

0 commit comments

Comments
 (0)