-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
194 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
.vitepress/cache | ||
|
||
public/cover | ||
|
||
database | ||
# Logs | ||
logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import download from 'image-downloader' | ||
|
||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import fs from 'node:fs' | ||
|
||
|
||
export async function downloadCovers(records = [], { | ||
field = 'cover', | ||
folder = 'cover', | ||
query = 'quality=70&width=800&height=800&format=webp' | ||
} = options) { | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
let dest = path.resolve(dirname, '../public/', folder) | ||
if (!fs.existsSync(dest)) { | ||
fs.mkdirSync(dest, { recursive: true }); | ||
} | ||
const urls = [] | ||
|
||
for (let r of records) { | ||
if (!r?.[field]) continue | ||
let filePath = path.resolve(dest, `${r.slug}.webp`) | ||
if (fs.existsSync(filePath)) continue | ||
console.log(r, r[field]) | ||
let url = `https://db.chromatone.center/assets/${r[field]?.id}?${query}&download` | ||
urls.push({ url, slug: r.slug, dest: filePath }) | ||
} | ||
|
||
|
||
const chunkSize = 5; | ||
for (let i = 0; i < urls.length; i += chunkSize) { | ||
const chunk = urls.slice(i, i + chunkSize); | ||
await Promise.all(chunk.map(rec => { | ||
console.log('downloading file:', rec.slug + '.webp') | ||
return download.image(rec) | ||
})); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script setup> | ||
import {onMounted} from 'vue' | ||
import { useData } from 'vitepress' | ||
const { params } = useData() | ||
onMounted(()=>{ | ||
console.log('mounted') | ||
}) | ||
</script> | ||
|
||
<template lang='pug'> | ||
.flex.flex-col.rounded-lg.overflow-hidden.shadow.bg-light-700.mx-2.max-w-45ch | ||
.flex.flex-col.p-2(:style="{ backgroundColor: $params?.color }") | ||
img(:src="`/cover/${$params?.slug}.webp`") | ||
.p-4.text-lg.bg-light-200.flex.flex-col.gap-2 | ||
.text-4xl {{ $params?.title }} | ||
.p-0 {{ $params?.description }} | ||
|
||
|
||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script setup> | ||
import { data } from './projects.data' | ||
</script> | ||
|
||
<template lang='pug'> | ||
.text-2xl.flex.p-2.mt-8(style="flex: 1 0 100%") | ||
h1.font-bold Projects | ||
.flex-1 | ||
.op-80 {{ data.length }} | ||
slot | ||
.flex.flex-wrap.gap-4.p-4 | ||
a.items-stretch.bg-light-800.text-xl.no-underline.rounded.overflow-hidden.shadow.hover-brightness-110.flex.flex-wrap( | ||
style="flex: 1 1 400px" | ||
:href="`/${project?.slug}/`" | ||
v-for="project in data" :key="project" | ||
) | ||
.p-0(style="flex: 1 1 180px") | ||
img( :src="`/cover/${project?.slug}.webp`") | ||
.flex.flex-col.gap-2(style="flex: 1 1 250px") | ||
.p-2.flex.flex-col.gap-2 | ||
.text-sm.flex.flex-wrap.gap-1 | ||
.op-60 {{ project?.start_date }} − {{ project?.end_date || 'Present' }} | ||
.flex-1 | ||
|
||
.text-2xl.font-bold {{ project?.title }} | ||
|
||
.text-sm.op-80 {{ project?.description }} | ||
.flex-1 | ||
.text-md.op-40.bg-dark-300.bg-op-40.flex.items-center(v-if="project?.events.length") Events: {{ project?.events.length }} | ||
|
||
|
||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
dynamic: true | ||
title: Projects | ||
--- | ||
|
||
<script setup> | ||
import ProjectPage from '../ProjectPage.vue' | ||
</script> | ||
|
||
<ProjectPage > | ||
|
||
</ProjectPage> | ||
|
||
<!-- @content --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createDirectus, rest, readItems, staticToken } from '@directus/sdk' | ||
|
||
export default { | ||
async paths() { | ||
let projects = [] | ||
|
||
try { | ||
projects = await createDirectus('https://db.chromatone.center/').with(staticToken('HDqt6uvSbGyYnL4tdi3jntEHOj7i_aYp')).with(rest()).request(readItems('projects', { | ||
fields: ['*', 'cover.id', 'program.title'] | ||
})) | ||
} catch (e) { | ||
console.log('Projects paths not loaded', e) | ||
} | ||
|
||
return projects.map(project => { | ||
let content = project.content | ||
delete project.content | ||
return { | ||
params: { | ||
...project | ||
}, | ||
content | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createDirectus, rest, readItems, staticToken } from '@directus/sdk' | ||
import { downloadCovers } from './.vitepress/downloadCovers' | ||
|
||
export default { | ||
async load() { | ||
let projects = [] | ||
try { | ||
projects = await createDirectus('https://db.chromatone.center/') | ||
.with(staticToken('HDqt6uvSbGyYnL4tdi3jntEHOj7i_aYp')) | ||
.with(rest()) | ||
.request(readItems('projects', { | ||
sort: '-start_date', | ||
fields: ['*', 'title', 'description', 'start_date', 'end_date', 'field', 'program.title', 'cover.id'] | ||
})) | ||
} catch (e) { | ||
console.log('Projects fetch failed') | ||
} | ||
|
||
await downloadCovers(projects, { | ||
folder: 'cover' | ||
}) | ||
|
||
return projects | ||
} | ||
} |