Skip to content

Commit 16a8a22

Browse files
Add cheatsheets to the guide (#65)
1 parent fdf7a27 commit 16a8a22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2477
-1022
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
description: "Send a webhook message in the #website channel after deployment"
1919
type: boolean
2020
default: true
21+
run_linting:
22+
description: "Run the linting scripts on the documentation"
23+
type: boolean
24+
default: true
2125
jobs:
2226
build:
2327
name: Build image
@@ -45,12 +49,15 @@ jobs:
4549
# since workflow dispatch can be run on failed builds
4650
- name: Run eslint
4751
run: npm run lint
52+
if: inputs.run_linting
4853

4954
- name: Run markdown lint
5055
run: npm run lint-markdown
56+
if: inputs.run_linting
5157

5258
- name: Run file lint
5359
run: npm run lint-files
60+
if: inputs.run_linting
5461

5562
- name: Check guide build
5663
run: npm run docs:build

.ls-lint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ ls:
2121
.png: regex:logo_(\w|_|\d)+
2222

2323
images:
24-
# TODO: add this when ls-lint adds this
25-
# .png: not_regex:image\d+
24+
.png: not_regex:image\d+
2625

2726
# All images should be in the following folders only
2827
'{blender,udk}/*':

.markdownlint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"MD025": false,
55
"MD029": false,
66
"MD033": false,
7-
"MD034": false
7+
"MD034": false,
8+
"MD045": false
89
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ To update the site on the host machine, run [the `deploy` workflow](https://gith
2525
- push (default: `true`). Controls whether to push the built image to Docker hub. If `deploy` is enabled and `push` is disabled, the server will use an already pushed image with the same `version`, or fail.
2626
- deploy (default: `true`). Disable this to only build (and push) the Docker Image without deploying it.
2727
- webhook message (default: `true`): send a Discord message with the deployment details when the workflow is finished.
28+
- run linting (default: `true`): run all linting scripts before deploying the site.
2829

2930
See the GitHub documentation for [how to run a workflow manually](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow#running-a-workflow).
3031

docs/.vitepress/config/cms/blocks.ts

Lines changed: 140 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,115 @@
1-
import { DecapCmsField } from 'vite-plugin-decap-cms'
1+
import { createField, DecapCmsField, fieldToSnakeCase, Options } from 'vite-plugin-decap-cms'
2+
3+
import * as fields from './fields/'
4+
5+
type Block = NonNullable<NonNullable<Options['script']>['markdownEditorComponents']>[number]
6+
7+
interface ComponentBlockOptions {
8+
id: string
9+
label: string
10+
props: DecapCmsField[]
11+
templateField?: {
12+
label: string
13+
labelSingular: string
14+
nameLabel?: string
15+
contentLabel?: string
16+
names?: string[]
17+
}
18+
}
19+
20+
// TODO: fix enters while transitioning
21+
function createComponentBlock (options: ComponentBlockOptions): Block {
22+
const { id, label, props, templateField } = options
23+
24+
interface ComponentData {
25+
templates: {
26+
name: string | null;
27+
content: string;
28+
}[]
29+
props: Record<string, unknown>
30+
}
31+
32+
return {
33+
id,
34+
label,
35+
pattern: new RegExp(`^<${id}(.*)>((.|\\n)*?)<\\/${id}>$`, 'm'),
36+
fields: [
37+
props.length > 0 ? createField('object', {
38+
name: 'props',
39+
label: 'Properties',
40+
required: false,
41+
collapsed: true,
42+
fields: props.map(fieldToSnakeCase),
43+
}) : undefined,
44+
templateField != undefined ? createField('list', {
45+
name: 'templates',
46+
label: templateField.label,
47+
label_singular: templateField.labelSingular,
48+
allow_add: true,
49+
required: false,
50+
min: 1,
51+
fields: [
52+
createField(templateField.names ? 'select' : 'string', {
53+
name: 'name',
54+
required: false,
55+
label: templateField.nameLabel ?? 'Name',
56+
// @ts-expect-error Errors bc of 'options' not in the string options
57+
options: templateField.names,
58+
}),
59+
createField('markdown', {
60+
name: 'content',
61+
required: true,
62+
label: templateField.contentLabel ?? 'Content',
63+
}),
64+
].filter((n): n is NonNullable<typeof n> => n != undefined),
65+
}) : undefined,
66+
].filter(n => n) as Block['fields'],
67+
fromBlock: function (match): ComponentData {
68+
const props = match.at(1), slots = match.at(2)
69+
70+
return {
71+
props: props != undefined
72+
? props.split(/(?= :)(?<=")/)
73+
.map(str => str.trim().replace(':', '').split('=', 2))
74+
.reduce((obj, value) => ({ ...obj, [value[0]]: value[1] }), {})
75+
: {},
76+
templates: slots != undefined
77+
? slots.split('</template>').filter(str => str.length).map((slot) => {
78+
const results = /^<template #(.*)>(.*)/ms.exec(slot) ?? []
79+
const name = results.at(1)
80+
81+
return {
82+
name: name ?? null,
83+
content: results.at(2) ?? slot,
84+
}
85+
}) : [],
86+
}
87+
},
88+
toBlock: function (data: ComponentData) {
89+
const templates = data.templates.map(({ name, content }) => {
90+
return `<template${name ? ` #${name}` : ''}>\n${content}\n</template>`
91+
})
92+
93+
const props = Object.entries(data.props)
94+
.reduce((str, prop) => str + ` :${prop[0]}="${prop[1]}"`, ' ')
95+
96+
return `<${id}${props}>\n${templates}\n</${id}>`
97+
},
98+
toPreview: function () {
99+
return ''
100+
},
101+
}
102+
}
2103

3104
type BlockFields = { summary?: string, contents: string, type: string }
4105

5-
export const customContainerBlock = {
106+
const customContainerBlock: Block = {
6107
id: 'custom-block',
7-
label: 'Custom block',
108+
label: 'Custom comtainer',
8109
fields: [
9110
{
10111
name: 'type',
11-
label: 'Type of block',
112+
label: 'Type of comtainer',
12113
widget: 'select',
13114
required: true,
14115
options: [
@@ -34,9 +135,8 @@ export const customContainerBlock = {
34135
widget: 'markdown'
35136
}
36137
] satisfies DecapCmsField[],
37-
// @ts-expect-error Needs flag to work
38138
pattern: /^:::(\w+)(.*?)\n(.*?)\n^:::$/ms,
39-
fromBlock: function (match: RegExpMatchArray): BlockFields {
139+
fromBlock: function (match): BlockFields {
40140
return {
41141
type: match[1],
42142
summary: match[2],
@@ -50,3 +150,37 @@ export const customContainerBlock = {
50150
return `:::${data.type} ${data.summary}\n${data.contents}\n:::`
51151
},
52152
}
153+
154+
export default [
155+
customContainerBlock,
156+
createComponentBlock({
157+
id: 'steps',
158+
label: 'Steps component',
159+
templateField: {
160+
label: 'Steps',
161+
labelSingular: 'step',
162+
},
163+
props: fields.stepsProperties,
164+
}),
165+
createComponentBlock({
166+
id: 'tabs',
167+
label: 'Tabs component',
168+
templateField: {
169+
label: 'Tabs',
170+
labelSingular: 'tab',
171+
nameLabel: 'Id',
172+
},
173+
props: fields.tabsProperties,
174+
}),
175+
createComponentBlock({
176+
id: 'ActionBlock',
177+
label: 'Action block component',
178+
templateField: {
179+
label: 'Content',
180+
labelSingular: 'content',
181+
names: ['left', 'right'],
182+
nameLabel: 'Position',
183+
},
184+
props: [],
185+
}),
186+
]

docs/.vitepress/config/cms/collections.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { type DecapCmsCollection } from 'vite-plugin-decap-cms'
44
import sidebar, { type Sidebar } from '../sidebar'
55

66
import {
7-
createFeaturePageField,
7+
createFeaturesField,
88
createHomePageFields,
9+
createNotificationConfigFields,
910
createSiteConfigFields,
10-
createTeamPageField,
11-
} from './fields'
11+
createTeamsField,
12+
} from './fields/'
1213

1314
import {
1415
createAdvancedCollections,
@@ -46,6 +47,14 @@ export default function (): DecapCmsCollection[] {
4647
},
4748
additionalFields: createHomePageFields(),
4849
},
50+
{
51+
name: 'Notifications',
52+
file: 'docs/.vitepress/config/data/notifications.json',
53+
overwrites: {
54+
deleted: true,
55+
},
56+
additionalFields: createNotificationConfigFields(),
57+
},
4958
], {
5059
collection: {
5160
create: false,
@@ -61,7 +70,11 @@ export default function (): DecapCmsCollection[] {
6170
hidden: true,
6271
},
6372
additionalFields: [
64-
createTeamPageField(),
73+
createTeamsField({
74+
name: 'teams',
75+
label: 'Teams',
76+
label_singular: 'team',
77+
}),
6578
]
6679
},
6780
{
@@ -71,7 +84,7 @@ export default function (): DecapCmsCollection[] {
7184
hidden: true,
7285
},
7386
additionalFields: [
74-
createFeaturePageField({
87+
createFeaturesField({
7588
name: 'collision_types',
7689
label: 'Collision types',
7790
label_singular: 'type',
@@ -85,7 +98,7 @@ export default function (): DecapCmsCollection[] {
8598
hidden: true,
8699
},
87100
additionalFields: [
88-
createFeaturePageField({
101+
createFeaturesField({
89102
name: 'next_actions',
90103
label: 'Next actions',
91104
label_singular: 'action',
@@ -140,7 +153,8 @@ export default function (): DecapCmsCollection[] {
140153
return createFolderCollection({
141154
base,
142155
label: config.text ?? items[0].text!,
143-
mediaFolder: '',
156+
description: config.description,
157+
mediaFolder: config.mediaFolder,
144158
})
145159
}),
146160
]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { createField } from 'vite-plugin-decap-cms'
2+
3+
export const stepsProperties = [
4+
createField('string', {
5+
name: 'color',
6+
label: 'Color',
7+
required: false,
8+
}),
9+
]
10+
11+
export const tabsProperties = [
12+
createField('list', {
13+
name: 'tabs',
14+
label: 'Tab names',
15+
label_singular: 'name',
16+
allow_add: true,
17+
required: true,
18+
}),
19+
createField('string', {
20+
name: 'startTab',
21+
label: 'Start tab name',
22+
required: false,
23+
}),
24+
createField('string', {
25+
name: 'searchParam',
26+
label: 'Search parameter',
27+
required: false,
28+
}),
29+
]

0 commit comments

Comments
 (0)