Sha256: 1226b2a1a0417d8793395df06afbdbf15f2394f7c3b5db57d5556a15b94e8bcc

Contents?: true

Size: 1.86 KB

Versions: 20

Compression:

Stored size: 1.86 KB

Contents

---
---
import { stringLookup } from "../strings.mjs";
import DateUtil from "../DateUtil.mjs";

const NEXT_POST_ID = "next_post_link_btn";
const PREV_POST_ID = "prev_post_link_btn";

function createNextPrevLinks(page) {
    let nextLink = document.createElement("a");
    let prevLink = document.createElement("a");
    let container = document.querySelector("#post_next_prev");

    if (page.previous) {
        prevLink.innerText = stringLookup(`prev_post`, page.previous.title);
        prevLink.href = page.previous.url + `#${PREV_POST_ID}`;;

        prevLink.setAttribute("id", PREV_POST_ID);
        prevLink.classList.add(`prev-post-link`);

        container.appendChild(prevLink);
    }

    if (page.next) {
        nextLink.innerText = stringLookup(`next_post`, page.next.title);
        nextLink.href = page.next.url + `#${NEXT_POST_ID}`;

        nextLink.setAttribute("id", NEXT_POST_ID);
        nextLink.classList.add(`next-post-link`);

        container.appendChild(nextLink);
    }
}

function createTagLinks(page) {
    let container = document.querySelector("#post_tags");
    let label = document.querySelector("#post_tags > #tag_header_lbl");
    label.innerText = stringLookup(`tags`);

    for (const tag of page.tags) {
        let tagElem = document.createElement("a");
        tagElem.style.display = "inline-block";
        tagElem.classList.add(`post-tag`);

        tagElem.href = `{{ 'assets/html/all_tags.html' | relative_url }}#tag__${escape(tag)}`;
        tagElem.innerText = tag;

        container.appendChild(tagElem);
    }
}

function fillDate(page) {
    let postDateContainer = document.querySelector(`#post_date`);
    postDateContainer.innerText = DateUtil.toString(new Date(page.date));
}

function initPost(pageData) {
    createNextPrevLinks(pageData);
    createTagLinks(pageData);

    fillDate(pageData);
}

export { initPost };
export default initPost;

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hematite-0.1.9 assets/js/layout/post.mjs
hematite-0.1.8 assets/js/layout/post.mjs
hematite-0.1.7 assets/js/layout/post.mjs
hematite-0.1.6 assets/js/layout/post.mjs
hematite-0.1.5 assets/js/layout/post.mjs
hematite-0.1.4 assets/js/layout/post.mjs
hematite-0.1.3 assets/js/layout/post.mjs
hematite-0.1.2 assets/js/layout/post.mjs
hematite-0.0.12 assets/js/layout/post.mjs
hematite-0.0.11 assets/js/layout/post.mjs
hematite-0.0.10 assets/js/layout/post.mjs
hematite-0.0.9 assets/js/layout/post.mjs
hematite-0.0.8 assets/js/layout/post.mjs
hematite-0.0.7 assets/js/layout/post.mjs
hematite-0.0.6 assets/js/layout/post.mjs
hematite-0.0.5 assets/js/layout/post.mjs
hematite-0.0.4 assets/js/layout/post.mjs
hematite-0.0.3 assets/js/layout/post.mjs
hematite-0.0.2 assets/js/layout/post.mjs
hematite-0.0.1 assets/js/layout/post.mjs