Skip to content

Commit fcc39ec

Browse files
committed
21.9
[treemap] - implement treemap [changelog] - better titles - minor styling changes - skip repeated commits [general] - minor footer changes
1 parent 9d66b1d commit fcc39ec

9 files changed

Lines changed: 76 additions & 10 deletions

File tree

.eleventy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { EleventyRenderPlugin } = require("@11ty/eleventy");
33
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
44
const Nunjucks = require("nunjucks");
55

6-
const buildBreadcrumbs = require('./src/static/js/building/breadcrumbs.js');
6+
const { buildBreadcrumbs, buildTreemap } = require('./src/static/js/building/breadcrumbs.js');
77
const buildChangelog = require('./src/static/js/building/changelog.js');
88
const addAsset = require('./src/static/js/building/linking.js');
99
const { qka, quizButtons, quizQuestions } = require('./src/static/js/building/quizzing.js');
@@ -21,6 +21,7 @@ module.exports = function (eleventyConfig) {
2121

2222

2323
eleventyConfig.addShortcode("breadcrumbs", function(navPages) { return buildBreadcrumbs(navPages, this.page) });
24+
eleventyConfig.addShortcode("treemap", function(navPages) { return buildTreemap(navPages) });
2425
eleventyConfig.addShortcode("changelog", (data) => buildChangelog(data));
2526
eleventyConfig.addShortcode("qka", (data) => qka(data));
2627
eleventyConfig.addShortcode("quizButtons", (json) => quizButtons(json));

build-changelog.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ def log(msg)
5151
commit = Commit.new
5252
commit.body, commit.date, commit.hash, commit.author = line.split("||")
5353
commit.author.strip!
54+
commit.hash.strip!
5455

5556
# filter out commits
56-
next unless commit.author in allowed_authors # discard commits from other authors
57+
next unless commit.author in allowed_authors # discard commits from other authors
58+
next if commit.body =~ /Merge pull request/ # discard merge commits
5759
next if commit.body !~ /^\d{1,2}\.\d{1,2}(.*)/ # discard commits that don't have a version number (XX.y)
58-
next if commit.body =~ /Merge pull request/ # discard merge commits
5960

6061
# process version
6162
commit.version = Version.new
@@ -87,6 +88,12 @@ def log(msg)
8788
commit.title = commit.title.gsub(/`(.*)`/, "<code>\\1</code>")
8889
commit.message = commit.message.gsub(/`(.*)`/, "<code>\\1</code>") unless commit.message.nil?
8990

91+
# skip commits with repeated titles
92+
next if commits.map(&:title).include? commit.title
93+
94+
# bold sections in the commit message (format: "[section]")
95+
commit.message = commit.message.gsub(/\[(.*)\]/, "<strong>\[\\1\]</strong>") unless commit.message.nil?
96+
9097
commits << commit
9198
end
9299

package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/treemap.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ eleventyNavigation:
88
title: map
99
---
1010

11+
{% treemap collections.all %}

src/static/css/app/changelog.sass

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111

1212
.title
1313
font-weight: bold
14-
font-size: 1.5rem
14+
font-size: 1.75rem
15+
16+
.subtitle
17+
font-weight: normal
18+
font-size: 1rem
1519

1620
.date
21+
margin-top: 0.75em
1722
font-size: 0.8rem
1823
color: colors.$dark
1924

src/static/css/global.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ footer
2222
color: colors.$light
2323
background: colors.$primary
2424
padding: 1em
25+
font-size: 0.85em
2526

2627
img
2728
height: 2em

src/static/js/building/breadcrumbs.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,42 @@ function findSelfInNavPages(navPages, url) {
1010
}
1111

1212
return null;
13-
}
13+
};
14+
15+
const buildTreemap = (navPages) => {
16+
let html = `<ul id="treemap">`
17+
let pages = navPages.filter(p => p.url !== '/' && p.url !== false)
18+
let tree = []
19+
20+
while (pages.length > 0) {
21+
const page = pages.shift()
22+
23+
let element = {
24+
name: page.fileSlug,
25+
html: `<li class="treemap-node"><a href="${page.url}">${page.fileSlug}</a>`,
26+
children: navPages.filter(p => p.data.eleventyNavigation?.parent === page.fileSlug)
27+
}
28+
29+
// remove children from navPages
30+
pages = pages.filter(p => !element.children.includes(p))
31+
32+
if (element.children.length > 0) {
33+
element.html += `<ul class="treemap-children">`
34+
element.children.forEach(child => {element.html += `<li class="treemap-node"><a href="${child.url}">${child.fileSlug}</a></li>`})
35+
element.html += `</ul>`
36+
}
37+
38+
element.html += `</li>`
39+
tree.push(element)
40+
}
41+
42+
tree.sort((a, b) => a.name > b.name ? 1 : -1) // sort tree by name
43+
tree.forEach(node => html += node.html) // add html to the treemap
44+
45+
html += `</ul>`
46+
47+
return html
48+
};
1449

1550
const buildBreadcrumbs = (navPages, thisPage) => {
1651
if (!thisPage.url) return ''; // if permalink is false in frontmatter, don't show breadcrumbs
@@ -35,4 +70,4 @@ const buildBreadcrumbs = (navPages, thisPage) => {
3570
return html;
3671
};
3772

38-
module.exports = buildBreadcrumbs;
73+
module.exports = {buildBreadcrumbs, buildTreemap};

src/static/js/building/changelog.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ const checkCurrent = (data) => {
1818
})
1919
}
2020

21+
22+
const processTitle = (title) => {
23+
let content = `<span class="title">`
24+
25+
const parts = title.split(': ')
26+
content += parts[0]
27+
28+
if (parts.length > 1) {
29+
content += `<span class="subtitle"> ${parts.slice(1).join(': ')}</span>`
30+
}
31+
32+
content += `</span>`
33+
return content
34+
}
35+
2136
const buildChangelog = (data) => {
2237
let content = '<div id="changelog">'
2338

@@ -38,7 +53,8 @@ const buildChangelog = (data) => {
3853
prevMajor = d.version.major
3954

4055
// add the commit entry
41-
content += `<div class="entry hoverborder"><span class="title">${d.title}</span>`
56+
content += `<div class="entry hoverborder">`
57+
content += processTitle(d.title)
4258
if (d.message) content += `<br><span class="message">${d.message.replace(/\n/g, '<br>')}</span>`
4359
content += `<a class="date" href="https://github.com/miermontoto/mier.info/commit/${d.hash}" target="_blank">${d.date}</a></div>`
4460
})

src/templates/snippets/footer.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<img src="/assets/favicon.svg" alt="logo">
33

44
<a property="dct:title" rel="cc:attributionURL" href="https://mier.info">mier.info</a>
5-
by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://github.com/miermontoto">Juan Mier</a>.
5+
by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://github.com/miermontoto">Juan Mier</a>
66

7-
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0" target="_blank" rel="license noopener noreferrer" class="footer-links">license</a>
7+
<a href="http://creativecommons.org/licenses/by-nc-nd/4.0" target="_blank" rel="license noopener noreferrer" class="footer-links">license</a>
88
<a href="https://github.com/miermontoto/mier.info" target="_blank" class="footer-links">source</a>
99
</footer>

0 commit comments

Comments
 (0)