-
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
17 changed files
with
167 additions
and
110 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
jobs: | ||
build_site: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 'latest' | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: build | ||
env: | ||
BASE_PATH: '/' | ||
run: | | ||
bun run build | ||
touch build/.nojekyll | ||
- name: Upload Artifacts | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
# this should match the `pages` option in your adapter-static options | ||
path: 'build/' | ||
|
||
deploy: | ||
needs: build_site | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
pages: write | ||
id-token: write | ||
|
||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
steps: | ||
- name: Deploy | ||
id: deployment | ||
uses: actions/deploy-pages@v1 |
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
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,46 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export interface Resource { | ||
title: string; | ||
summary: string; | ||
comment: string; | ||
subject: string; | ||
grade: string; | ||
school: string; | ||
file_name: string; | ||
year: string; | ||
} | ||
|
||
export interface Database { | ||
subjects: string[]; | ||
resources: Resource[]; | ||
} | ||
|
||
const db: Database = { subjects: [], resources: [] }; | ||
|
||
function importFiles(directoryPath: string) { | ||
const items = fs.readdirSync(directoryPath, { withFileTypes: true }); | ||
|
||
items.forEach((item) => { | ||
const fullPath = path.join(directoryPath, item.name); | ||
if (item.isDirectory()) { | ||
importFiles(fullPath); | ||
} else if (path.extname(item.name) === '.json') { | ||
const fileData = fs.readFileSync(fullPath, 'utf8'); | ||
const resource: Resource = JSON.parse(fileData); | ||
|
||
if (!db.subjects.includes(resource.subject)) { | ||
db.subjects.push(resource.subject); | ||
} | ||
|
||
db.resources.push(resource); | ||
} | ||
}); | ||
} | ||
|
||
importFiles('static/files'); | ||
|
||
fs.writeFile('src/lib/data.json', JSON.stringify(db), (err) => { | ||
if (err) throw err; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,42 @@ | ||
import type { Database, Resource } from './init'; | ||
|
||
// links | ||
export const DiscordURL = 'https://discord.com/invite/nWd8yZ4HWY'; | ||
export const InstagramURL = 'https://www.instagram.com/schulenimchaos/'; | ||
export const GithubURL = 'https://github.com/schulen-im-chaos'; | ||
|
||
// helper sorting function | ||
export function resourcesBySubjectAndGradeMap( | ||
db: Database, | ||
subjectName: string, | ||
query: string | ||
): { [key: string]: Resource[] } { | ||
const filteredResources: { [key: string]: Resource[] } = {}; | ||
query = query.toLowerCase(); | ||
|
||
for (const resource of db.resources) { | ||
if (resource.subject === subjectName) { | ||
if (!query) { | ||
filteredResources[resource.grade] = [ | ||
...(filteredResources[resource.grade] || []), | ||
resource | ||
]; | ||
} else { | ||
if ( | ||
resource.grade.toLowerCase().includes(query) || | ||
resource.title.toLowerCase().includes(query) || | ||
resource.school.toLowerCase().includes(query) || | ||
resource.year.toLowerCase().includes(query) || | ||
resource.summary.toLowerCase().includes(query) | ||
) { | ||
filteredResources[resource.grade] = [ | ||
...(filteredResources[resource.grade] || []), | ||
resource | ||
]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return filteredResources; | ||
} |
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,2 +1 @@ | ||
export const prerender = false; | ||
export const ssr = false; | ||
export const prerender = true; |
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
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
This file was deleted.
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
This file was deleted.
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,15 @@ | ||
import { resourcesBySubjectAndGradeMap } from '$lib/utils'; | ||
import db from '$lib/data.json'; | ||
|
||
export const prerender = false; | ||
|
||
export async function load({ params, url }) { | ||
return { | ||
resources: resourcesBySubjectAndGradeMap( | ||
db, | ||
params.subject, | ||
url.searchParams.get('query') || '' | ||
), | ||
subject: params.subject | ||
}; | ||
} |
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