Skip to content

Commit de82f47

Browse files
Feature: Custom Styling for Embedded Downloadable Zip Files (#50)
Adds unique appearance to embedded zip files, styling these like a download button. `.zip` and `.7z` files will be the main filetype (and at this stage, only filetype) used for downloadable links for tutorials and the like. This makes it more obvious to users that these are meant to be clicked and downloaded.
1 parent c57cce0 commit de82f47

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

quartz/plugins/transformers/ofm.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
272272
type: "html",
273273
value: `<iframe src="${url}"></iframe>`,
274274
}
275+
// MMW - assign custom styling to .zip embed download link
276+
} else if ([".zip", ".7z"].includes(ext)) {
277+
const downloadText = alias ? alias : fp
278+
return {
279+
type: "html",
280+
value: `<a href="${url}" class="mmw-download-link" download>Download ${downloadText}</a>`,
281+
}
275282
} else {
276283
const block = anchor
277284
return {

quartz/styles/custom.scss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,3 +1088,44 @@ kbd:active kbd {
10881088
color: #db8942;
10891089
text-align: center;
10901090
}
1091+
1092+
/* ===================== */
1093+
1094+
/* --- Download Link --- */
1095+
1096+
a.mmw-download-link:link, a.mmw-download-link:visited {
1097+
background-color: #8f9fa926;
1098+
border: none;
1099+
text-align: center;
1100+
text-decoration: none;
1101+
display: inline-block;
1102+
font-size: 1.2rem;
1103+
width: 100%;
1104+
transition: .4s;
1105+
padding: 6px;
1106+
}
1107+
1108+
a.mmw-download-link:hover, a.mmw-download-link:active {
1109+
background-color: #8f9fa93d;
1110+
}
1111+
1112+
a.mmw-download-link::before {
1113+
/* display download icon before link text */
1114+
display: inherit;
1115+
vertical-align: middle;
1116+
padding-right: 5px;
1117+
}
1118+
1119+
/*change svg stroke='' based on dark/light theme*/
1120+
[saved-theme="light"]a.mmw-download-link::before {
1121+
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1.2rem' height='1.2rem' viewBox='0 0 24 24' fill='none' stroke='%232b2b2b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-download'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' x2='12' y1='15' y2='3'/%3E%3C/svg%3E");
1122+
}
1123+
1124+
[saved-theme="dark"]a.mmw-download-link::before {
1125+
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1.2rem' height='1.2rem' viewBox='0 0 24 24' fill='none' stroke='%23ebebec' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-download'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' x2='12' y1='15' y2='3'/%3E%3C/svg%3E");
1126+
}
1127+
1128+
a.mmw-download-link div.popover {
1129+
display: none;
1130+
/* prevent link popover from appearing */
1131+
}

0 commit comments

Comments
 (0)