Prototype links page
This commit is contained in:
parent
304e17ab66
commit
2061680593
7 changed files with 61 additions and 8 deletions
|
|
@ -1,22 +1,26 @@
|
|||
function get_data() {
|
||||
return {
|
||||
"pt": {
|
||||
"posts": [
|
||||
"posts": {
|
||||
"pt": [
|
||||
{
|
||||
"title": "Scripts em OCaml",
|
||||
"slug": "scripts-em-ocaml",
|
||||
"date": "23/03/2024"
|
||||
}
|
||||
]
|
||||
},
|
||||
"en": {
|
||||
"posts": [
|
||||
],
|
||||
"en": [
|
||||
{
|
||||
"title": "Meeting the BSD Family",
|
||||
"slug": "meeting-the-bsd-family",
|
||||
"date": "May 20, 2024"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"title": "Capital Offense How to Handle Abbreviations in CamelCase - Approxion",
|
||||
"url": "https://www.approxion.com/capital-offenses-how-to-handle-abbreviations-in-camelcase/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
assets/js/links.js
Normal file
18
assets/js/links.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const data = get_data()
|
||||
|
||||
function populate_links() {
|
||||
data.links.forEach(link => {
|
||||
const links = document.getElementById('links')
|
||||
links.innerHTML = ''
|
||||
const item = document.createElement('li')
|
||||
const anchor = document.createElement('a')
|
||||
anchor.innerText = link.title
|
||||
anchor.href = link.url
|
||||
item.appendChild(anchor)
|
||||
links.appendChild(item)
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
populate_links()
|
||||
})
|
||||
|
|
@ -4,7 +4,7 @@ const userLang = navigator.language || navigator.userLanguage
|
|||
let lang = userLang.includes('pt') ? 'pt' : 'en'
|
||||
|
||||
function populate_posts() {
|
||||
data[lang].posts.forEach(post => {
|
||||
data.posts[lang].forEach(post => {
|
||||
const posts = document.getElementById('nav-posts')
|
||||
posts.innerHTML = ''
|
||||
const item = document.createElement('li')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue