#13: Dynamically populate header careers dropdown
All checks were successful
CodyOps Core Builder / build-conteiner (pull_request) Successful in 6m6s
All checks were successful
CodyOps Core Builder / build-conteiner (pull_request) Successful in 6m6s
This commit is contained in:
parent
a716982652
commit
e953cc454e
@ -2,11 +2,13 @@
|
|||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
import Logo from '../../assets/svg/logo.svg';
|
import Logo from '../../assets/svg/logo.svg';
|
||||||
import { getAllCourses, filterCoursesByCloud } from '../../libs/courses';
|
import { getAllCourses, filterCoursesByCloud } from '../../libs/courses';
|
||||||
|
import { getCareers } from '../../libs/careers';
|
||||||
import { slugifyCourse } from '../../utils/text';
|
import { slugifyCourse } from '../../utils/text';
|
||||||
|
|
||||||
const awsCourses = filterCoursesByCloud(getAllCourses(), ['aws']);
|
const awsCourses = filterCoursesByCloud(getAllCourses(), ['aws']);
|
||||||
const gcpCourses = filterCoursesByCloud(getAllCourses(), ['gcp']);
|
const gcpCourses = filterCoursesByCloud(getAllCourses(), ['gcp']);
|
||||||
const azrCourses = filterCoursesByCloud(getAllCourses(), ['azr']);
|
const azrCourses = filterCoursesByCloud(getAllCourses(), ['azr']);
|
||||||
|
const careers = await getCareers();
|
||||||
---
|
---
|
||||||
|
|
||||||
<header id="header" class={`navbar navbar-expand-lg navbar-end navbar-sticky-top navbar-dark root`}>
|
<header id="header" class={`navbar navbar-expand-lg navbar-end navbar-sticky-top navbar-dark root`}>
|
||||||
@ -49,30 +51,17 @@ const azrCourses = filterCoursesByCloud(getAllCourses(), ['azr']);
|
|||||||
aria-labelledby="dropdownSubMenu"
|
aria-labelledby="dropdownSubMenu"
|
||||||
style="min-width: 14rem"
|
style="min-width: 14rem"
|
||||||
>
|
>
|
||||||
|
{careers.map((career: any) => (
|
||||||
<a
|
<a
|
||||||
class="dropdown-item text-white"
|
class="dropdown-item text-white"
|
||||||
id="devops_header"
|
id={career.slug + '_header'}
|
||||||
href=`/carreras/devops/`
|
href={`/carreras/${career.slug}/`}
|
||||||
role="button"
|
role="button"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>DevOps Engineer
|
>
|
||||||
</a>
|
{career.name}
|
||||||
<a
|
|
||||||
class="dropdown-item text-white"
|
|
||||||
id="cloud_header"
|
|
||||||
href=`/carreras/cloudops/`
|
|
||||||
role="button"
|
|
||||||
aria-expanded="false"
|
|
||||||
>Cloud Engineer
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
class="dropdown-item text-white"
|
|
||||||
id="aws_devops_header"
|
|
||||||
href=`/carreras/aws-devops/`
|
|
||||||
role="button"
|
|
||||||
aria-expanded="false"
|
|
||||||
>AWS DevOps
|
|
||||||
</a>
|
</a>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-indicator nav-indicator--blue"></div>
|
<div class="nav-indicator nav-indicator--blue"></div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -3,11 +3,14 @@ import { readItems, type Query } from '@directus/sdk';
|
|||||||
import type { CodyopsCareers, Careers } from '../types/codyops-careers';
|
import type { CodyopsCareers, Careers } from '../types/codyops-careers';
|
||||||
import { sumTimes } from '../utils/time';
|
import { sumTimes } from '../utils/time';
|
||||||
|
|
||||||
|
const isDev = import.meta.env.DEV; // Astro's way to check for development mode
|
||||||
|
|
||||||
export async function getCareers(): Promise<Careers[]> {
|
export async function getCareers(): Promise<Careers[]> {
|
||||||
const careers = await directus.request(
|
const careers = await directus.request(
|
||||||
readItems<CodyopsCareers, 'codyops_careers', Query<CodyopsCareers, Careers>>('codyops_careers', {
|
readItems<CodyopsCareers, 'codyops_careers', Query<CodyopsCareers, Careers>>('codyops_careers', {
|
||||||
fields: [
|
fields: [
|
||||||
'slug',
|
'slug',
|
||||||
|
'status',
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'banner',
|
'banner',
|
||||||
@ -28,6 +31,9 @@ export async function getCareers(): Promise<Careers[]> {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
filter: {
|
||||||
|
status: isDev ? { '_neq': 'archived' } : { '_eq': 'published' }
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user