-
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.
Merge pull request #22 from BohdanOne/21-init-connect-cloudinary
feat: add peak cover images
- Loading branch information
Showing
23 changed files
with
570 additions
and
49 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
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,24 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
// Read the covers.json file | ||
const coversData = JSON.parse(fs.readFileSync('src/lib/data/covers.json', 'utf8')); | ||
|
||
// Get all JSON files in the /data directory | ||
const dataDir = 'src/lib/data'; | ||
const files = fs.readdirSync(dataDir); | ||
|
||
files.forEach((file) => { | ||
if (path.extname(file) === '.json') { | ||
const filePath = path.join(dataDir, file); | ||
const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); | ||
|
||
// If the data has a matching key in coversData, add the covers property | ||
if (coversData[data.slug]) { | ||
data.covers = coversData[data.slug]; | ||
|
||
// Write the updated data back to the file | ||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); | ||
} | ||
} | ||
}); |
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 @@ | ||
<script lang="ts"> | ||
import type { CoverBreakpoint } from '$lib/types'; | ||
export let covers: { [key in CoverBreakpoint]: [string, string] }; | ||
export let small = false; | ||
</script> | ||
|
||
<picture> | ||
<source media="(max-width: 375px)" srcset="{covers.s[0]} 1x, {covers.s[1]} 2x" /> | ||
{#if small} | ||
<source media="(max-width: 640px)" srcset="{covers.xs[0]} 1x, {covers.xs[1]} 2x" /> | ||
<source srcset="{covers.l[0]} 1x, {covers.l[1]} 2x" /> | ||
<img | ||
class="hover:filter-[brightness(50%)] transition-all duration-200 ease-in-out w-full" | ||
src={covers.xs[1]} | ||
alt="" | ||
loading="lazy" | ||
/> | ||
{:else} | ||
<source media="(max-width: 640px)" srcset="{covers.l[0]} 1x, {covers.l[1]} 2x" /> | ||
<source media="(max-width: 768px)" srcset="{covers.s[0]} 1x, {covers.s[1]} 2x" /> | ||
<source srcset="{covers.m[0]} 1x, {covers.m[1]} 2x" /> | ||
<img src={covers.m[1]} alt="" loading="lazy" /> | ||
{/if} | ||
</picture> |
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,20 @@ | ||
<script lang="ts"> | ||
import type { Peak } from '$lib/types'; | ||
import PeakInfoLine from './PeakInfoLine.svelte'; | ||
export let peak: Peak; | ||
</script> | ||
|
||
<div class="flex flex-col gap-4"> | ||
<div> | ||
<h2 class="font-bold mb-4 border-b-4 border-red-600"> | ||
{peak.name} | ||
</h2> | ||
<PeakInfoLine lineTitle="Pasmo górskie" lineValue={peak.mountainRange} /> | ||
<PeakInfoLine lineTitle="Wysokość" lineValue={`${peak.elevation}m n.p.m.`} /> | ||
|
||
{#if peak.visitDate} | ||
<PeakInfoLine lineTitle="Wejście w dniu" lineValue={peak.visitDate} /> | ||
{/if} | ||
</div> | ||
</div> |
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,9 @@ | ||
<script lang="ts"> | ||
export let lineTitle: string; | ||
export let lineValue: string; | ||
</script> | ||
|
||
<p class="mb-2 flex flex-wrap gap-4 justify-between max-w-md border-b-2 border-red-300"> | ||
<span>{lineTitle}: </span> | ||
<span class="font-bold">{lineValue}</span> | ||
</p> |
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,29 @@ | ||
<script lang="ts"> | ||
import type { Peak } from '$lib/types'; | ||
import PeakCover from './PeakCover.svelte'; | ||
export let peaks: Peak[]; | ||
</script> | ||
|
||
<section class="py-6"> | ||
<h2 class="mb-4">Odwiedzone szczyty</h2> | ||
<div class="grid gap-4 max-w-full"> | ||
{#each peaks as peak} | ||
{#if peak.covers} | ||
<a | ||
class="relative font-bold text-white [text-shadow:_0_1px_rgb(0_0_0_/_40%)]" | ||
href={`/${peak.slug}`} | ||
> | ||
<PeakCover covers={peak.covers} small /> | ||
<h3 class="absolute bottom-2 left-2">{peak.name}</h3> | ||
</a> | ||
{/if} | ||
{/each} | ||
</div> | ||
</section> | ||
|
||
<style> | ||
div { | ||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); | ||
} | ||
</style> |
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
Oops, something went wrong.