Skip to content

Commit

Permalink
Improve template behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonstyle committed Jul 21, 2023
1 parent 6201e63 commit 1c30a1f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
46 changes: 27 additions & 19 deletions src/format/html/format-html-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,9 @@ function processOtherLinks(
const containerEl = doc.createElement("div");
containerEl.classList.add("quarto-other-links");

const heading = dlLinkTarget.makeHeadingEl();
if (format.language[kOtherLinksTitle]) {
heading.innerText = format.language[kOtherLinksTitle];
}
const heading = dlLinkTarget.makeHeadingEl(
format.language[kOtherLinksTitle],
);
containerEl.appendChild(heading);

const getAttrs = (otherLink: OtherLink) => {
Expand Down Expand Up @@ -542,8 +541,7 @@ function processOtherLinks(
order: ++order,
attr: getAttrs(otherLink),
};
const li = dlLinkTarget.makeItemEl();
li.appendChild(createLinkChild(alternateLink, doc));
const li = dlLinkTarget.makeItemEl(createLinkChild(alternateLink, doc));
if (linkList) {
linkList.appendChild(li);
} else {
Expand All @@ -564,17 +562,24 @@ function getLinkTarget(doc: Document, explicitTargetClz: string) {
if (explicitTarget !== null) {
return {
targetEl: explicitTarget,
makeHeadingEl: () => {
makeHeadingEl: (text?: string) => {
const headingEl = doc.createElement("div");
headingEl.classList.add("quarto-title-meta-heading");
if (text) {
headingEl.innerText = text;
}
return headingEl;
},
makeContainerEl: () => {
return undefined;
},
makeItemEl: () => {
makeItemEl: (el: Element) => {
const itemEl = doc.createElement("div");
itemEl.classList.add("quarto-title-meta-contents");

const pEl = doc.createElement("p");
pEl.appendChild(el);
itemEl.appendChild(pEl);
return itemEl;
},
};
Expand All @@ -588,14 +593,20 @@ function getLinkTarget(doc: Document, explicitTargetClz: string) {
if (dlLinkTarget !== null) {
return {
targetEl: dlLinkTarget,
makeHeadingEl: () => {
return doc.createElement("h2");
makeHeadingEl: (text?: string) => {
const headingEl = doc.createElement("h2");
if (text) {
headingEl.innerText = text;
}
return headingEl;
},
makeContainerEl: () => {
return doc.createElement("ul");
},
makeItemEl: () => {
return doc.createElement("li");
makeItemEl: (el: Element) => {
const liEl = doc.createElement("li");
liEl.appendChild(el);
return liEl;
},
};
}
Expand All @@ -618,10 +629,9 @@ function processAlternateFormatLinks(
const containerEl = doc.createElement("div");
containerEl.classList.add("quarto-alternate-formats");

const heading = dlLinkTarget.makeHeadingEl();
if (format.language[kRelatedFormatsTitle]) {
heading.innerText = format.language[kRelatedFormatsTitle];
}
const heading = dlLinkTarget.makeHeadingEl(
format.language[kRelatedFormatsTitle],
);
containerEl.appendChild(heading);

const otherLinks = otherFormatLinks(
Expand All @@ -636,8 +646,6 @@ function processAlternateFormatLinks(
a - b
)
) {
const li = dlLinkTarget.makeItemEl();

const link = doc.createElement("a");
link.setAttribute("href", alternateLink.href);
if (alternateLink.dlAttrValue) {
Expand All @@ -656,7 +664,7 @@ function processAlternateFormatLinks(
link.appendChild(icon);
link.appendChild(doc.createTextNode(alternateLink.title));

li.appendChild(link);
const li = dlLinkTarget.makeItemEl(link);
if (formatList) {
formatList.appendChild(li);
} else {
Expand Down
14 changes: 10 additions & 4 deletions src/resources/formats/html/embed/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@
window.document.addEventListener("DOMContentLoaded", function () {

var header = window.document.querySelector("#quarto-embed-header");
const contentEl = window.document.getElementById('quarto-content');
for (const child of contentEl.children) {
child.style.paddingTop = header.clientHeight + "px";
child.style.marginTop = "1em";
const titleBannerEl = window.document.querySelector("body > #title-block-header");
if (titleBannerEl) {
titleBannerEl.style.paddingTop = header.clientHeight + "px";
}
if (offsetEl === null) {
const contentEl = window.document.getElementById('quarto-content');
for (const child of contentEl.children) {
child.style.paddingTop = header.clientHeight + "px";
child.style.marginTop = "1em";
}
}

const headroom = new window.Headroom(header, {
Expand Down
4 changes: 0 additions & 4 deletions src/resources/formats/html/templates/title-block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ main.quarto-banner-title-block > section:first-child > h4 {
flex-direction: column;
}

.quarto-title-meta-column-end a {
font-size: 0.9em;
}

.quarto-title-meta-column-end a .bi {
margin-right: 0.3em;
}
Expand Down

0 comments on commit 1c30a1f

Please sign in to comment.