Skip to content

Commit e290474

Browse files
authored
Tags improvements (#22)
* Tags and URL * Image optimizer * a11y name * Compress file to reduce size
1 parent b986115 commit e290474

File tree

11 files changed

+791
-38
lines changed

11 files changed

+791
-38
lines changed

package-lock.json

Lines changed: 732 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030
"prettier-plugin-tailwindcss": "^0.6.5",
3131
"rehype-slug": "^6.0.0",
3232
"remark-github": "^12.0.0",
33+
"sharp": "^0.33.5",
3334
"svelte": "^4.2.7",
3435
"svelte-carousel": "^1.0.25",
3536
"svelte-check": "^3.6.0",
37+
"svgo": "^3.3.2",
3638
"tailwindcss": "^3.4.4",
3739
"tslib": "^2.4.1",
3840
"typescript": "^5.0.0",
39-
"vite": "^5.0.3"
41+
"vite": "^5.0.3",
42+
"vite-plugin-compression2": "^1.3.3",
43+
"vite-plugin-image-optimizer": "^1.1.8"
4044
},
4145
"type": "module",
4246
"dependencies": {

src/lib/components/blogs/BlogItem.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script lang="ts">
22
import { base } from '$app/paths'
33
import Image from '$lib/components/elements/Image.svelte'
4+
import Tag from '$lib/components/elements/Tag.svelte'
45
import { config } from '$lib/config'
56
import type { Blog } from '$utils/constants'
6-
import Tag from '$lib/components/elements/Tag.svelte'
77
88
export let post: Blog
99
@@ -20,20 +20,19 @@
2020
<Image
2121
src="{base}{post.image ??
2222
'https://placehold.co/100x100/EEA050/white/?text=' + post.title}"
23-
class="max-h-48 w-full rounded-t-xl object-cover object-top xl:max-h-52 {hover &&
24-
'scale-105'}"
23+
class="h-40 w-full rounded-t-xl object-cover object-top md:h-52 {hover && 'scale-105'}"
2524
/>
2625
</div>
2726

28-
<div class="flex h-60 flex-col gap-1 px-5">
27+
<div class="flex h-60 flex-col gap-1 px-2 md:px-5">
2928
<time dateTime={post.date ?? post.date} class="text-arkGray4">
3029
{new Date(post.date).toLocaleDateString(config.locale, {
3130
year: 'numeric',
3231
month: 'long',
3332
day: 'numeric',
3433
})}
3534
</time>
36-
<p class="text-2xl font-extrabold {hover && 'underline'}">
35+
<p class="text-lg font-extrabold md:text-2xl {hover && 'underline'}">
3736
{post.title}
3837
</p>
3938
<div class="">

src/lib/components/layouts/Footer.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
22
import { base } from '$app/paths'
3+
import FooterLogo from '$lib/assets/images/footer-logo.svelte'
34
import { communityList } from '$utils/constants'
45
import Icon from '@iconify/svelte'
5-
import FooterLogo from '$lib/assets/images/footer-logo.svelte'
66
</script>
77

88
<footer class="bg-white px-5 pb-10 pt-40 xl:px-0">
@@ -14,6 +14,7 @@
1414
<div class="grid w-fit grid-cols-4 flex-row gap-3 lg:flex">
1515
{#each communityList as community}
1616
<a
17+
aria-label={community.name}
1718
target="_blank"
1819
href={community.url}
1920
class="flex h-10 w-fit cursor-pointer flex-row items-center gap-4 hover:text-arkOrange"

src/lib/components/sections/Hero.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts">
2-
import Cta from '$lib/components/elements/CTA.svelte'
3-
import Icon from '@iconify/svelte'
4-
import { communityList } from '$utils/constants'
52
import LeftImage from '$lib/assets/images/left.svelte'
6-
import RightImage from '$lib/assets/images/right.svelte'
73
import MobLeftImage from '$lib/assets/images/mob-left.svelte'
84
import MobRightImage from '$lib/assets/images/mob-right.svelte'
5+
import RightImage from '$lib/assets/images/right.svelte'
6+
import Cta from '$lib/components/elements/CTA.svelte'
7+
import { communityList } from '$utils/constants'
8+
import Icon from '@iconify/svelte'
99
1010
const contacts = communityList.filter((community) =>
1111
['Telegram', 'Discord', 'X'].includes(community.name)
@@ -69,6 +69,7 @@
6969
<div class="flex flex-row justify-center gap-5">
7070
{#each contacts as community}
7171
<a
72+
aria-label={community.name}
7273
class="flex h-10 w-10 items-center justify-center rounded-full bg-arkOrangeLight2"
7374
href={community.url}
7475
target="_blank"

src/lib/components/sections/Support.svelte

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<script lang="ts">
22
import { base } from '$app/paths'
3+
import BitcoinImage from '$lib/assets/images/support/bitcoin.svelte'
4+
import BuyMeACoffeeImage from '$lib/assets/images/support/buycoffee.png'
5+
import EthereumImage from '$lib/assets/images/support/ethereum.svelte'
6+
import PatreonImage from '$lib/assets/images/support/patreon.png'
7+
import SupportImage from '$lib/assets/images/support/support.svelte'
38
import Modal from '$lib/components/elements/Modal.svelte'
49
import { BTC_ADDRESS, ETH_ADDRESS } from '$utils/constants'
510
import Icon from '@iconify/svelte'
611
import QR from '@svelte-put/qr/img/QR.svelte'
7-
import SupportImage from '$lib/assets/images/support/support.svelte'
8-
import BitcoinImage from '$lib/assets/images/support/bitcoin.svelte'
9-
import EthereumImage from '$lib/assets/images/support/ethereum.svelte'
10-
import BuyMeACoffeeImage from '$lib/assets/images/support/buycoffee.png'
11-
import PatreonImage from '$lib/assets/images/support/patreon.png'
1212
import type { SvelteComponent } from 'svelte'
1313
1414
const supportImages: Record<string, string> = {
1515
buycoffee: BuyMeACoffeeImage,
16-
patreon: PatreonImage
16+
patreon: PatreonImage,
1717
}
1818
1919
const supportImagesCrypto: Record<string, typeof SvelteComponent> = {
2020
bitcoin: BitcoinImage,
21-
ethereum: EthereumImage
21+
ethereum: EthereumImage,
2222
}
2323
2424
let modalData = {
2525
show: false,
2626
type: '',
27-
address: ''
27+
address: '',
2828
}
2929
let copied = false
3030
let timeout: ReturnType<typeof setTimeout> | null = null
@@ -36,21 +36,21 @@
3636
modalData.show = true
3737
modalData.type = 'bitcoin'
3838
modalData.address = BTC_ADDRESS
39-
}
39+
},
4040
},
4141
{
4242
name: 'ethereum',
4343
onClick: () => {
4444
modalData.show = true
4545
modalData.type = 'etheruem'
4646
modalData.address = ETH_ADDRESS
47-
}
48-
}
47+
},
48+
},
4949
]
5050
5151
const supportLogos = [
5252
{ name: 'buycoffee', url: 'https://buymeacoffee.com/arkbuilders' },
53-
{ name: 'patreon', url: 'https://www.patreon.com/ARKBuilders' }
53+
{ name: 'patreon', url: 'https://www.patreon.com/ARKBuilders' },
5454
]
5555
5656
const copyAddress = (value: string) => {
@@ -83,6 +83,7 @@
8383
<div class="my-5 grid grid-cols-2 gap-2 md:flex md:h-[40px] md:flex-row">
8484
{#each supportLogosCrypto as logo}
8585
<button
86+
aria-label={logo.name}
8687
class="h-11 w-[150px] overflow-hidden rounded-md"
8788
on:click={(e) => {
8889
if (['bitcoin', 'ethereum'].includes(logo.name)) e.preventDefault()

src/routes/tags/[tag]/+page.server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
export const prerender = false
1+
export const prerender = true
22

3-
import type { Blog } from '$utils/constants'
4-
import { getEntries } from '$utils/entries'
3+
import type { Blog, Tag } from '$utils/constants'
4+
import { getEntries, getTags } from '$utils/entries'
55
import { error } from '@sveltejs/kit'
66
import { slug } from 'github-slugger'
77

8+
/** @type {import('./$types').EntryGenerator} */
9+
export function entries() {
10+
const tags = (getTags() as Tag[]) || []
11+
return tags.map((tag: Tag) => ({ tag: tag.slug }))
12+
}
13+
814
function slugsArray(tags: string[]) {
915
return tags?.map((t) => slug(t) || [])
1016
}

src/routes/tags/[tag]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Head from '$lib/components/layouts/Head.svelte'
44
55
export let data
6-
const { tag, posts } = data
6+
$: ({ tag, posts } = data)
77
</script>
88

99
<Head title="Blog" />

src/utils/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ export interface Issue {
163163
languages: string[]
164164
}
165165

166+
export interface Tag {
167+
text: string
168+
slug: string
169+
count: number
170+
}
171+
166172
export const appLogos: Record<string, ComponentType> = {
167173
rate: RateLogo,
168174
memo: MemoLogo,

src/utils/entries.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { browser } from '$app/environment'
22
import { config, user } from '$lib/config'
3+
import type { Blog, Tag } from '$utils/constants'
34
import { slug } from 'github-slugger'
4-
import type { Blog } from './constants'
55

66
// we require some server-side APIs to parse all metadata
77
if (browser) {
@@ -60,7 +60,7 @@ const getMetadata = (entryType: string, filepath: string, entry: any) => {
6060
: null,
6161

6262
tag: entry.metadata?.type?.split(' ').shift().toLowerCase() || null,
63-
tags: entry.metadata?.tags || []
63+
tags: entry.metadata?.tags || [],
6464

6565
// whether or not this file is `my-post.md` or `my-post/index.md`
6666
// (needed to do correct dynamic import in posts/[slug].svelte)
@@ -92,17 +92,11 @@ export const getEntries = (entryType: string, includeDraft: boolean = false) =>
9292
.map((entry, index, allEntries) => ({
9393
...entry,
9494
next: allEntries[index - 1],
95-
prev: allEntries[index + 1]
95+
prev: allEntries[index + 1],
9696
}))
9797
)
9898
}
9999

100-
interface Tag {
101-
text: string
102-
slug: string
103-
count: number
104-
}
105-
106100
export const getTags = () => {
107101
const posts = getEntries('posts') as Blog[]
108102
let tags = posts

0 commit comments

Comments
 (0)