forked from PriyaGhosal/BuddyTrail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.html
1304 lines (1152 loc) · 46.9 KB
/
blog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BuddyTrail Blog - Discover Your Next Adventure</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="blog.css" />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Playfair+Display:wght@400;700&display=swap"
rel="stylesheet">
<style>
:root {
--primary-color: #3498db;
--secondary-color: #2ecc71;
--background-color: #f4f4f4;
--text-color: #333;
--card-bg: #ffffff;
--header-bg: #1a1a2e;
--header-text: #ffffff;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background-color: var(--background-color);
color: var(--text-color);
line-height: 1.6;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
header {
background-color: var(--header-bg);
color: var(--header-text);
padding: 1rem 0;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
transition: background-color 0.3s ease;
}
header.scrolled {
background-color: rgba(26, 26, 46, 0.9);
backdrop-filter: blur(10px);
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 2rem;
}
.logo {
display: flex;
align-items: center;
}
.logo img {
height: 40px;
margin-right: 10px;
}
#logo {
font-family: 'Playfair Display', serif;
font-size: 1.8rem;
font-weight: 700;
color: var(--header-text);
}
#nav-list {
display: flex;
list-style-type: none;
}
#nav-list li {
margin-left: 2rem;
}
#nav-list a {
color: var(--header-text);
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
#nav-list a:hover,
#nav-list a.active {
color: var(--secondary-color);
}
.hamburger {
display: none;
background: none;
border: none;
font-size: 1.5rem;
color: var(--header-text);
cursor: pointer;
}
main {
margin-top: 80px;
padding: 2rem 0;
}
.hero {
text-align: center;
padding: 4rem 0;
background: linear-gradient(135deg, #3498db, #2ecc71);
color: white;
margin-bottom: 2rem;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.hero h2 {
font-family: 'Playfair Display', serif;
font-size: 2.5rem;
margin-bottom: 1rem;
animation: fadeInUp 1s ease-out;
}
.hero p {
font-size: 1.2rem;
max-width: 600px;
margin: 0 auto;
animation: fadeInUp 1s ease-out 0.3s;
opacity: 0;
animation-fill-mode: forwards;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.cms-controls {
display: flex;
justify-content: center;
margin-bottom: 2rem;
}
.cms-controls button {
background-color: var(--secondary-color);
color: white;
border: none;
padding: 0.7rem 1.5rem;
margin: 0 0.5rem;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
font-weight: 500;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.cms-controls button:hover {
background-color: #27ae60;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.blog-filters {
display: flex;
justify-content: center;
margin-bottom: 2rem;
}
.blog-filters select {
padding: 0.7rem;
margin: 0 0.5rem;
border: 1px solid #ddd;
border-radius: 25px;
background-color: white;
font-family: 'Poppins', sans-serif;
font-size: 0.9rem;
transition: all 0.3s ease;
cursor: pointer;
}
.blog-filters select:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
.blog-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.blog-post {
background-color: var(--card-bg);
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 1.5rem;
transition: all 0.3s ease;
display: flex;
flex-direction: column;
}
.blog-post:hover {
transform: translateY(-5px);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
.blog-post h2 {
color: var(--primary-color);
margin-bottom: 1rem;
font-family: 'Playfair Display', serif;
font-size: 1.5rem;
}
.meta {
font-size: 0.9rem;
color: #777;
margin-bottom: 1rem;
}
.category {
display: inline-block;
background-color: var(--primary-color);
color: white;
padding: 0.2rem 0.8rem;
border-radius: 15px;
font-size: 0.8rem;
margin-bottom: 0.5rem;
}
.tags {
margin-bottom: 1rem;
}
.tag {
display: inline-block;
background-color: #e0e0e0;
color: #333;
padding: 0.2rem 0.5rem;
border-radius: 15px;
font-size: 0.8rem;
margin-right: 0.5rem;
margin-bottom: 0.5rem;
transition: background-color 0.3s ease;
}
.tag:hover {
background-color: #d0d0d0;
}
.content {
margin-bottom: 1rem;
}
.read-more {
display: inline-block;
margin-top: auto;
color: var(--primary-color);
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
.read-more:hover {
color: #2980b9;
}
.comments-section {
margin-top: 1.5rem;
border-top: 1px solid #eee;
padding-top: 1rem;
}
.comment {
background-color: #f9f9f9;
border-radius: 5px;
padding: 1rem;
margin-bottom: 1rem;
transition: all 0.3s ease;
}
.comment:hover {
background-color: #f0f0f0;
}
.comment-form textarea {
width: 100%;
padding: 0.8rem;
border: 1px solid #ddd;
border-radius: 5px;
resize: vertical;
font-family: 'Poppins', sans-serif;
transition: all 0.3s ease;
}
.comment-form textarea:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
.comment-form button {
background-color: var(--primary-color);
color: white;
border: none;
padding: 0.7rem 1.5rem;
border-radius: 25px;
cursor: pointer;
margin-top: 0.5rem;
transition: all 0.3s ease;
font-weight: 500;
}
.comment-form button:hover {
background-color: #2980b9;
transform: translateY(-2px);
}
footer {
background-color: var(--header-bg);
color: var(--header-text);
padding: 3rem 0;
/* Increased padding for more space */
margin-top: 2rem;
}
.footer-container {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 2rem;
/* Added gap for better spacing between columns */
}
.footer-column {
flex: 1;
margin-bottom: 2rem;
/* Increased margin for better spacing */
min-width: 250px;
/* Increased min-width for more balance */
}
.footer-column h3 {
margin-bottom: 1.5rem;
/* Increased spacing for better layout */
font-family: 'Playfair Display', serif;
font-size: 1.5rem;
/* Increased font size for headings */
color: var(--secondary-color);
/* Color added for contrast */
}
.footer-column ul {
list-style-type: none;
padding-left: 0;
}
.footer-column ul li {
margin-bottom: 0.8rem;
/* Increased spacing for a cleaner look */
}
.footer-column a {
color: var(--header-text);
text-decoration: none;
font-size: 1.1rem;
/* Increased font size for better readability */
transition: color 0.3s ease, transform 0.3s ease;
/* Added hover effect */
}
.footer-column a:hover {
color: var(--secondary-color);
/* Smooth color transition */
transform: translateX(5px);
/* Slight movement on hover */
}
.social-icons {
display: flex;
gap: 1.5rem;
/* Increased gap between social icons */
margin-top: 1.5rem;
}
.social-icons a {
color: var(--header-text);
font-size: 1.8rem;
/* Increased size for icons */
transition: color 0.3s ease, transform 0.3s ease;
}
.social-icons a:hover {
color: var(--secondary-color);
transform: scale(1.1);
/* Scale effect on hover */
}
.footer-bottom {
text-align: center;
padding-top: 2rem;
margin-top: 2rem;
border-top: 1px solid rgba(255, 255, 255, 0.2);
/* Softer border color */
font-size: 1rem;
color: rgba(255, 255, 255, 0.8);
/* Softer footer text color */
}
@media (max-width: 768px) {
.footer-container {
flex-direction: column;
align-items: center;
/* Center align items on mobile */
gap: 1.5rem;
/* Adjusted gap for mobile layout */
}
.footer-column {
min-width: unset;
/* Remove min-width on smaller screens */
text-align: center;
/* Center align text on mobile */
}
}
@media (max-width: 768px) {
.hamburger {
display: block;
}
#nav-list {
display: none;
position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: var(--header-bg);
flex-direction: column;
padding: 1rem 0;
}
#nav-list.show {
display: flex;
}
#nav-list li {
margin: 0.5rem 0;
}
.blog-container {
grid-template-columns: 1fr;
}
.footer-container {
flex-direction: column;
}
}
/* New styles for modals */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
animation: fadeIn 0.3s;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.modal-content {
background-color: var(--card-bg);
margin: 10% auto;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
width: 80%;
max-width: 600px;
animation: slideIn 0.3s;
}
@keyframes slideIn {
from {
transform: translateY(-50px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.modal-content h2 {
color: var(--primary-color);
margin-bottom: 1.5rem;
font-family: 'Playfair Display', serif;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
cursor: pointer;
transition: color 0.3s ease;
}
.close:hover,
.close:focus {
color: var(--primary-color);
text-decoration: none;
}
/* Form styles */
.modal-form input[type="text"],
.modal-form textarea {
width: 100%;
padding: 0.7rem;
margin-bottom: 1rem;
border: 1px solid #ddd;
border-radius: 5px;
font-family: 'Poppins', sans-serif;
transition: border-color 0.3s ease;
}
.modal-form input[type="text"]:focus,
.modal-form textarea:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
.modal-form button {
background-color: var(--primary-color);
color: white;
border: none;
padding: 0.7rem 1.5rem;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
font-weight: 500;
}
.modal-form button:hover {
background-color: #2980b9;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
/* List styles for categories and tags */
.item-list {
list-style-type: none;
padding: 0;
margin-bottom: 1.5rem;
}
.item-list li {
background-color: #f9f9f9;
border-radius: 5px;
padding: 0.7rem 1rem;
margin-bottom: 0.5rem;
display: flex;
justify-content: space-between;
align-items: center;
transition: background-color 0.3s ease;
}
.item-list li:hover {
background-color: #f0f0f0;
}
.delete-btn {
background-color: #e74c3c;
color: white;
border: none;
padding: 0.3rem 0.7rem;
border-radius: 15px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 0.8rem;
}
.delete-btn:hover {
background-color: #c0392b;
transform: translateY(-1px);
}
</style>
</head>
<body>
<header>
<nav>
<div class="logo">
<img src="img/logo.png" alt="BuddyTrail Logo">
<h1 id="logo">BuddyTrail</h1>
</div>
<button class="hamburger" id="hamburger">☰</button>
<ul id="nav-list">
<li><a href="index.html">Home</a></li>
<li><a href="index.html#locations">Location</a></li>
<li><a href="index.html#itineraries">Travel Itineraries</a></li>
<li><a href="index.html#reviews">Reviews</a></li>
<li><a href="index.html#benefits">Benefits</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="auth.html">Sign In</a></li>
<li><a href="#" class="active">Blog</a></li>
<button class="mode-toggle" id="modeToggle">
<span class="sun-icon glow"><img src="day-mode.png" alt="Light mode"></span>
<span class="moon-icon glow" style="display: none;"><img src="moon.png" alt="Dark mode"></span>
</button>
</ul>
</nav>
</header>
<main>
<section class="hero">
<h2>Discover Travel Tips, Stories, and Inspiration</h2>
<p>Welcome to the BuddyTrail Blog, your go-to destination for all things travel!</p>
</section>
<div class="container">
<div class="cms-controls">
<button id="newPostBtn">New Post</button>
<button id="manageCategoriesBtn">Manage Categories</button>
<button id="manageTagsBtn">Manage Tags</button>
</div>
<div class="blog-filters">
<select id="categoryFilter">
<option value="">All Categories</option>
</select>
<select id="tagFilter">
<option value="">All Tags</option>
</select>
</div>
<div class="blog-container">
<!-- Blog posts will be dynamically generated here -->
</div>
</div>
</main>
<footer>
<div class="container">
<div class="footer-container">
<div class="footer-column">
<h3>About Us</h3>
<p>We are a team of passionate travelers creating amazing experiences for adventurers worldwide.</p>
</div>
<div class="footer-column">
<h3>Quick Links</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="index.html#locations">Locations</a></li>
<li><a href="index.html#itineraries">Itineraries</a></li>
<li><a href="index.html#contact">Contact</a></li>
</ul>
</div>
<div class="footer-column">
<h3>Contact Us</h3>
<p>Email: info@buddytrail.com</p>
<p>Phone: +1 (123) 456-7890</p>
</div>
<div class="footer-column">
<h3>Follow Us</h3>
<div class="social-icons">
<a href="https://discord.com/invite/priyaghosal" target="_blank"
><i class="fab fa-discord"></i
></a>
<a href="https://twitter.com/PriyaGhosa39968" target="_blank"
><i class="fab fa-twitter"></i
></a>
<a
href="https://github.com/PriyaGhosal/BuddyTrail"
target="_blank"
><i class="fab fa-github"></i
></a>
<a
href="https://www.linkedin.com/in/priya-ghosal-785771286/"
target="_blank"
><i class="fab fa-linkedin-in"></i
></a>
</div>
</div>
</div>
<div class="footer-bottom">
<p>© 2024 Buddy Trail. All rights reserved.</p>
</div>
</div>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/2.1.3/marked.min.js"></script>
<script>
// Initialize data in localStorage if it doesn't exist
if (!localStorage.getItem('blogPosts')) {
localStorage.setItem('blogPosts', JSON.stringify([
{
id: 1,
title: "10 Must-Visit Destinations for 2024",
content: "As we enter 2024, the world of travel continues to evolve. Here are our top picks for must-visit destinations:\n\n1. Kyoto, Japan: Experience the perfect blend of ancient traditions and modern innovations.\n2. Galapagos Islands, Ecuador: Witness unique wildlife in their natural habitat.\n3. Dubrovnik, Croatia: Explore the stunning medieval architecture and crystal-clear Adriatic waters.\n4. Machu Picchu, Peru: Discover the mysteries of this ancient Incan citadel.\n5. Santorini, Greece: Enjoy breathtaking sunsets and picturesque white-washed buildings.\n6. Banff National Park, Canada: Immerse yourself in the pristine wilderness of the Canadian Rockies.\n7. Marrakech, Morocco: Get lost in the vibrant souks and experience rich Moroccan culture.\n8. Reykjavik, Iceland: Chase the Northern Lights and relax in geothermal hot springs.\n9. Queenstown, New Zealand: Indulge in adrenaline-pumping activities amidst stunning landscapes.\n10. Petra, Jordan: Step back in time at this ancient wonder carved into rose-red cliffs.\n\nEach of these destinations offers unique experiences that will create lasting memories. Whether you're seeking cultural immersion, natural wonders, or adventure, these places have something special to offer every type of traveler in 2024.",
author: "Travel Expert",
date: "May 15, 2024",
category: "Destinations",
tags: ["2024", "travel", "destinations"],
comments: []
},
{
id: 2,
title: "Exploring the Hidden Gems of Bali",
content: "Bali, known for its stunning beaches and vibrant culture, offers much more than meets the eye. Venture beyond the popular tourist spots to discover hidden waterfalls, ancient temples, and serene rice terraces. Don't miss the sacred Tirta Empul temple or the breathtaking Sekumpul Waterfall. For a unique experience, visit the lesser-known Nusa Penida island for its dramatic cliffs and pristine beaches.",
author: "Island Explorer",
date: "June 1, 2024",
category: "Destinations",
tags: ["Bali", "hidden gems", "adventure"],
comments: []
},
{
id: 3,
title: "The Majestic Landscapes of Patagonia",
content: "Patagonia, straddling Chile and Argentina, is a must-visit destination for nature lovers and adventure seekers. Witness the towering peaks of Torres del Paine, trek on the massive Perito Moreno Glacier, and explore the enchanting Tierra del Fuego. The region's diverse wildlife, including guanacos and Andean condors, adds to its allure. Plan your visit between December and February for the best weather conditions.",
author: "Adventure Junkie",
date: "June 15, 2024",
category: "Destinations",
tags: ["Patagonia", "nature", "trekking"],
comments: []
},
{
id: 4,
title: "Uncovering the Magic of Marrakech",
content: "Marrakech, the Red City of Morocco, is a sensory delight that should be on every traveler's bucket list. Lose yourself in the winding alleys of the medina, bargain for treasures in the bustling souks, and marvel at the intricate architecture of the Bahia Palace. Don't miss the chance to experience a traditional hammam or enjoy a sunset camel ride in the nearby Agafay Desert. The vibrant Jardin Majorelle and the historic Koutoubia Mosque are also must-see attractions.",
author: "Culture Enthusiast",
date: "July 1, 2024",
category: "Destinations",
tags: ["Marrakech", "culture", "history"],
comments: []
},
{
id: 5,
title: "The Natural Wonders of Iceland",
content: "Iceland, the land of fire and ice, offers a unique landscape that seems almost otherworldly. From the ethereal Northern Lights to the powerful geysers and hot springs, nature's spectacles are on full display here. Take a dip in the Blue Lagoon, witness the beauty of Gullfoss waterfall, and explore the black sand beaches of Vik. For the adventurous, a trip to the Vatnajökull glacier or a tour of the Golden Circle is a must. Don't forget to visit in summer for the midnight sun or in winter for the best chances to see the aurora borealis.",
author: "Nature Photographer",
date: "July 15, 2024",
category: "Destinations",
tags: ["Iceland", "natural wonders", "photography"],
comments: []
},
{
id: 6,
title: "The Ancient Wonders of Petra, Jordan",
content: "Petra, the ancient city carved into rose-red cliffs, is a testament to human ingenuity and one of the world's most impressive archaeological sites. Walk through the narrow Siq to reach the iconic Treasury, then explore the vast complex of tombs, temples, and the Roman-style theatre. For a truly magical experience, visit Petra by Night when the site is illuminated by thousands of candles. Don't miss the opportunity to hike up to the Monastery for panoramic views of the surrounding landscape. Petra is not just a destination; it's a journey through time that will leave you in awe.",
author: "History Buff",
date: "August 1, 2024",
category: "Destinations",
tags: ["Petra", "archaeology", "history"],
comments: []
}
]));
}
if (!localStorage.getItem('categories')) {
localStorage.setItem('categories', JSON.stringify(["Destinations", "Sustainable Travel", "Budget Travel", "Solo Travel", "Food"]));
}
if (!localStorage.getItem('tags')) {
localStorage.setItem('tags', JSON.stringify(["2024", "travel", "destinations", "sustainable", "budget", "solo", "food", "Bali", "hidden gems", "adventure", "Patagonia", "nature", "trekking", "Marrakech", "culture", "history", "Iceland", "natural wonders", "photography", "Petra", "archaeology"]));
}
// Function to get data from localStorage
function getLocalData(key) {
return JSON.parse(localStorage.getItem(key));
}
// Function to set data in localStorage
function setLocalData(key, data) {
localStorage.setItem(key, JSON.stringify(data));
}
function renderPosts() {
const container = document.querySelector('.blog-container');
container.innerHTML = '';
const posts = getLocalData('blogPosts');
posts.forEach(post => {
const article = document.createElement('article');
article.className = 'blog-post';
article.innerHTML = `
<h2>${post.title}</h2>
<div class="meta">Posted on ${post.date} by ${post.author}</div>
<div class="category">${post.category}</div>
<div class="tags">${post.tags.map(tag => `<span class="tag">${tag}</span>`).join('')}</div>
<div class="content">
<p>${post.content.substring(0, 150)}...</p>
</div>
<div class="full-content" style="display: none;">
<p>${marked(post.content)}</p>
</div>
</div>
<div class="full-content" style="display: none;">
<p>${marked(post.content)}</p>
</div>
<a href="#" class="read-more" data-id="${post.id}">Read More</a>
<div class="comments-section">
<h3>Comments (${post.comments.length})</h3>
<div class="comments">
${post.comments.slice(0, 2).map(comment => `
<div class="comment">
<p>${comment.text}</p>
<small>${comment.date}</small>
</div>
`).join('')}
</div>
<form class="comment-form" data-post-id="${post.id}">
<textarea placeholder="Add a comment"></textarea>
<button type="submit">Post Comment</button>
</form>
</div>
`;
container.appendChild(article);
});
addEventListeners();
}
function addEventListeners() {
// Add event listeners for read more links
document.querySelectorAll('.read-more').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const article = e.target.closest('.blog-post');
const content = article.querySelector('.content');
const fullContent = article.querySelector('.full-content');
if (content.style.display !== 'none') {
content.style.display = 'none';
fullContent.style.display = 'block';
e.target.textContent = 'Read Less';
} else {
content.style.display = 'block';
fullContent.style.display = 'none';
e.target.textContent = 'Read More';
}
});
});
// Add event listeners for comment forms
document.querySelectorAll('.comment-form').forEach(form => {
form.addEventListener('submit', (e) => {
e.preventDefault();
const postId = parseInt(e.target.getAttribute('data-post-id'));
const comment = e.target.querySelector('textarea').value;
addComment(postId, comment);
e.target.reset();
});
});
}
function populateFilters() {
const categoryFilter = document.getElementById('categoryFilter');
const tagFilter = document.getElementById('tagFilter');
const categories = getLocalData('categories');
const tags = getLocalData('tags');
categoryFilter.innerHTML = '<option value="">All Categories</option>';
tagFilter.innerHTML = '<option value="">All Tags</option>';
categories.forEach(category => {
const option = document.createElement('option');
option.value = category;
option.textContent = category;
categoryFilter.appendChild(option);
});
tags.forEach(tag => {
const option = document.createElement('option');
option.value = tag;
option.textContent = tag;
tagFilter.appendChild(option);
});
// Add event listeners for filters
categoryFilter.addEventListener('change', filterPosts);
tagFilter.addEventListener('change', filterPosts);
}
function filterPosts() {
const selectedCategory = document.getElementById('categoryFilter').value;
const selectedTag = document.getElementById('tagFilter').value;
const posts = getLocalData('blogPosts');
const filteredPosts = posts.filter(post => {
const categoryMatch = !selectedCategory || post.category === selectedCategory;
const tagMatch = !selectedTag || post.tags.includes(selectedTag);
return categoryMatch && tagMatch;
});
renderFilteredPosts(filteredPosts);
}
function renderFilteredPosts(filteredPosts) {
const container = document.querySelector('.blog-container');
container.innerHTML = '';
filteredPosts.forEach(post => {
const article = document.createElement('article');
article.className = 'blog-post';
article.innerHTML = `
<h2>${post.title}</h2>
<div class="meta">Posted on ${post.date} by ${post.author}</div>
<div class="category">${post.category}</div>
<div class="tags">${post.tags.map(tag => `<span class="tag">${tag}</span>`).join('')}</div>
<div class="content">
<p>${post.content.substring(0, 150)}...</p>
</div>
<div class="full-content" style="display: none;">
<p>${marked(post.content)}</p>
</div>
<a href="#" class="read-more" data-id="${post.id}">Read More</a>
<div class="comments-section">
<h3>Comments (${post.comments.length})</h3>
<div class="comments">
${post.comments.slice(0, 2).map(comment => `
<div class="comment">
<p>${comment.text}</p>
<small>${comment.date}</small>
</div>
`).join('')}
</div>
<form class="comment-form" data-post-id="${post.id}">
<textarea placeholder="Add a comment"></textarea>
<button type="submit">Post Comment</button>
</form>
</div>
`;
container.appendChild(article);
});
addEventListeners();
}
function viewFullPost(postId) {
const posts = getLocalData('blogPosts');
const post = posts.find(p => p.id === postId);
if (post) {
const modal = document.createElement('div');
modal.className = 'modal';
modal.innerHTML = `
<div class="modal-content">
<span class="close">×</span>
<h2>${post.title}</h2>
<div class="meta">Posted on ${post.date} by ${post.author}</div>
<div class="category">${post.category}</div>
<div class="tags">${post.tags.map(tag => `<span class="tag">${tag}</span>`).join('')}</div>
<div class="content">
<p>${marked(post.content)}</p>
</div>
<div class="comments-section">
<h3>Comments (${post.comments.length})</h3>
<div class="comments">
${post.comments.map(comment => `
<div class="comment">
<p>${comment.text}</p>
<small>${comment.date}</small>
</div>
`).join('')}