Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷‍♀️ Add Build Process for Definitions #31

Merged
merged 65 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8307168
feat(11ty): apply styles to markdown output
ovlb Nov 12, 2019
0c9eb8f
styles: delete duplicated defintions, apply global link styles
ovlb Nov 12, 2019
0ac6c06
feat(definitions): add ok-hand
ovlb Nov 12, 2019
45bdf89
feat(definitions): add unreal
ovlb Nov 14, 2019
3399abf
feat(11ty): rename defined collection
ovlb Nov 14, 2019
9dc5a14
feat(dictionary): link to defined alt words
ovlb Nov 14, 2019
51a7efd
feat(styles): update markdown output to be closer to original layout
ovlb Nov 14, 2019
ff410b0
feat(definitions): remove horizontal line
ovlb Nov 14, 2019
08d48f1
feat(11ty): definition is not spelled defintion, definition is not sp…
ovlb Nov 15, 2019
7d837dc
feat(11ty): remove unnecessary spread
ovlb Nov 15, 2019
e5718e3
feat(11ty): add serve command
ovlb Nov 15, 2019
701ceaa
feat(11ty): move table of content in partial file
ovlb Nov 15, 2019
f5db4c1
feat(11ty): add further reading section to definitions
ovlb Nov 15, 2019
16132c7
feat(11ty): spell alt words capitalised
ovlb Nov 15, 2019
c15826c
feat(definitions): add minorities and minoritised
ovlb Nov 15, 2019
f8469ba
feat(11ty): sort defintions by title
ovlb Nov 15, 2019
fad8700
feat(11ty): only render flag in ToC if type is defined
ovlb Nov 15, 2019
71de563
feat(eleventy): split table of content into sub sections
ovlb Nov 15, 2019
b5e2289
feat(definitions): add performative allyship && ocd
ovlb Nov 15, 2019
017aef1
feat(11ty): render flags in defintions
ovlb Nov 15, 2019
838ecf8
styles: fix icon of alternatives
ovlb Nov 15, 2019
4f44185
feat(definitions): fat && fatphobia
ovlb Nov 17, 2019
a83f278
feat(11ty): render flag outside link in toc
ovlb Nov 17, 2019
9066657
feat(11ty): render subterms in toc
ovlb Nov 17, 2019
6e087a9
feat(11ty): rename definitions collection to tableOfContent
ovlb Nov 17, 2019
488a5cd
feat(11ty): skip items which have skip flag set in toc
ovlb Nov 17, 2019
42d5252
feat(11ty): add filter for subterm output
ovlb Nov 17, 2019
fdc4963
feat(11ty): link sub terms in table of content
ovlb Nov 17, 2019
b615a4c
feat(11ty): add page layout
ovlb Nov 17, 2019
ca10894
packages: add prism and markdown-it-anchor
ovlb Nov 17, 2019
6ef759b
feat(definitions): remove type of flag and always use text
ovlb Nov 17, 2019
82ca5c3
feat(11ty): use flag text in template
ovlb Nov 17, 2019
4db1675
docs: add front matter documentation
ovlb Nov 17, 2019
586d92f
styles: import prism, add grid variant
ovlb Nov 17, 2019
e0eca4c
feat(11ty): add custom markdown-it
ovlb Nov 17, 2019
3cfa04d
💅
ovlb Nov 17, 2019
0c66996
docs: add contributing.md (WIP)
ovlb Nov 17, 2019
f9d7c96
docs: fix code highlighting
ovlb Nov 18, 2019
0a2d6bf
docs: fix headline breaking the layout
ovlb Nov 18, 2019
b39693b
styles: update code styles, make `.page` grid container to contain co…
ovlb Nov 18, 2019
8399ac5
docs: contributing guidelines (wip)
ovlb Nov 18, 2019
184ec33
styles: constrain width of .page content column
ovlb Nov 18, 2019
731e43e
docs: link to complete examples from front matter page
ovlb Nov 18, 2019
a812dcf
feat(definitions): add esl
ovlb Nov 18, 2019
2177586
docs: add basic && flagged word examples
ovlb Nov 18, 2019
ea1c549
feat(defintions): port defined words from static site
ovlb Nov 18, 2019
fbac442
typography: use english style quotation marks
ovlb Nov 18, 2019
c9b04a6
feat(definitions): add undefined words
ovlb Nov 18, 2019
02a937e
feat(definitions): helper script to create defs from data list
ovlb Nov 18, 2019
4895c83
feat(definitions): add flags and more sub terms
ovlb Nov 18, 2019
e6f7c7f
feat(definitions): update transgender, spirit animal && bipolar
ovlb Nov 18, 2019
d4b7cc5
feat(definitions): add further sub terms
ovlb Nov 19, 2019
20b1771
feat(definitions): add missing sub terms
ovlb Nov 19, 2019
4055384
meta: update site title and description
ovlb Nov 19, 2019
63fafa5
feat(11ty): correctly sort words beginning with `-`
ovlb Nov 19, 2019
94d30ee
🧹
ovlb Nov 19, 2019
ccdc357
build: add assets folder
ovlb Nov 22, 2019
13aee11
build: add sass config
ovlb Nov 22, 2019
0013f2e
build: add build and watch for css
ovlb Nov 22, 2019
50c286b
build: add netlify config
ovlb Nov 22, 2019
5f7b24d
git: ignore parcel cache
ovlb Nov 22, 2019
58ba261
docs: add dev guide
ovlb Nov 22, 2019
5d26c51
styles(table of content): use multi column layout
ovlb Nov 29, 2019
6f888d0
feat(definitions): port fatphobia update
ovlb Nov 29, 2019
82f2595
Merge branch 'master' into feature/eleventy-build
tatianamac Dec 16, 2019
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
149 changes: 131 additions & 18 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,151 @@
const makeItemLink = (slug) => `#${slug}`
const findExistingDefinition = (word, collection) => collection.find(item => item.data.title === word)

module.exports = function (config) {
// Add a filter using the Config API
config.addFilter('linkTarget', (slug) => `#${slug}`);
config.addFilter('linkTarget', makeItemLink);

config.addFilter('linkIfExistsInCollection', (word, collection) => {
const existingDefinition = findExistingDefinition(word, collection)

if (existingDefinition) {
return `<a href="${makeItemLink(existingDefinition.data.slug)}">${word}</a>`
}

return word
})

config.addFilter('linkSubTermIfDefined', (subTermData, collection) => {
const existingDefinition = findExistingDefinition(subTermData.full_title, collection)

if (existingDefinition) {
return `<a href="${makeItemLink(existingDefinition.data.slug)}" aria-label="${subTermData.full_title}">${subTermData.text}</a>`
}

return subTermData.text
})

// just a debug filter to lazily inspect the content of anything in a template
config.addFilter('postInspect', function (post) {
console.log(post);

})

config.addPassthroughCopy({'_site/css/': 'assets/css/'})

// Add collections here
config.addCollection('definitions', collection => {
return [
...collection
.getFilteredByGlob('./11ty/definitions/*.md')
.sort((a, b) => {
// `toLowerCase()` is just a safety measure, slugs should be lower case anyway
// `localeCompare()` is super cool: http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
return a.data.slug.toLowerCase().localeCompare(b.data.slug.toLowerCase())
})]
config.addShortcode('definitionFlag', (flag) => {
const cleanText = new Map([
['avoid', {
class: 'avoid',
text: 'Avoid'
}],
['better-alternative', {
class: 'better',
text: 'Better alternate'
}],
['tool', {
class: 'tool',
text: ''
}]
])

if (flag) {
const info = cleanText.get(flag.level)

const sep = flag.text && info.text ? '—' : ''
const text = flag.text ? [info.text, flag.text].join(sep) : info.text

return `<p class="word__signal word__signal--${info.class}">${text}</p>`
}

return '<p class="word__signal"></p>'
});


// NOTE (ovlb): this will not be remembered as the best code i’ve written. if anyone seeing this has a better solution then the following to achieve sub groups of the definitions: i am happy to get rid of it
config.addCollection('tableOfContent', collection => {
const allItems = collection
.getFilteredByGlob('./11ty/definitions/*.md')
.filter(word => !word.data.skip_in_table_of_content)
.sort((a, b) => {
// `localeCompare()` is super cool: http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
return a.data.title.toLowerCase().localeCompare(b.data.title.toLowerCase())
})

const split = {
notLetters: {
title: '#',
definitions: []
},
aToE: {
title: 'A–E',
definitions: []
},
fToL: {
title: 'F–L',
definitions: []
},
mToS: {
title: 'M–S',
definitions: []
},
tToZ: {
title: 'T–Z',
definitions: []
}
}

allItems.forEach(word => {
const { title, skip_in_table_of_content } = word.data
const { notLetters, aToE, fToL, mToS, tToZ } = split

if (/^[a-e]/gmi.test(title)) {
return aToE.definitions.push(word)
}

if (/^[f-l]/i.test(title)) {
return fToL.definitions.push(word)
}

if (/^[m-s]/i.test(title)) {
return mToS.definitions.push(word)
}

if (/^[t-z]/i.test(title)) {
return tToZ.definitions.push(word)
}

// no reg ex as the fallback to avoid testing for emojis and numbers
notLetters.definitions.push(word)
})

return Object.keys(split).map(key => {
const { title, definitions } = split[key]

return { title, definitions }
})
})

config.addCollection('definedDefinitions', collection => {
return [
...collection
config.addCollection('definedWords', collection => {
return collection
.getFilteredByGlob('./11ty/definitions/*.md')
.filter(word => word.data.defined)
.sort((a, b) => {
// `toLowerCase()` is just a safety measure, slugs should be lower case anyway
// `localeCompare()` is super cool: http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
return a.data.slug.toLowerCase().localeCompare(b.data.slug.toLowerCase())
})]
return a.data.title.toLowerCase().localeCompare(b.data.title.toLowerCase())
})
})

const mdIt = require('markdown-it')({
html: true
})
const prism = require('markdown-it-prism')
const anchor = require('markdown-it-anchor')

mdIt.use(prism)
mdIt.use(anchor)

config.setLibrary('md', mdIt);

// You can return your Config object (optional).
return {
dir: {
Expand Down
35 changes: 24 additions & 11 deletions 11ty/_includes/components/definition.njk
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<article id={{ definition.data.slug }} class="block__word word">
<article id="{{ definition.data.slug }}" class="block__word word">
{% definitionFlag definition.data.flag %}
<h3 class="word__title">
{{ definition.data.title}}
<span class="word__speech">{{ definition.data.speech}}</span>
</h3>
{{ definition.templateContent | safe }}
{# <p>{{ definition.data.alt_words }}</p> #}
{%- if definition.data.alt_words -%}
<h4>Alt words</h4>
<ul class="list-semicolon">
{% for word in definition.data.alt_words %}
<li>{{ word }}</li>
{% endfor %}
</ul>
{% endif %}
<div class="word__content">
{{ definition.templateContent | safe }}
{# <p>{{ definition.data.alt_words }}</p> #}
{%- if definition.data.alt_words -%}
<h4>Alt Words</h4>
<ul class="list-semicolon">
{% for word in definition.data.alt_words %}
<li>{{ word | linkIfExistsInCollection(collections.definedWords) | safe }}</li>
{% endfor %}
</ul>
{% endif %}
{%- if definition.data.reading -%}
<h4>Further Reading</h4>
<ul class="list-semicolon">
{% for link in definition.data.reading %}
<li>
<a href="{{link.href}}">{{ link.text }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</article>
2 changes: 1 addition & 1 deletion 11ty/_includes/components/defintions-list.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="auto-grid">
{% for definition in collections.definedDefinitions %}
{% for definition in collections.definedWords %}
{% include 'components/definition.njk' %}
{% endfor %}
</div>
18 changes: 18 additions & 0 deletions 11ty/_includes/components/table-of-content-item.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<li>
{{ definition.data.title | linkIfExistsInCollection(collections.definedWords) | safe }}
{%- if
definition.data.flag and
definition.data.flag.text and
(definition.data.flag.level == 'avoid') -%}
<span class="flag__red">{{ definition.data.flag.text }}</span>
{% endif %}
{%- if definition.data.sub_terms -%}
<ul class="sub-terms">
{% for term in definition.data.sub_terms %}
<li
class="subterm"
>{{ term | linkSubTermIfDefined(collections.definedWords) | safe }}</li>
{% endfor %}
</ul>
{% endif %}
</li>
16 changes: 16 additions & 0 deletions 11ty/_includes/components/table-of-content.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<section>
<nav class="" aria-label="Definitions">
<ol class="auto-grid list">
{% for section in collections.tableOfContent %}
<li>
<span class="sub-headline">{{ section.title }}</span>
<ol>
{% for definition in section.definitions %}
{% include 'components/table-of-content-item.njk' %}
{% endfor %}
</ol>
</li>
{% endfor %}
</ol>
</nav>
</section>
37 changes: 4 additions & 33 deletions 11ty/_includes/layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,11 @@

<link
rel="stylesheet"
href="{{ 'assets/css/base.css' | url }}"
href="{{ '/assets/css/base.css' | url }}"
>
</head>
<body>
<main>
{{ content | safe }}
<section>
<h2>Table of Content</h2>
<div class="auto-grid list">
<ul>
{% for definition in collections.definitions %}
{% set renderedName %}
{{ definition.data.title}}
{%- if definition.data.flag and (definition.data.flag.level == 'avoid') -%}
<span class="flag__red">{{ definition.data.flag.type }}</span>
{% endif %}
{% endset %}
<li>
{%- if definition.data.defined -%}
<a
href={{ definition.data.slug | linkTarget | url }}
class="word__link"
>{{ renderedName | safe }}</a>
{%- else -%}
{{ renderedName | safe }}
{% endif %}
</li>
{% endfor %}
</ul>
</div>
</section>
<section>
<h2>Words</h2>
{% include 'components/defintions-list.njk' %}
</section>
</main>
{% block content %}
{% endblock content %}
</body>
</html>
19 changes: 19 additions & 0 deletions 11ty/_includes/layouts/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends 'layouts/base.njk' %}

{% block content %}
<main>
{{ content | safe }}
{% include 'components/table-of-content.njk' %}
<section>
<h2>Words</h2>
{% include 'components/defintions-list.njk' %}
</section>
</main>
<footer class="site-footer">
<nav aria-label="">
<ul class="navigation-list">
<li><a href="/documentation/">Documentation
</ul>
</nav>
</footer>
{% endblock %}
19 changes: 19 additions & 0 deletions 11ty/_includes/layouts/page.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends 'layouts/base.njk' %}
{% set pageType = 'Page' %}

{% block content %}
<div class="small-left-grid">
<div id="title">
<a href="/">Self-Defined</a>
<p>A modern dictionary about us.<br>We define our words, but they don't define us.</p>
</div>
<main class="page">
{%- if parent -%}
<div>
<a href={{ parent.href }}>{{ parent.title }}</a>
</div>
{% endif %}
<h1 class="title__thicc" >{{ title }}</h1>
{{ content | safe }}
</main>
{% endblock %}
2 changes: 0 additions & 2 deletions 11ty/definitions/bisexual.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defined: true

of, relating to, or characterised by being sexually attracted to more than one gender.

---

#### Note

Bisexuality does not preclude attraction to [non-binary](#non-binary) or [transgender](#transgender) people.
Expand Down
10 changes: 10 additions & 0 deletions 11ty/definitions/cisgender.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Cisgender
slug: cisgender
speech: adj
defined: true
---

of, relating to, or characterised by being a gender that matches the gender they were assigned at birth.

The opposite of [transgender](/#transgender).
2 changes: 1 addition & 1 deletion 11ty/definitions/crazy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: crazy
slug: crazy
flag:
type: ableist-slur
text: 'Ableist Slur'
level: avoid
defined: true
speech: noun
Expand Down
25 changes: 25 additions & 0 deletions 11ty/definitions/english-as-second-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: English as Second Language (ESL)
slug: english-as-second-language
flag:
level: avoid
defined: true
speech: noun
alt_words:
- English as learning-language (ELL)
- or non-native
- or omit (because do you really know, for sure?)
reading:
- href: https://benchmarkeducation.com/best-practices-library/supporting-english-language-learners-in-reading-writing.html#section_2
text: ELL Glossary by Benchmark Education
---

the teaching of English to people who speak a different language and who live in a country where English is the main language spoken

#### Issues

Monolinguist, English-only speakers often refer to people who don't speak English natively as "ESL" or say they are learning a "second language". More often than not, this is not true, as many people are multi-lingual with 3 or more languages

#### Impact

It makes false assumptions about English learners, centres English as the "default" or "expected" first language, ignoring that many people learn multiple (>3), non-English languages first.
Loading