diff --git a/assets/js/data.js b/assets/js/data.js index 275e8de..9894f2b 100644 --- a/assets/js/data.js +++ b/assets/js/data.js @@ -1,11 +1,23 @@ function get_data() { return { - posts: [ - { - title: "Scripts em OCaml", - slug: "scripts-em-ocaml", - }, - ] + pt: { + posts: [ + { + title: "Scripts em OCaml", + slug: "scripts-em-ocaml", + date: "23/03/2024", + }, + ] + }, + en: { + posts: [ + { + title: "Hello, Worldling", + slug: "hello-worldling", + date: "May 20, 2024", + }, + ] + } } } diff --git a/assets/js/main.js b/assets/js/main.js index 1884992..1f82a62 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,13 +1,26 @@ const data = get_data() -const post_list = document.getElementById("posts") +const post_list = document.getElementById('posts') -document.addEventListener("DOMContentLoaded", function() { - data.posts.forEach(post => { - const item = document.createElement("li") - const anchor = document.createElement("a") +const userLang = navigator.language || navigator.userLanguage +let lang = userLang.includes('pt') ? 'pt' : 'en' + +document.addEventListener('DOMContentLoaded', function() { + data[lang].posts.forEach(post => { + const item = document.createElement('li') + const anchor = document.createElement('a') + const date = document.createElement('span') anchor.innerText = post.title anchor.href = 'posts/' + post.slug + '.html' + date.innerText = `${parse_date(post.date)} - ` + item.appendChild(date) item.appendChild(anchor) post_list.appendChild(item) }) }) + +function parse_date(date) { + current_year = new Date().getFullYear() + return date.replace(`, ${current_year}`, '') + .replace(`/${current_year}`, '') +} + diff --git a/assets/js/post-l10n.js b/assets/js/post-l10n.js new file mode 100644 index 0000000..895007c --- /dev/null +++ b/assets/js/post-l10n.js @@ -0,0 +1,9 @@ +const userLang = navigator.language || navigator.userLanguage +let lang = userLang.includes('pt') ? 'pt' : 'en' +console.log('loaded post-l10n.js', lang) + +if (lang != 'pt') { + const footer_back = document.getElementById('footer-back-link') + console.log(footer_back) + footer_back.innerText = 'Back' +} diff --git a/assets/style.css b/assets/style.css index 7ffa2b2..9f3637b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -5,13 +5,17 @@ src: url('Share Tech Mono.ttf'), format('truetype'); } -body { +html { background-color: #222222; font-family: 'ShareTech', monospace; + color: #F1E9E5; +} + +.header-art { + color: #888 } p { - color: #F1E9E5; margin: 30px; } @@ -31,7 +35,7 @@ h1 { font-weight: bold; color: #ccc; font-size: 25px; - margin: 20px 0px 10px 20px; + margin: 40px 0px 10px 20px; } h2 { @@ -53,3 +57,15 @@ li { margin-bottom: 10px; } color: #ccc; padding: 20px; } + +footer { + margin-top: 40px; +} + +.footer-text { + padding: 20px 20px; +} + +.footer-back { + float: right; +} diff --git a/index.html b/index.html index daa1eb7..72fc26a 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,8 @@
-
+