mirror of
https://github.com/jaronpate/folio.git
synced 2026-10-19 01:07:39 +00:00
hide projects too
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
isExternalHref,
|
isExternalHref,
|
||||||
projectEntryHref,
|
projectEntryHref,
|
||||||
projectOgImage,
|
projectOgImage,
|
||||||
|
sortProjects,
|
||||||
} from '~/utils/projects';
|
} from '~/utils/projects';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -30,7 +31,7 @@ const folderName = computed(
|
|||||||
const { data } = await useAsyncData(
|
const { data } = await useAsyncData(
|
||||||
() => `projects:${route.path}`,
|
() => `projects:${route.path}`,
|
||||||
async () => {
|
async () => {
|
||||||
const all = await queryCollection('projects').order('title', 'ASC').all();
|
const all = await queryCollection('projects').all();
|
||||||
const visible = all.filter((page) => import.meta.dev || !page.hidden);
|
const visible = all.filter((page) => import.meta.dev || !page.hidden);
|
||||||
const project = visible.find(
|
const project = visible.find(
|
||||||
(page) =>
|
(page) =>
|
||||||
@@ -44,7 +45,9 @@ const { data } = await useAsyncData(
|
|||||||
const prefix = contentPath.value.endsWith('/')
|
const prefix = contentPath.value.endsWith('/')
|
||||||
? contentPath.value
|
? contentPath.value
|
||||||
: `${contentPath.value}/`;
|
: `${contentPath.value}/`;
|
||||||
const pages = visible.filter((page) => page.path.startsWith(prefix));
|
const pages = sortProjects(
|
||||||
|
visible.filter((page) => page.path.startsWith(prefix)),
|
||||||
|
);
|
||||||
|
|
||||||
if (!pages.length) return null;
|
if (!pages.length) return null;
|
||||||
return { kind: 'folder' as const, project: null, pages };
|
return { kind: 'folder' as const, project: null, pages };
|
||||||
|
|||||||
@@ -6,11 +6,16 @@ import {
|
|||||||
personId,
|
personId,
|
||||||
websiteId,
|
websiteId,
|
||||||
} from '~/utils/site';
|
} from '~/utils/site';
|
||||||
import { isExternalHref, projectEntryHref } from '~/utils/projects';
|
import {
|
||||||
|
isExternalHref,
|
||||||
|
projectEntryHref,
|
||||||
|
sortProjects,
|
||||||
|
} from '~/utils/projects';
|
||||||
|
|
||||||
const { data: pages } = await useAsyncData('project-pages', async () => {
|
const { data: pages } = await useAsyncData('project-pages', async () => {
|
||||||
const all = await queryCollection('projects').order('title', 'ASC').all();
|
const all = await queryCollection('projects').all();
|
||||||
return import.meta.dev ? all : all.filter((page) => !page.hidden);
|
const visible = all.filter((page) => !page.hidden);
|
||||||
|
return sortProjects(visible);
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectsUrl = `${SITE_URL}/projects`;
|
const projectsUrl = `${SITE_URL}/projects`;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
} from '~/utils/fonts';
|
} from '~/utils/fonts';
|
||||||
import { BG_THEMES } from '~/utils/themes';
|
import { BG_THEMES } from '~/utils/themes';
|
||||||
import { SITE_URL } from '~/utils/site';
|
import { SITE_URL } from '~/utils/site';
|
||||||
|
import { sortProjects } from '~/utils/projects';
|
||||||
|
|
||||||
const TOKEN_NAMES = [
|
const TOKEN_NAMES = [
|
||||||
'--bg',
|
'--bg',
|
||||||
@@ -51,8 +52,8 @@ const { data: writingPages } = await useAsyncData(
|
|||||||
const { data: projectPages } = await useAsyncData(
|
const { data: projectPages } = await useAsyncData(
|
||||||
'styleguide-projects',
|
'styleguide-projects',
|
||||||
async () => {
|
async () => {
|
||||||
const all = await queryCollection('projects').order('title', 'ASC').all();
|
const all = await queryCollection('projects').all();
|
||||||
return all.filter((page) => !page.hidden).slice(0, 4);
|
return sortProjects(all.filter((page) => !page.hidden)).slice(0, 4);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
|
|
||||||
const { data: pages } = await useAsyncData('writing-pages', async () => {
|
const { data: pages } = await useAsyncData('writing-pages', async () => {
|
||||||
const all = await queryCollection('writing').order('date', 'DESC').all();
|
const all = await queryCollection('writing').order('date', 'DESC').all();
|
||||||
return import.meta.dev ? all : all.filter((page) => !page.hidden);
|
return all.filter((page) => !page.hidden);
|
||||||
});
|
});
|
||||||
|
|
||||||
const writingUrl = `${SITE_URL}/writing`;
|
const writingUrl = `${SITE_URL}/writing`;
|
||||||
|
|||||||
@@ -5,6 +5,20 @@ export function projectEntryHref(page: {
|
|||||||
return page.href || `/projects${page.path}`;
|
return page.href || `/projects${page.path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sortProjects<
|
||||||
|
T extends { title: string; date?: Date | string | null },
|
||||||
|
>(pages: T[]) {
|
||||||
|
return [...pages].sort((a, b) => {
|
||||||
|
const aTime = a.date ? new Date(a.date).getTime() : Number.NaN;
|
||||||
|
const bTime = b.date ? new Date(b.date).getTime() : Number.NaN;
|
||||||
|
const aHasDate = !Number.isNaN(aTime);
|
||||||
|
const bHasDate = !Number.isNaN(bTime);
|
||||||
|
if (aHasDate && bHasDate && aTime !== bTime) return bTime - aTime;
|
||||||
|
if (aHasDate !== bHasDate) return aHasDate ? -1 : 1;
|
||||||
|
return a.title.localeCompare(b.title);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function isExternalHref(href: string) {
|
export function isExternalHref(href: string) {
|
||||||
return /^https?:\/\//i.test(href);
|
return /^https?:\/\//i.test(href);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default defineContentConfig({
|
|||||||
description: z.string(),
|
description: z.string(),
|
||||||
href: z.string().optional(),
|
href: z.string().optional(),
|
||||||
hidden: z.boolean().optional(),
|
hidden: z.boolean().optional(),
|
||||||
|
date: z.coerce.date().optional(),
|
||||||
image: z.string().optional(),
|
image: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
title: Mystwright
|
title: Mystwright
|
||||||
description: An AI-driven mystery detective game. Generate, investigate, solve.
|
description: An AI-driven mystery detective game. Generate, investigate, solve.
|
||||||
href: https://mystwright.com/
|
href: https://mystwright.com/
|
||||||
|
hidden: true
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user