-
Hi, I’m in the process of writing my personnal blog and adapting your theme. I know it’s a long shot since it’s an older project of you, but I have a question for you : What I’m trying to do : adapting my notefeed to your backlinks : The tipical frontmatter is something like that :
So, notefeed is going fine. But, when I’m adapting it to your backlinks, I’m having a problem I’m not sure I understand correctly. BacklinksSo, while adapting the css, it works just fine So I tried to adapt your notes.11tydata.js, and we’re here at the heart of the problem : I don’t understand how it truly works to adapt it correctly. here is the original for reference : module.exports = {
layout: "note.md",
type: "note",
eleventyComputed: {
title: data => (data.title || data.page.fileSlug),
backlinks: (data) => {
const notes = data.collections.notes;
const currentFileSlug = data.page.fileSlug;
let backlinks = [];
// Search the other notes for backlinks
for(const otherNote of notes) {
const noteContent = otherNote.template.frontMatter.content;
// Get all links from otherNote
const outboundLinks = (noteContent.match(wikilinkRegExp) || [])
.map(link => (
// Extract link location
link.slice(2,-2)
.split("|")[0]
.replace(/.(md|markdown)\s?$/i, "")
.trim()
));
// If the other note links here, return related info
if(outboundLinks.some(link => caselessCompare(link, currentFileSlug))) {
// Construct preview for hovercards
let preview = noteContent.slice(0, 240);
backlinks.push({
url: otherNote.url,
title: otherNote.data.title,
preview
})
}
}
return backlinks;
}
}
} and what I tried to do : // Search the other notes for backlinks
for(const otherNote of notes) {
const noteContent = otherNote.template.frontMatter.content;
// importing description in the otherNote frontmatter
const currentDescription = otherNote.template.frontmatter.description;
[…]
// If the other note links here, return related info
if(outboundLinks.some(link => caselessCompare(link, currentFileSlug))) {
// Construct preview for hovercards
let preview = noteContent.slice(0, 240);
// passing the description tag
let description = currentDescription;
backlinks.push({
url: otherNote.url,
title: otherNote.data.title,
description,
preview,
})
} And of course it don’t works as intended, it trows 3 types of errors at me, tell me I don’t understand template.frontmatter (which is true, I don’t understand it and didn’t found it in eleventy documentation), so here I am : could you please help me through this ? It’s OK if you don’t but I really sucks in js and programming in general (I only don’t suck at CSS I guess), it’s my first attempt at really adapting a theme and I’m close to lose my mind :’) (no, I’m not, it’s just frustrating to not get it). If needed, my repository is here https://codeberg.org/yazae101/yazae.garden, but I really think it’s my understanding of the piece of code below who is the problem. Have a great day, Yazae |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Nevermind, I found my problem : backlinks.push({
url: otherNote.url,
title: otherNote.data.title,
description: otherNote.data.description, //MY CODE
preview
}) just adding the description like any other item in eleventy worked, without trying to touch the other part of the code. I feel very dumb but it works ! sorry for the bother, Yazae |
Beta Was this translation helpful? Give feedback.
Nevermind, I found my problem :
just adding the description like any other item in eleventy worked, without trying to touch the other part of the code. I feel very dumb but it works !
sorry for the bother,
Yazae