-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
264 lines (239 loc) · 11 KB
/
index.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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meu Blog</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@latest/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
pre {
position: relative;
padding: 1rem;
background: #f5f5f5;
border-radius: 0.375rem;
overflow-x: auto;
white-space: pre-wrap;
}
.copy-button {
position: absolute;
top: 1rem;
right: 1rem;
background: #4B5563;
color: white;
border: none;
padding: 0.5rem;
border-radius: 0.375rem;
cursor: pointer;
}
img {
max-width: 100%;
height: auto;
border-radius: 0.375rem;
}
.post-link {
text-decoration: none;
}
.search-bar {
max-width: 600px;
margin: 0 auto;
}
.markdown-body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
font-size: 16px;
line-height: 1.5;
word-wrap: break-word;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
margin-top: 2rem;
margin-bottom: 1rem;
}
.markdown-body p {
margin-bottom: 1rem;
}
.markdown-body ul, .markdown-body ol {
margin-bottom: 1rem;
}
.markdown-body blockquote {
margin: 1rem 0;
padding: 0 1rem;
border-left: 0.25rem solid #dfe2e5;
color: #6a737d;
}
.markdown-body code {
background: #f5f5f5;
border-radius: 0.375rem;
padding: 0.2rem 0.4rem;
font-size: 90%;
}
.markdown-body pre code {
background: #f5f5f5;
border-radius: 0.375rem;
padding: 1rem;
display: block;
font-size: 90%;
}
</style>
</head>
<body class="bg-gray-100 text-gray-900">
<header class="bg-blue-600 text-white p-4 shadow-md">
<div class="container mx-auto flex justify-between items-center">
<img src="https://jeiel.pages.dev/jeiel.png" alt="Foto de Perfil" class="w-12 h-12 rounded-full mr-4">
<h1 class="text-3xl font-bold">Meu Blog</h1>
</div>
</header>
<main class="container mx-auto p-4">
<div class="search-bar mb-6">
<input type="text" id="search-input" placeholder="Pesquisar por título..." class="w-full p-2 border rounded-lg">
</div>
<div id="posts-list"></div>
<button id="load-more" class="bg-blue-500 text-white p-2 rounded hover:bg-blue-600 transition mt-4 hidden">
Carregar mais
</button>
<div id="post-detail" class="hidden">
<button id="back-button" class="bg-blue-500 text-white p-2 rounded mb-4 hover:bg-blue-600 transition">
Voltar
</button>
<div id="post-content" class="prose lg:prose-xl markdown-body"></div>
</div>
</main>
<footer class="bg-gray-800 text-white p-4 mt-6">
<div class="container mx-auto flex justify-between items-center">
<p>© 2024 Jeiel - Todos os direitos reservados.</p>
<div>
<a href="https://www.linkedin.com/in/jeiel-lima-miranda" class="text-blue-400 hover:underline">LinkedIn</a> |
<a href="https://github.com/Jetrom17" class="text-blue-400 hover:underline">GitHub</a> |
<a href="http://jeiel.pages.dev/" class="text-blue-400 hover:underline">Link Bio</a> |
<a href="http://quiz-jeiel.vercel.app/" class="text-blue-400 hover:underline">Quiz Bíblico</a>
</div>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
const postsList = document.getElementById('posts-list');
const postDetail = document.getElementById('post-detail');
const postContent = document.getElementById('post-content');
const backButton = document.getElementById('back-button');
const loadMoreButton = document.getElementById('load-more');
const searchInput = document.getElementById('search-input');
let posts = [];
let visiblePosts = 5;
async function fetchPosts() {
try {
const response = await fetch('https://www.tabnews.com.br/api/v1/contents/JeielLimaMiranda');
const allPosts = await response.json();
posts = allPosts
.filter(post => post.status === 'published' && post.title && post.published_at)
.sort((a, b) => new Date(b.published_at) - new Date(a.published_at));
renderPosts();
} catch (error) {
console.error('Erro ao buscar posts:', error);
postsList.innerHTML = '<p class="text-center text-red-500">Erro ao carregar conteúdo.</p>';
}
}
function renderPosts() {
postsList.innerHTML = '';
const postsToShow = posts.slice(0, visiblePosts);
postsToShow.forEach(post => {
if (!post.title) return;
const postElement = document.createElement('article');
postElement.className = 'mb-6 p-6 bg-white shadow-lg rounded-lg transition-transform transform hover:scale-105';
postElement.innerHTML = `
<h2 class="text-2xl font-semibold mb-2">
<a href="#" class="text-blue-600 hover:underline post-link" data-slug="${post.slug}">${post.title}</a>
</h2>
<p class="text-gray-500">${new Date(post.published_at).toLocaleDateString()}</p>
`;
postsList.appendChild(postElement);
});
if (posts.length > visiblePosts) {
loadMoreButton.classList.remove('hidden');
} else {
loadMoreButton.classList.add('hidden');
}
document.querySelectorAll('.post-link').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const slug = e.target.getAttribute('data-slug');
showPostDetail(slug);
});
});
}
async function showPostDetail(slug) {
try {
const response = await fetch(`https://www.tabnews.com.br/api/v1/contents/JeielLimaMiranda/${slug}`);
const post = await response.json();
if (!post || !post.body) {
postContent.innerHTML = '<p class="text-center text-gray-500">Conteúdo não disponível.</p>';
return;
}
const content = marked.parse(post.body || 'Conteúdo não disponível.');
postContent.innerHTML = `
<article class="bg-white shadow-lg rounded-lg p-6">
<h2 class="text-3xl font-bold mb-4">${post.title}</h2>
<p class="text-gray-500 mb-4">${new Date(post.published_at).toLocaleDateString()}</p>
<div>${content}</div>
<a href="https://www.tabnews.com.br/JeielLimaMiranda/${post.slug}" class="text-blue-600 hover:underline mt-4 block" target="_blank" rel="noopener noreferrer">Disponível em TabNews</a>
</article>
`;
document.querySelectorAll('pre code').forEach((block) => {
const button = document.createElement('button');
button.className = 'copy-button';
button.textContent = 'Copiar';
button.onclick = () => {
navigator.clipboard.writeText(block.textContent).then(() => {
button.textContent = 'Copiado!';
setTimeout(() => button.textContent = 'Copiar', 1500);
});
};
block.parentElement.appendChild(button);
});
postsList.classList.add('hidden');
loadMoreButton.classList.add('hidden');
postDetail.classList.remove('hidden');
} catch (error) {
console.error('Erro ao buscar post:', error);
postContent.innerHTML = '<p class="text-center text-red-500">Erro ao carregar conteúdo.</p>';
}
}
backButton.addEventListener('click', () => {
postDetail.classList.add('hidden');
postsList.classList.remove('hidden');
if (posts.length > visiblePosts) {
loadMoreButton.classList.remove('hidden');
}
});
loadMoreButton.addEventListener('click', () => {
visiblePosts += 5;
renderPosts();
});
searchInput.addEventListener('input', () => {
const query = searchInput.value.toLowerCase();
const filteredPosts = posts.filter(post =>
post.title && post.title.toLowerCase().includes(query)
);
postsList.innerHTML = '';
filteredPosts.forEach(post => {
const postElement = document.createElement('article');
postElement.className = 'mb-6 p-6 bg-white shadow-lg rounded-lg transition-transform transform hover:scale-105';
postElement.innerHTML = `
<h2 class="text-2xl font-semibold mb-2">
<a href="#" class="text-blue-600 hover:underline post-link" data-slug="${post.slug}">${post.title}</a>
</h2>
<p class="text-gray-500">${new Date(post.published_at).toLocaleDateString()}</p>
`;
postsList.appendChild(postElement);
});
document.querySelectorAll('.post-link').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const slug = e.target.getAttribute('data-slug');
showPostDetail(slug);
});
});
});
fetchPosts();
});
</script>
</body>
</html>