Skip to content

Commit

Permalink
Adding the index pages, the query for the artists.json file, ArtistIt…
Browse files Browse the repository at this point in the history
…em component
  • Loading branch information
Mirko authored and moekify committed Mar 21, 2020
1 parent 283ecc4 commit e4f875d
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/components/UI/ArtistItem.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script>
export let artist;
</script>

<style lang="scss">
h3 {
text-align: center;
}
.image img {
object-fit: cover;
}
.column {
padding: 5rem;
}
</style>

<a
rel="prefetch"
href="/artists/{artist.id}"
class="column is-one-quarter-desktop is-one-third-tablet">
<div>
<figure class="image is-square">
<img
class="is-rounded"
src={artist.imageUrls}
alt="{artist.name} Picture" />
</figure>
<h3>{artist.name}</h3>
</div>
</a>
12 changes: 12 additions & 0 deletions src/routes/_layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@
<svelte:window bind:scrollY={y} bind:innerHeight={winHeight} />

<Nav {segment} />
<<<<<<< HEAD
<progress value={progress} />
=======
<progress value={progress} />

<div bind:clientHeight={docHeight}>

>>>>>>> Adding the index pages, the query for the artists.json file, ArtistItem component

<div bind:clientHeight={docHeight}>

Expand All @@ -61,3 +68,8 @@
<Footer />
</div>

<<<<<<< HEAD
=======
<Footer />
</div>
>>>>>>> Adding the index pages, the query for the artists.json file, ArtistItem component
24 changes: 24 additions & 0 deletions src/routes/artists/index.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { fetchArtists } from '../../_directus';


export async function get(req, res, next) {
const artists = await fetchArtists();

if (artists !== null) {
res.setHeader('Content-Type', 'application/json');
res.end(
JSON.stringify(
artists.map(artist => ({
id: artist.id,
name: artist.artist_name,
imageUrls: artist.image ? artist.image.data.full_url : "placeholder_artists.jpeg",
location: artist.current_location,
category: artist.type_of_art
}))
)
);
} else {
next();
}
}

29 changes: 28 additions & 1 deletion src/routes/artists/index.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
Artists
<script context="module">
export function preload({ params, query }) {
return this.fetch(`artists.json`)
.then(r => r.json())
.then(artists => {
return { artists };
});
}
</script>

<script>
import ArtistItem from "../../components/UI/ArtistItem.svelte";
export let artists;
</script>

<style lang="scss">
</style>

<svelte:head>
<title>Artists</title>
</svelte:head>

<div class="columns is-multiline">
{#each artists as artist}
<ArtistItem {artist} />
{/each}
</div>
Binary file added static/placeholder_artists.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e4f875d

Please # to comment.