Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const compileSlots = (body, slots) => {
}

const [find, name, fallback] = m;
copy = copy.replace(find, slots[name] || fallback || '');
copy = copy.replace(find, () => slots[name] || fallback || '');
}
body = copy;

Expand All @@ -263,7 +263,7 @@ const compileSlots = (body, slots) => {
}

const [find, name] = m;
copy = copy.replace(find, slots[name] || '');
copy = copy.replace(find, () => slots[name] || '');
}
body = copy;

Expand All @@ -274,12 +274,12 @@ const compileSlots = (body, slots) => {
}

const [find, fallback] = m;
copy = copy.replace(find, slots.default || fallback || '');
copy = copy.replace(find, () => slots.default || fallback || '');
}
body = copy;

// Simple default slots
body = body.replace(patterns.simpleDefaultSlots, slots.default);
body = body.replace(patterns.simpleDefaultSlots, () => slots.default);

return body;
};
Expand Down Expand Up @@ -307,7 +307,7 @@ const compileImport = (body, pattern) => {

// Recurse
replace = compileTemplate(replace, slots);
body = body.replace(find, replace);
body = body.replace(find, () => replace);
}

return body;
Expand Down Expand Up @@ -350,7 +350,7 @@ const compileLinks = (body, path) => {
const isCurrent = isCurrentPage(to, path);
if (isCurrent || isParentPage(to, path)) {
if (attributes.includes('class="')) {
attributes = attributes.replace('class="', `class="${ACTIVE_CLASS} `);
attributes = attributes.replace('class="', () => `class="${ACTIVE_CLASS} `);
} else {
attributes += ` class="${ACTIVE_CLASS}"`;
}
Expand All @@ -361,7 +361,7 @@ const compileLinks = (body, path) => {
}

replace = `<a ${attributes}>${content}</a>`;
copy = copy.replace(find, replace);
copy = copy.replace(find, () => replace);
}
body = copy;

Expand Down