Skip to content

Commit 8b2d0ee

Browse files
committed
fix(#160): Only apply prefix and suffix to website’s title or URL.
1 parent 430c7d6 commit 8b2d0ee

File tree

2 files changed

+115
-17
lines changed

2 files changed

+115
-17
lines changed

README.md

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,122 @@
22

33
“Show off your semantic `<body>`”: [_April 9 is CSS Naked Day!_](https://css-naked-day.org/)
44

5-
If you’re participating, [add a file to the respective folder](https://github.com/css-naked-day/css-naked-day.github.io) to add your website(s).
5+
If you’re participating, add or update a [file in participants](https://github.com/css-naked-day/css-naked-day.github.io/tree/issues/160-refactor-eleventy/_src/_data/participants)!
6+
7+
If you have been participating and are not listed, feel free to make a Pull Request and give us reasonable clues. A link to the [Web archive](https://web.archive.org/web/https://css-naked-day.org/) is always welcome, but you might also point to articles or online mentions of your participation.
68

79
Welcome to CSS Naked Day!
810

11+
## Data structure
12+
13+
We are using **one file per website owner**, with your websites and participating years in the same file! Simply add years or websites as they come.
14+
15+
We are using [Toml configuration files](https://toml.io/) to structure data. Here are examples of configurations:
16+
17+
### Bare minimum
18+
19+
The following will show as “_[css-naked-day.org]_”:
20+
21+
```toml
22+
[[websites]]
23+
url = "https://css-naked-day.org/"
24+
years = [2006, 2010]
25+
```
26+
27+
### With a display name
28+
29+
The following will show as “_[Naked Days Corp]_”:
30+
31+
```toml
32+
display = "Naked Days Corp"
33+
34+
[[websites]]
35+
url = "https://css-naked-day.org/"
36+
years = [2006, 2010]
37+
```
38+
39+
### With multiple websites
40+
41+
The following will show as “_[Naked Days Corp]_” in 2006 and “_Naked Days Corp: [CSS Naked Day] & [JS Naked Day]_” in 2010:
42+
43+
```toml
44+
display = "Naked Days Corp"
45+
46+
[[websites]]
47+
url = "https://css-naked-day.org/"
48+
title = "CSS Naked Day"
49+
years = [2006, 2010]
50+
51+
[[websites]]
52+
url = "https://js-naked-day.org/"
53+
title = "JS Naked Day"
54+
years = [2010]
55+
```
56+
57+
### Advanced formatting
58+
59+
By default, more than one entry will be listed as “_`display`: [website1](), [website2]() & [website3]()_”. [Tom Hazeldine’s config file](https://github.com/css-naked-day/css-naked-day.github.io/blob/430c7d632bddd5d4fb1a17799ac5fc45cee49fab/_src/_data/participants/tom-hazledine.toml#L14-L16) is a good example of a more free-flow writing of entries.
60+
61+
His websites will appear as “_Tom Hazledine: [tomhazledine.com](https://tomhazledine.com/) (some of which is [always naked](https://tomhazledine.com/css-naked-day/))_
62+
63+
### More than complete
64+
65+
We are not using all data yet, but feel free to add them, as we might improve the website with it!
66+
67+
External accounts can also be a good way to join you.
68+
69+
```toml
70+
display = "Joan Elisabeth Lowther Murray" # [optional]
71+
firstname = "Joan Elisabeth" # [optional]
72+
surname = "Lowther Murray" # [optional]
73+
email = "joan@example.com" # [optional]
74+
username = "jelm" # [optional]
75+
76+
# Websites
77+
# ------------------------------------------------------------------------------
78+
79+
[[websites]]
80+
url = "https://css-naked-day.org/"
81+
title = "CSS Naked Day"
82+
years = [2006, 2010]
83+
84+
[[websites]]
85+
url = "https://js-naked-day.org/"
86+
title = "JS Naked Day"
87+
years = [2010]
88+
89+
# Accounts [optional]
90+
# ------------------------------------------------------------------------------
91+
92+
[[accounts]]
93+
type = "Mastodon"
94+
url = "https://mas.to.don/@jelm"
95+
96+
[[accounts]]
97+
type = "Github"
98+
url = "https://github.com/jelm.github"
99+
username = "jelm.github" # [optional] The main one is used by default
100+
```
101+
9102
## Development
10103

11-
The site is built using <https://www.11ty.dev/> and <https://www.npmjs.com/>. The commands are:
104+
The site is built using [Eleventy](https://www.11ty.dev/) and [npm](https://www.npmjs.com/).
12105

13-
### Build HTML
106+
### Build website
14107

15108
```bash
16109
npm run build
17110
```
18111

19-
### Watch files and host web-server (development mode)
112+
### Host a local web-server and watch files (development mode)
20113

21114
```bash
22115
npm run dev
23116
```
117+
118+
119+
[css-naked-day.org]: https://css-naked-day.org/
120+
[Naked Days Corp]: https://css-naked-day.org/
121+
[CSS Naked Day]: https://css-naked-day.org/
122+
[Naked]: https://css-naked-day.org/
123+
[JS Naked Day]: https://js-naked-day.org/

eleventy.config.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function (eleventyConfig) {
2222
eleventyConfig.addDataExtension("toml", (contents) => toml.parse(contents));
2323

2424
eleventyConfig.addFilter("getParticipantDisplayName", (participant) => {
25+
// TODO: Either get current year’s website, or use the filename.
2526
const websiteURL = participant.websites[0].url;
2627

2728
return participant.display || participant.username || getWebsiteDomain(websiteURL);
@@ -44,26 +45,23 @@ export default function (eleventyConfig) {
4445

4546
eleventyConfig.addShortcode("linkNoSpam", function(callback, url, participant, year, loopRevIndex0) {
4647
const website = eleventyConfig.getFilter("getSiteData")(url, participant, year);
48+
const isWebsiteTitle = callback === 'getSiteTitle';
4749

4850
if(!website) {
4951
return;
5052
};
5153

52-
let title;
53-
let separator = website.separator;
54-
let prefix = website.prefix;
55-
let suffix = website.suffix;
56-
57-
switch (callback) {
58-
case 'getSiteTitle':
59-
title = eleventyConfig.getFilter('getSiteTitle')(url, participant);
60-
break;
61-
case 'getParticipantDisplayName':
62-
title = eleventyConfig.getFilter('getParticipantDisplayName')(participant);
63-
break;
54+
let title, prefix, suffix, separator;
55+
56+
if (isWebsiteTitle) {
57+
title = eleventyConfig.getFilter('getSiteTitle')(url, participant);
58+
prefix = website.prefix;
59+
suffix = website.suffix;
60+
} else {
61+
title = eleventyConfig.getFilter('getParticipantDisplayName')(participant);
6462
}
6563

66-
if (separator === undefined && loopRevIndex0) {
64+
if (website.separator === undefined && loopRevIndex0) {
6765
separator = loopRevIndex0 > 1 ? ' & ' : ', ';
6866
}
6967

0 commit comments

Comments
 (0)