Skip to content

Commit 91917ed

Browse files
committed
Resolved merge conflict
2 parents 0e8a0c5 + 3bb9b19 commit 91917ed

File tree

15 files changed

+177
-51
lines changed

15 files changed

+177
-51
lines changed

src/components/Hero.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
});
1515
</script>
1616

17-
<div class="hero" style="background: {accentColor}">
17+
<div class="hero pt-hero" style="background: {accentColor}">
1818
<div class="container px-5 py-28">
1919
<div class="flex-col-reverse md:flex-row flex items-center gap-10 columns-2">
2020
<div class="md:w-1/2 md:p-5">

src/components/MenuTagsBlog.svelte

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script>
2+
export let activeTag;
3+
export let handleTags;
4+
export let tags;
5+
</script>
6+
7+
{#each tags as tag}
8+
<a
9+
href={null}
10+
class={activeTag === tag ? 'text-cmxgreen' : null}
11+
on:click={() => handleTags(tag)}
12+
>
13+
{tag.toUpperCase()}
14+
</a>
15+
{/each}
16+
17+
<style>
18+
a {
19+
display: inline-block;
20+
text-transform: uppercase;
21+
font-weight: 700;
22+
line-height: 2.5;
23+
}
24+
a:not(:last-child) {
25+
padding-right: 15px;
26+
}
27+
a:hover {
28+
cursor: pointer;
29+
text-decoration: underline;
30+
}
31+
</style>

src/components/Navbar.svelte

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script>
2+
import { principalMenuStore } from "@/store";
3+
24
function closeHambMenu() {
35
document.getElementById('hamburger-menu').classList.toggle('hidden');
46
}
@@ -12,9 +14,9 @@
1214
{name: "Comunidad", url: "/comunidad"},
1315
{name: "Recursos", url: "/recursos"},
1416
{name: "Blog", url: "/blog"},
15-
];
17+
];
1618
</script>
17-
<nav class="w-full py-5">
19+
<nav class="absolute w-full py-5 max-lg:bg-white">
1820
<div class="flex container m-auto items-center px-5">
1921
<a href="/">
2022
<span class="sr-only">Codeando México</span>
@@ -25,7 +27,14 @@
2527

2628
<ul class="gap-5 hidden lg:flex">
2729
{#each menuItems as item }
28-
<li><a class="hover:underline hover:gray-800 uppercase font-bold" href="{item.url}">{item.name}</a></li>
30+
<li>
31+
<a
32+
class={`hover:underline hover:gray-800 uppercase font-bold ${$principalMenuStore.urlActive.includes(item.url) ? $principalMenuStore.color : ''}`.trim()}
33+
href="{item.url}"
34+
>
35+
{item.name}
36+
</a>
37+
</li>
2938
{/each}
3039
</ul>
3140

@@ -43,7 +52,7 @@
4352
<div id="hamburger-menu" class="lg:hidden hidden" role="dialog" aria-modal="true">
4453
<!-- Background backdrop, show/hide based on slide-over state. -->
4554
<div class="fixed inset-0 z-10"></div>
46-
<div class="fixed inset-y-0 right-0 z-10 w-full overflow-y-auto bg-white px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10">
55+
<div class="fixed inset-y-0 right-0 z-40 w-full overflow-y-auto bg-white px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10">
4756
<div class="flex items-center justify-between">
4857
<a href="/" class="-m-1.5 p-1.5">
4958
<span class="sr-only">Codeando México</span>
@@ -62,7 +71,7 @@
6271
{#each menuItems as item}
6372
<div class="mx-3 block px-3 py-2 divide-y divide-gray-500 hover:bg-gray-50">
6473

65-
<a href="{item.url}" class="-text-base font-semibold leading-7 text-gray-900 uppercase ">{item.name}</a>
74+
<a href="{item.url}" class={`-text-base font-semibold leading-7 uppercase ${$principalMenuStore.urlActive.includes(item.url) ? 'text-cmxgreen' : 'text-gray-900'}`}>{item.name}</a>
6675
</div>
6776
{/each}
6877
</div>

src/lib/menuSelectorUpdater.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { onDestroy } from "svelte";
2+
import { principalMenuStore } from "@/store";
3+
4+
export function updateMenuSelector({url = '/', color = 'text-white'}) {
5+
principalMenuStore.update(data => {
6+
data.urlActive = url
7+
data.color = color
8+
9+
return data
10+
});
11+
12+
onDestroy(() => {
13+
principalMenuStore.update(data => {
14+
data.urlActive = ''
15+
data.color = ''
16+
17+
return data
18+
});
19+
});
20+
}

src/routes/acerca/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script>
2+
import { updateMenuSelector } from '@/lib/menuSelectorUpdater';
23
import Hero from '@/components/Hero.svelte';
34
import IconTextAction from '@/components/IconTextAction.svelte';
5+
6+
updateMenuSelector({url: '/acerca'})
47
</script>
58

69
<Hero accentColor="#0073F4" title="Acerca de" subtitle="Somos una organización sin fines de lucro, basada en una comunidad abierta." image="/acerca.png"/>

src/routes/aviso-de-privacidad/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const { aviso } = data
55
</script>
66

7-
<div id="aviso" class="container mx-auto py-20">
7+
<div id="aviso" class="container mx-auto my-20 pt-hero">
88
<div class="w-10/12 p-5 mx-auto w-1/2 mx-auto bg-[url('/grid-bg.png')] bg-slate-200 prose" style={`box-shadow: 7px 7px 1px black;`}>
99
{@html aviso.content}
1010
<p>Ultima actualización: <HumanDate date={aviso.date_updated}/></p>

src/routes/blog/+page.server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import client from '$lib/apiClient'
2+
import { getFlatArrayUnrepeated } from '$lib/utilities';
23
import { readSingleton, readItems } from '@directus/sdk'
34

45
export async function load() {
@@ -20,9 +21,13 @@ export async function load() {
2021
sort: ['-date_published'],
2122
}))
2223

24+
const tags = getFlatArrayUnrepeated(posts);
25+
tags.unshift('todos');
26+
2327
return {
2428
blog,
25-
posts
29+
posts,
30+
tags,
2631
}
2732
}
2833

src/routes/blog/+page.svelte

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
<script>
2+
import { updateMenuSelector } from '@/lib/menuSelectorUpdater.js';
23
import ArticleCard from "@/components/Cards/ArticleCard.svelte";
34
import BlogHero from "@/components/BlogHero.svelte";
5+
import MenuTagsBlog from "@/components/MenuTagsBlog.svelte";
46
export let data
5-
const { blog, posts } = data
7+
const { blog, posts, tags } = data
8+
let filteredPosts = [...posts]
9+
let activeTag = "todos"
10+
11+
const handleTags = (tag = "") => {
12+
tag = tag.toLocaleLowerCase()
13+
activeTag = tag
14+
filteredPosts = tag === "todos"
15+
? [...posts]
16+
: posts.filter(post => post.tags.map((tagItem = '') => tagItem.toLowerCase()).includes(tag))
17+
}
18+
19+
updateMenuSelector({url: '/blog', color: 'text-cmxgreen'})
620
</script>
7-
<div class="container my-20 mx-auto">
21+
<div class="container my-20 pt-hero mx-auto">
822

923
<div class="container m-auto px-3">
1024
<div class="my-7">
11-
<h1 class="text-5xl text-cmxblack font-bold">Blog</h1>
25+
<h1 class="text-5xl text-cmxgreen font-bold">Blog</h1>
1226
</div>
1327
<BlogHero
1428
slug={blog.highlight_post.slug}
@@ -20,9 +34,16 @@
2034
content={blog.highlight_post.content}
2135
/>
2236
</div>
37+
<div class="container mx-auto px-3 pt-16 pb-12 text-center">
38+
<MenuTagsBlog
39+
activeTag={activeTag}
40+
handleTags={handleTags}
41+
tags={tags}
42+
/>
43+
</div>
2344
<div class="container m-auto p-3">
2445
<div class="md:grid grid-cols-3 gap-5">
25-
{#each posts as post}
46+
{#each filteredPosts as post}
2647
<ArticleCard
2748
slug={post.slug}
2849
title={post.title}

src/routes/blog/[slug]/+page.svelte

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
<script>
2+
import { browser } from '$app/environment';
3+
import { updateMenuSelector } from '@/lib/menuSelectorUpdater.js';
4+
import { onDestroy } from 'svelte';
25
import ReadingTime from '@/components/ReadingTime.svelte';
36
import HumanDate from '@/components/HumanDate.svelte';
4-
export let data
5-
const { post } = data
7+
export let data;
8+
const { post } = data;
9+
let title = '';
10+
11+
updateMenuSelector({url: '/blog', color: 'text-cmxgreen'})
12+
if (browser) { title = document.title }
13+
14+
onDestroy(() => {
15+
if (browser) { document.title = title }
16+
})
617
</script>
718

819
<svelte:head>
@@ -13,8 +24,7 @@
1324
<meta property="og:image" content={`https://content.codeandomexico.org/assets/${post.post_image}`} />
1425
</svelte:head>
1526

16-
<section class="my-10">
17-
27+
<section class="my-10 pt-hero">
1828
<div class="container m-auto max-w-prose my-8">
1929
<h1 class="text-5xl font-black my-8">{post.title}</h1>
2030
{#if post.authors}
@@ -32,5 +42,4 @@
3242
<div class="container m-auto p-3 prose prose-blockquote:text-2xl prose-blockquote:border-green-400">
3343
<p class="prose text-lg">{@html post.content}</p>
3444
</div>
35-
3645
</section>

src/routes/comunidad/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<script>
2+
import { updateMenuSelector } from '@/lib/menuSelectorUpdater.js';
23
import Hero from "@/components/Hero.svelte";
34
import GetInvolvedCard from "@/components/Cards/GetInvolvedCard.svelte";
45
import CommunityCard from "@/components/Cards/CommunityCard.svelte";
56
// import CollaboratorCard from "@/components/Cards/CollaboratorCard.svelte";
67
export let data
78
const { comunidad } = data
9+
10+
updateMenuSelector({url: '/comunidad'})
811
</script>
912

1013
<Hero accentColor="#F2D301" title="Involúcrate en la comunidad" subtitle="Somos una comunidad abierta que construye tecnología para el bien común." image="/comunidad.png" />

0 commit comments

Comments
 (0)