-
-
Notifications
You must be signed in to change notification settings - Fork 341
Migrate to Astro 5 content layer API #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
60416c0
045ed06
0fc8243
1b90683
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||
import { defineCollection, z } from 'astro:content'; | ||||
import { glob } from 'astro/loaders'; | ||||
|
||||
const blog = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/blog' }), | ||||
}); | ||||
|
||||
const community = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/community' }), | ||||
}); | ||||
|
||||
const download = defineCollection({ | ||||
loader: glob({ | ||||
pattern: '**/[^_]*.{md,mdx}', | ||||
base: './src/content/download', | ||||
}), | ||||
}); | ||||
|
||||
const explore = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/explore' }), | ||||
}); | ||||
|
||||
const landing = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/landing' }), | ||||
}); | ||||
|
||||
const landingFeatures = defineCollection({ | ||||
loader: glob({ | ||||
pattern: '**/[^_]*.{md,mdx}', | ||||
base: './src/content/landing-features', | ||||
}), | ||||
}); | ||||
|
||||
const learningManuals = defineCollection({ | ||||
loader: glob({ | ||||
pattern: '**/[^_]*.{md,mdx}', | ||||
base: './src/content/learning-manuals', | ||||
}), | ||||
}); | ||||
|
||||
const menus = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/menus' }), | ||||
}); | ||||
|
||||
// TODO get `research` from astro collection instead of hardcoded json | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like research is using this json inside the astro file nixos-homepage/src/pages/research.astro Line 227 in c0b1510
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, lets tackle this in the PR you mentioned since it does not hurt content collection migration right now |
||||
|
||||
const sponsors = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/sponsors' }), | ||||
}); | ||||
|
||||
const teams = defineCollection({ | ||||
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/teams' }), | ||||
}); | ||||
|
||||
export const collections = { | ||||
blog, | ||||
community, | ||||
download, | ||||
explore, | ||||
landing, | ||||
landingFeatures, | ||||
learningManuals, | ||||
menus, | ||||
sponsors, | ||||
teams, | ||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ import Layout from '../layouts/Layout.astro'; | |
const meetups = await getEntry('community', 'meetups'); | ||
const teams = await getCollection('teams'); | ||
|
||
teams.sort((a, b) => a.id.localeCompare(b.id)); | ||
|
||
const nixcons = [ | ||
{ | ||
title: 'NixCon 2024 - Berlin', | ||
|
@@ -422,7 +424,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg'; | |
teams.map((team) => ( | ||
<li class="flex grow basis-72 flex-col items-center gap-2 text-center text-white md:items-start md:text-left [&>a]:inline-block"> | ||
<img | ||
src={`/images/teams/${team.slug.split('_')[1]}.svg`} | ||
src={`/images/teams/${team.id.split('_')[1]}.svg`} | ||
alt={`${team.data.name} Logo`} | ||
class="h-24" | ||
/> | ||
|
@@ -432,7 +434,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg'; | |
</p> | ||
<Button | ||
color="green" | ||
href={'/community/teams/' + team.slug.split('_')[1]} | ||
href={'/community/teams/' + team.id.split('_')[1]} | ||
> | ||
Read more | ||
</Button> | ||
|
@@ -461,9 +463,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg'; | |
<ul class="mx-auto mt-2 list-disc pl-8 md:w-72 md:pl-10"> | ||
{ | ||
teams | ||
.filter( | ||
(team) => team.slug.split('_')[1] === 'foundation-board', | ||
)[0] | ||
.find((team) => team.id.split('_')[1] === 'foundation-board') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small refactor to use |
||
.data.members.map((member) => ( | ||
<li class="mb-1"> | ||
{member.name} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we glob every directory on md,mdx,yaml or is this fine? it might be annoying in the future if we add a new filetype to a collection and forget to edit this config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can fix it then. At the end of the day this prevents devs from inserting incompatible file types without implementation on the rendering side.