Skip to content

Commit

Permalink
Merge pull request #7 from noskofficial/fix/build
Browse files Browse the repository at this point in the history
feat: add devDependencies for js-yaml and node types
  • Loading branch information
mukezhz authored Oct 5, 2024
2 parents 46c047a + 975bbdd commit a0b997c
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 25 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"tailwindcss": "^3.4.13",
"typescript": "^5.5.4"
},
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72",
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.7.4"
}
}
26 changes: 13 additions & 13 deletions src/components/shared/TopNavigation.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { loadConfig } from '../../utils/loadconfig.js';
import { loadConfig } from '../../utils/loadconfig';
const config = loadConfig();
const menu = config.menu;
Expand All @@ -15,7 +15,7 @@ const menu = config.menu;
</button>
</div>

<ul id="navLinks" class="flex flex-col md:flex-row md:justify-center md:flex-1 md:space-x-6 mt-2 md:mt-0">
<ul id="navLinks" class="flex flex-col md:flex-row md:justify-center md:items-center md:flex-1 md:space-x-6 mt-2 md:mt-0">
{menu.main.map(item => (
<li class="relative">
{item.subMenu ? (
Expand All @@ -31,17 +31,17 @@ const menu = config.menu;
{subItem.inRange ? (
<nav class="w-64">
<ul class="grid grid-cols-2 gap-2">
{Array.from({ length: (subItem.rangeEnd ?? new Date().getFullYear()) - subItem.rangeStart + 1 }, (_, i) => subItem.rangeStart + i).map(range => (
<li key={range}>
<a href={subItem.link.replace('{range}', range)} class="text-gray-700 hover:text-blue-600">{range}</a>
{Array.from({ length: (subItem.rangeEnd ?? new Date().getFullYear()) - subItem.rangeStart! + 1 }, (_, i) => subItem.rangeStart! + i).map(range => (
<li>
<a href={subItem.link.replace('{range}', `${range}`)} class="text-gray-700 hover:text-blue-600">{range}</a>
</li>
))}
</ul>
</nav>
) : (
<ul>
{subItem.items && subItem.items.map(department => (
<li key={department}>
<li>
<a href={subItem.link.replace('{item}', department)} class="text-gray-700 hover:text-blue-600">{department}</a>
</li>
))}
Expand All @@ -51,7 +51,7 @@ const menu = config.menu;
) : (
<ul>
{subItem.items && subItem.items.map(department => (
<li key={department}>
<li>
<a href={subItem.link.replace('{item}', department)} class="text-gray-700 hover:text-blue-600">{department}</a>
</li>
))}
Expand All @@ -71,7 +71,7 @@ const menu = config.menu;

<div class="flex items-center mt-2 md:mt-0 md:ml-auto">
<div class="relative flex-1">
<input type="text" placeholder="Search..." class="border rounded-md p-2 w-full focus:outline-none focus:ring focus:border-blue-300" />
<input type="text" placeholder="Search..."class="border rounded-md p-2 w-full focus:outline-none focus:ring focus:border-blue-300" />
<button class="absolute right-0 top-0 mt-2 mr-2">
<svg class="w-5 h-5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h-1l-4-4H7a5 5 0 100 10h10a5 5 0 000-10H15l4 4"></path>
Expand All @@ -82,11 +82,11 @@ const menu = config.menu;
</div>
</nav>

<script client:load>
const menuToggle = document.getElementById('menuToggle');
const navLinks = document.getElementById('navLinks');
const directoryToggle = document.getElementById('directoryToggle');
const megaMenu = document.getElementById('megaMenu');
<script>
const menuToggle = document.getElementById('menuToggle')!;
const navLinks = document.getElementById('navLinks')!;
const directoryToggle = document.getElementById('directoryToggle')!;
const megaMenu = document.getElementById('megaMenu')!;

menuToggle.addEventListener('click', () => {
navLinks.classList.toggle('hidden');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/profiles/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import TwoColLayout from "../../components/layout/TwoColLayout.astro";
import TwoColLayout from "../../layout/TwoColLayout.astro";
---

Expand Down
9 changes: 0 additions & 9 deletions src/utils/loadconfig.js

This file was deleted.

34 changes: 34 additions & 0 deletions src/utils/loadconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from "fs";
import path from "path";
import yaml from "js-yaml";

export interface Root {
menu: Menu
}

export interface Menu {
title: string
main: Main[]
}

export interface Main {
title: string
link?: string
subMenu?: SubMenu[]
}

export interface SubMenu {
category: string
inRange?: boolean
rangeStart?: number
rangeEnd?: number
link: string
items?: string[]
}


export function loadConfig(): Root {
const filePath = path.resolve("./config.yml");
const fileContents = fs.readFileSync(filePath, "utf8");
return yaml.load(fileContents) as Root;
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "astro/tsconfigs/strict"
"extends": "astro/tsconfigs/strict",
"include": ["src/**/*.ts", "src/**/*.tsx"],
}
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,11 @@
dependencies:
"@types/unist" "*"

"@types/js-yaml@^4.0.9":
version "4.0.9"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2"
integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==

"@types/mdast@^4.0.0":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-4.0.4.tgz#7ccf72edd2f1aa7dd3437e180c64373585804dd6"
Expand All @@ -829,6 +834,13 @@
dependencies:
"@types/unist" "*"

"@types/node@^22.7.4":
version "22.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc"
integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==
dependencies:
undici-types "~6.19.2"

"@types/unist@*", "@types/unist@^3.0.0":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.3.tgz#acaab0f919ce69cce629c2d4ed2eb4adc1b6c20c"
Expand Down Expand Up @@ -3432,6 +3444,11 @@ typescript@^5.5.4:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==

undici-types@~6.19.2:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

unified@^11.0.0, unified@^11.0.4, unified@^11.0.5:
version "11.0.5"
resolved "https://registry.yarnpkg.com/unified/-/unified-11.0.5.tgz#f66677610a5c0a9ee90cab2b8d4d66037026d9e1"
Expand Down

0 comments on commit a0b997c

Please sign in to comment.