1
0
Fork 0

feat(shared): Auto-generate jargon list. Closes #6102

This commit is contained in:
joostdecock 2024-03-17 19:19:56 +01:00
parent 1fc0676115
commit b354b189d6
34 changed files with 109 additions and 267 deletions

View file

@ -8,9 +8,46 @@ jargon/terms for us. This page shows you how to use it.
<Tip compact>Think of jargon as glossary terms</Tip>
## Defined terms
## Defining terms
The list of terminology that is defined differs from site to site:
To define a term, we need to establish a link between the term itself, and the documentation page that defines it.
In the most common scenario, the term is the title of the page.
For example, the title of this page is `Using jargon and terms`:
```mdx
---
title: Using jargon and terms
---
```
If we wanted to make it available as jargon, we only need to add the `jargon` frontmatter:
```mdx
---
title: Using jargon and terms
jargon: true
---
```
## Multiple terms for the same page
We can add additional terms that point to the same page by setting the `terms` in frontmatter to a comma-seperated list of terms.
For example to make both `jargon` and `term` point to this page, we can do this:
```mdx
---
title: Using jargon and terms
jargon: true
terms: jargon, term
---
```
## Terminology per site
The following pages show a list of all terminology per site:
| Site | Terminology List |
| ---- | ---------------- |

View file

@ -1,5 +1,6 @@
---
title: cjs
jargon: true
---
**cjs** stands for **CommonJS**. It is a module system for JavaScript that was

View file

@ -1,5 +1,6 @@
---
title: esm
jargon: true
---
**esm** stands for **ECMAScript Modules** and is the official module system of

View file

@ -1,5 +1,6 @@
---
title: Variadic
jargon: true
---
A **variadic** function is a function that accepts a variable number of arguments.

View file

@ -1,5 +1,7 @@
---
title: User ID
jargon: true
terms: id, uid
---
Every FreeSewing user has a user ID, sometimes referred to as `UID` or just `ID`.

View file

@ -1,5 +1,6 @@
---
title: Role
jargon: true
---
Every FreeSewing user has a role that determines their privileges on the site.

View file

@ -1,5 +1,6 @@
---
title: Basic sewing supplies
jargon: true
---
> What exactly constitutes the bare necessities for sewing is subject to debate.

View file

@ -1,6 +1,7 @@
---
layout: onecol
title: Basting
jargon: true
---
![The shape of this denim back pocket is basted before the pocket is topstitched to the garment](basting.jpg)

View file

@ -1,5 +1,6 @@
---
title: Coverlock
jargon: true
---
![A hem on a T-shirt, made with a coverlock machine](coverlock-hem.jpg)

View file

@ -1,6 +1,7 @@
---
layout: onecol
title: Cutting
jargon: true
---
![Me cutting out some T-shirts](cutting.jpg)

View file

@ -1,5 +1,6 @@
---
title: Darts
jargon: true
---
![Bust darts on a blouse](dart.jpg)

View file

@ -1,5 +1,6 @@
---
title: Double welt pockets
jargon: true
---
## Video

View file

@ -1,5 +1,6 @@
---
title: Ease
jargon: true
---
![Without ease, you would not be able to raise your arm](ease-plus.jpg)

View file

@ -1,5 +1,6 @@
---
title: Edgestitching
jargon: true
---
Edgestitching is a specific type of _topstitching_.

View file

@ -1,5 +1,6 @@
---
title: Fabric grain
jargon: true
---
![The grainline runs parallel to the selvedge](fabric-grain.jpg)

View file

@ -1,5 +1,6 @@
---
title: Good sides together
jargon: true
---
When I refer to good sides together that can refer to either cutting or sewing:

View file

@ -1,5 +1,6 @@
---
title: Hemming
jargon: true
---
![The hem at the bottom of a T-shirt](coverlock-hem.jpg)

View file

@ -1,5 +1,6 @@
---
title: High Point Shoulder (HPS)
jargon: true
---
The _high point shoulder_ or _HPS_ point is used as the base for several vertical measurements.

View file

@ -1,5 +1,6 @@
---
title: Jersey
jargon: true
---
![A piece of grey jersey](knit-fabric.jpg)

View file

@ -1,5 +1,6 @@
---
title: Knit fabric
jargon: true
---
![A piece of grey (French Terry) jersey, a knit fabric](fabric.jpg)

View file

@ -1,5 +1,6 @@
---
title: On the fold
jargon: true
---
When you have a pattern piece that is symmetric, the instructions might tell you that it is to be cut _on the fold_.

View file

@ -1,5 +1,6 @@
---
title: Pinning
jargon: true
---
![Sewing pins are part of the basic sewing supplies](sewing-pins.jpg)

View file

@ -1,5 +1,6 @@
---
title: Rayon
jargon: true
---
![I use rayon for my underwear](rayon.jpg)

View file

@ -1,5 +1,6 @@
---
title: Seam allowance
jargon: true
---
![The inside of the leg on a pair of jeans. The SA is the dark narrow stretch of fabric next to the seam. It has been zig-zagged to keep it from fraying](zig-zag.jpg)

View file

@ -1,5 +1,6 @@
---
title: Serger
jargon: true
---
![The finished backside of a serged seam](serged-seam.jpg)

View file

@ -1,5 +1,6 @@
---
title: Slipstitch
jargon: true
---
A slipstitch is a hand-sewing technique that allows you to join layers

View file

@ -1,5 +1,6 @@
---
title: Topstitching
jargon: true
---
![I used plenty of topstitching in a contrasting red thread on these jeans for my godson Akki](topstitching.jpg)

View file

@ -1,5 +1,6 @@
---
title: Trimming
jargon: true
---
![Seam allowance being trimmed](trimming.jpg)

View file

@ -1,5 +1,6 @@
---
title: Twin needle
jargon: true
---
![A twin needle from Schmetz](twin-needle.jpg)

View file

@ -1,5 +1,6 @@
---
title: Zig-zag stitch
jargon: true
---
![A zig-zag stitch is used to prevent the SA of the denim from fraying](zig-zag.jpg)

View file

@ -1,27 +0,0 @@
import { Term as SharedTerm, termList } from 'shared/components/jargon.mjs'
/*
* This object holds jargon terminology for FreeSewing.dev
*
* This object holds key/value pairs per language where:
* - key: holds the jargon term (make sure to lowercase it and strip dots)
* - value: holds the path to the documentation page as when browsing the website
*
* To be clear:
* - You need to first create a markdown page explaining the term.
* - Only afterwards can you add it here
* - Since this uses dynamic MDX loaded from GitHub,it won't work until pushed
*/
const jargon = {
en: {
cjs: 'reference/terms/cjs',
esm: 'reference/terms/esm',
variadic: 'reference/terms/variadic',
},
}
/*
* DO NOT CHANGE ANYTHING BELOW THIS LINE
*/
export const Term = ({ children }) => <SharedTerm {...{ jargon, children }} site="dev" />
export const TermList = termList(jargon, 'dev')

View file

@ -1,237 +0,0 @@
import { Term as SharedTerm, termList } from 'shared/components/jargon.mjs'
/*
* This object holds jargon terminology for FreeSewing.dev
*
* This object holds key/value pairs per language where:
* - key: holds the jargon term (make sure to lowercase it and strip dots)
* - value: holds the path to the documentation page as when browsing the website
*
* To be clear:
* - You need to first create a markdown page explaining the term.
* - Only afterwards can you add it here
* - Since this uses dynamic MDX loaded from GitHub,it won't work until pushed
*/
// prettier-ignore
export const jargon = {
en: {
// Sewing
'basic sewing supplies': 'docs/sewing/basic-sewing-supplies',
'basting': 'docs/sewing/basting',
'coverlock': 'docs/sewing/coverlock',
'cutting': 'docs/sewing/cutting',
'darts': 'docs/sewing/darts',
'double welt pockets': 'docs/sewing/double-welt-pockets',
'ease': 'docs/sewing/ease',
'edgestitching': 'docs/sewing/edgestitching',
'fabric grain': 'docs/sewing/fabric-grain',
'good sides together': 'docs/sewing/good-sides-together',
'hemming': 'docs/sewing/hemming',
'highpoint shoulder': 'docs/sewing/hps',
'hps': 'docs/sewing/hps',
'jersey': 'docs/sewing/jersey',
'knit binding': 'docs/sewing/knit-binding',
'knit fabric': 'docs/sewing/knit-fabric',
'on the fold': 'docs/sewing/on-the-fold',
'pinning': 'docs/sewing/pinning',
'rayon': 'docs/sewing/rayon',
'sa': 'docs/sewing/seam-allowance',
'seam allowance': 'docs/sewing/seam-allowance',
'serger': 'docs/sewing/serger',
'slipstitch': 'docs/sewing/slipstitch',
'topstitching': 'docs/sewing/topstitching',
'trimming': 'docs/sewing/trimming',
'twin needle': 'docs/sewing/twin-needle',
'zig-zag stitch': 'docs/sewing/zig-zag-stitch',
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
'user id': 'docs/about/site/account/id',
'role': 'docs/about/site/account/role',
},
de: {
// Sewing
'abnäher': 'docs/sewing/darts',
'coverlock': 'docs/sewing/coverlock',
'doppelpaspeltaschen': 'docs/sewing/double-welt- pockets',
'fadenlauf': 'docs/sewing/fabric-grain',
'grundlegendes nähzubehör': 'docs/sewing/basic-sewing-supplies',
'gute seiten zusammen': 'docs/sewing/good-sides-together',
'heften': 'docs/sewing/basting',
'hochpunkt schulter': 'docs/sewing/hps',
'hps': 'docs/sewing/hps',
'im stoffbruch': 'docs/sewing/on-the-fold',
'jersey': 'docs/sewing/jersey',
'nahtzugabe': 'docs/sewing/seam-allowance',
'randnaht': 'docs/sewing/edgestitching',
'rayon': 'docs/sewing/rayon',
'serger': 'docs/sewing/serger',
'stecken': 'docs/sewing/pinning',
'steppstich': 'docs/sewing/slipstitch',
'strickbindung': 'docs/sewing/knit-binding',
'strickstoff': 'docs/sewing/knit-fabric',
'säumen': 'docs/sewing/hemming',
'topstitching': 'docs/sewing/topstitching',
'zickzackstich': 'docs/sewing/zig-zag-stitch',
'zugabe': 'docs/sewing/ease',
'zurückschneiden': 'docs/sewing/trimming',
'zuschnitt': 'docs/sewing/cutting',
'zwillingsnadel': 'docs/sewing/twin-needle',
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
'benutzerkennung': 'docs/about/site/account/id',
'benutzer-id': 'docs/about/site/account/id',
'benutzer id': 'docs/about/site/account/id',
'rolle': 'docs/about/site/account/role',
},
es: {
// Sewing
'aguja gemela': "docs/sewing/twin-needle",
'basting': "docs/sewing/basting",
'bolsillos de doble soldadura': "docs/sewing/double-welt-pockets",
'buenas partes juntas': "docs/sewing/good-sides-together",
'cobertura': "docs/sewing/coverlock",
'corte': "docs/sewing/cutting",
'costura de bordes': "docs/sewing/edgestitching",
'dardos': "docs/sewing/darts",
'en el pliegue': "docs/sewing/on-the-fold",
'fijar': "docs/sewing/pinning",
'grano de tela': "docs/sewing/fabric-grain",
'hemming': "docs/sewing/hemming",
'hombro de punto alto': "docs/sewing/hps",
'hps': "docs/sewing/hps",
'jersey': "docs/sewing/jersey",
'margen de costura': "docs/sewing/seam-allowance",
'punto elástico': "docs/sewing/slipstitch",
'rayon': "docs/sewing/rayon",
'sargento': "docs/sewing/serger",
'suministros básicos de costura': "docs/sewing/basic-sewing-supplies",
'tela de tejidos': "docs/sewing/knit-fabric",
'topstitching': "docs/sewing/topstitching",
'trampa': "docs/sewing/trimming",
'vinculación de nudo': "docs/sewing/knit-binding",
'zig-zag stitch': "docs/sewing/zig-zag-stitch",
'único': "docs/sewing/ease",
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
'id de usuario': 'docs/about/site/account/id',
'identificador de usuario': 'docs/about/site/account/id',
'id usuario': 'docs/about/site/account/id',
'papel': 'docs/about/site/account/role',
},
fr: {
// Sewing
'aiguilles doubles': "docs/sewing/twin-needle",
'aisance': "docs/sewing/ease",
'au pli': "docs/sewing/on-the-fold",
'biais de jersey': "docs/sewing/knit-binding",
'bâtir': "docs/sewing/basting",
'coupe': "docs/sewing/cutting",
'droit fil': "docs/sewing/fabric-grain",
'dégarnir': "docs/sewing/trimming",
'endroit contre endroit': "docs/sewing/good-sides-together",
'fourniture de base pour la couture': "docs/sewing/basic-sewing-supplies",
'jersey': "docs/sewing/jersey",
'marge de couture': "docs/sewing/seam-allowance",
'ourlet': "docs/sewing/hemming",
'pinces': "docs/sewing/darts",
'poche passepoilée': "docs/sewing/double-welt-pockets",
'point glissé': "docs/sewing/slipstitch",
'point zig-zag': "docs/sewing/zig-zag-stitch",
'rayonne': "docs/sewing/rayon",
'viscose': "docs/sewing/rayon",
'recouvreuse': "docs/sewing/coverlock",
'sommet de lépaule': "docs/sewing/hps",
'phe': "docs/sewing/hps",
'surjeteuse': "docs/sewing/serger",
'surpiqûre': "docs/sewing/topstitching",
'surpiqûre nervure': "docs/sewing/edgestitching",
'tissu maille': "docs/sewing/knit-fabric",
'épingler': "docs/sewing/pinning",
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
"id de l'utilisateur": 'docs/about/site/account/id',
"identifiant de l'utilisateur": 'docs/about/site/account/id',
'rôle': 'docs/about/site/account/role',
},
nl: {
// Sewing
'aan de stofvouw': "docs/sewing/on-the-fold",
'basis naaimateriaal': "docs/sewing/basic-sewing-supplies",
'bijknippen': "docs/sewing/trimming",
'coverlock': "docs/sewing/coverlock",
'draadrichting': "docs/sewing/fabric-grain",
'driegen': "docs/sewing/basting",
'dubbele paspelzak': "docs/sewing/double-welt-pockets",
'gebreide stof': "docs/sewing/knit-fabric",
'goede kanten op elkaar': "docs/sewing/good-sides-together",
'hoog punt schouder': "docs/sewing/hps",
'hps': "docs/sewing/hps",
'jersey': "docs/sewing/jersey",
'jersey biezen': "docs/sewing/knit-binding",
'knippen': "docs/sewing/cutting",
'naadtoeslag': "docs/sewing/seam-allowance",
'nepen': "docs/sewing/darts",
'overwijdte': "docs/sewing/ease",
'rayon': "docs/sewing/rayon",
'serger/overlock': "docs/sewing/serger",
'sierstiksel': "docs/sewing/topstitching",
'spelden': "docs/sewing/pinning",
'stiksels': "docs/sewing/edgestitching",
'stiksteek': "docs/sewing/slipstitch",
'tweelingnaald': "docs/sewing/twin-needle",
'zigzagsteek': "docs/sewing/zig-zag-stitch",
'zomen': "docs/sewing/hemming",
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
"gebruikersid": 'docs/about/site/account/id',
"gebruikers id": 'docs/about/site/account/id',
"gebruiker id": 'docs/about/site/account/id',
'rol': 'docs/about/site/account/role',
},
uk: {
// Sewing
'базові матеріали для шиття': 'docs/sewing/basic-sewing-supplies',
'виточки': 'docs/sewing/darts',
'джерсі': 'docs/sewing/jersey',
'закріплення': 'docs/sewing/pinning',
'зметування': 'docs/sewing/basting',
'кишеня з подвійною листочкою': 'docs/sewing/double-welt-pockets',
'коверлок': 'docs/sewing/coverlock',
'крайовий шов': 'docs/sewing/edgestitching',
'крій': 'docs/sewing/cutting',
'лицьові сторони одна до одної': 'docs/sewing/good-sides-together',
'на згині': 'docs/sewing/on-the-fold',
'найвища точка плеча': 'docs/sewing/hps',
'обрізка': 'docs/sewing/trimming',
'поверхневий шов': 'docs/sewing/topstitching',
'подвійна голка': 'docs/sewing/twin-needle',
'припуск на шов': 'docs/sewing/seam-allowance',
'підшивання краю': 'docs/sewing/hemming',
'район': 'docs/sewing/rayon',
'свобода облягання': 'docs/sewing/ease',
'сергер': 'docs/sewing/serger',
'строчка зигзаг': 'docs/sewing/zig-zag-stitch',
'ткацьке переплетення': 'docs/sewing/fabric-grain',
'трикотажна бийка': 'docs/sewing/knit-binding',
'трикотажна тканина': 'docs/sewing/knit-fabric',
'шовний стібок': 'docs/sewing/slipstitch',
// Account
id: 'docs/about/site/account/id',
uid: 'docs/about/site/account/id',
"ідентифікатор користувача": 'docs/about/site/account/id',
"ім'я користувача": 'docs/about/site/account/id',
"ID користувача": 'docs/about/site/account/id',
'роль': 'docs/about/site/account/role',
},
}
/*
* DO NOT CHANGE ANYTHING BELOW THIS LINE
*/
export const Term = ({ children }) => <SharedTerm {...{ jargon, children }} site="org" />
export const TermList = termList(jargon, 'org')

View file

@ -17,7 +17,11 @@ import { DesignMeasurements } from './design-measurements.mjs'
import { DesignOptions } from './design-options.mjs'
import { MeasieImage } from 'shared/components/measurements/image.mjs'
// Dev/Org jargon
import { Term, TermList } from 'site/components/jargon.mjs'
import { Term as SharedTerm, termList } from 'shared/components/jargon.mjs'
import { jargon, site } from 'site/prebuild/jargon.mjs'
export const Term = ({ children }) => <SharedTerm {...{ jargon, children, site }} />
export const TermList = termList(jargon, site)
export const components = (site = 'org', slug = []) => {
const base = {

View file

@ -144,12 +144,38 @@ const loadUsers = async (list, store) => {
const loadDocs = async (site) => {
const folder = site === 'org' ? 'docs' : ''
const titles = await loadFolderFrontmatter('title', site, folder)
const terms = await loadFolderFrontmatter('jargon', site, folder)
// Order is the same for all languages, so only grab EN files
const order = await loadFolderFrontmatter('order', site, folder, false, 'en')
const jargon = await loadFolderFrontmatter('jargon', site, folder)
return mergeOrder(titles, order)
}
/*
* Loads jargon and terms
*/
const loadJargon = async (site, docs) => {
const folder = site === 'org' ? 'docs' : ''
const jargon = await loadFolderFrontmatter('jargon', site, folder)
const terms = await loadFolderFrontmatter('terms', site, folder)
const data = {}
for (const lang in jargon) {
data[lang] = {}
for (const slug in jargon[lang]) {
data[lang][docs[lang][slug].t.toLowerCase()] = slug
if (terms[lang]?.[slug]) {
for (const term of terms[lang][slug].split(',').map((term) => term.trim())) {
data[lang][term.toLowerCase()] = slug
}
}
}
}
return data
}
/*
* Loads all blog posts, titles and order
*/
@ -290,6 +316,15 @@ const writeFile = async (filename, exportname, site, content) => {
export const prebuildDocs = async (store) => {
store.docs = await loadDocs(store.site)
await writeFiles('docs', store.site, store.docs)
// Handle jargon
store.jargon = await loadJargon(store.site, store.docs)
fs.writeFileSync(
path.resolve('..', store.site, 'prebuild', `jargon.mjs`),
`${header}
export const site = "${store.site}"
export const jargon = ${JSON.stringify(store.jargon, null, 2)}`
)
}
/*