@@ -6,6 +6,13 @@ This repository contains the code and contents of https://crossplatform.dev.
66
77It is built using [ Docusaurus 2] ( https://docusaurus.io/ ) and deployed on Netlify.
88
9+ Table of contents:
10+
11+ * [ Installation] ( #installation )
12+ * [ Local development] ( #local-development )
13+ * [ Writing code examples] ( #writing-code-examples )
14+ * [ Adding a new technology] ( #adding-a-new-technology )
15+
916## Installation
1017
1118To install it locally, you will need to:
@@ -47,6 +54,58 @@ npm start
4754Most changes, like markdown modifications, ` sidebars.js ` , etc. are
4855reflected live without having to restart the server.
4956
57+ ## Writing code examples
58+
59+ The website also has a couple remark plugins that make it easier to have examples side by side.
60+ They live under the [ ` /src/transformers ` ] [ transformers ] folder:
61+
62+ - ` import-code ` allows you to reference a code file an "import" it automatically when building
63+ the website. This is useful to separate the code from the text. You can use it as follows:
64+
65+ ```` md
66+ Look at this JavaScript code:
67+
68+ ```js (./path/to/code.js)
69+ ```
70+ ````
71+
72+ The contents of ` ./path/to/code.js ` will be loaded and place inside the codeblock using the
73+ indicated language. There is no need to have any content in the codeblock.
74+
75+ - ` partial-content ` allows you to include the contents of a markdown file into another file. That
76+ way you can have a markdown file per technology:
77+
78+ ``` md
79+ # This is an example
80+
81+ {@import ./path/to/example.pmd}
82+ ```
83+
84+ Although the extension is ` .pmd ` (Partial MarkDown), the contents are the same as a regular
85+ markdown file. The reason to change the extension is to avoid building it with Docusaurus.
86+ When using it in combination with [ Docusaurus tabs] and writting MDX, you can end up with
87+ something like the following:
88+
89+ ``` jsx
90+ import Tabs from ' @theme/Tabs' ;
91+ import TabItem from ' @theme/TabItem' ;
92+
93+ < Tabs>
94+ < TabItem value= " electron" label= " Electron" default>
95+ {@import ./electron.pmd}
96+ < / TabItem>
97+ < TabItem value= " pwa" label= " PWA" >
98+ {@import ./pwa.pmd}
99+ < / TabItem>
100+ < TabItem value= " wv2" label= " WebView2" >
101+ {@import ./wv2.pmd}
102+ < / TabItem>
103+ < / Tabs> ;
104+ ` ` `
105+
106+ ` partial- content` files can also make use of ` import -code` .
107+
108+
50109## Adding a new technology
51110
52111To create a new technology overview, run the following command:
@@ -57,10 +116,10 @@ npm run add-technology
57116
58117You will be prompted the technology name and once provided:
59118
60- * a new folder will be created under ` /docs/ ` with its name
61- * the folder will have a few markdown files for you to complete
62- * ` sidebars.js ` will be updated to include the new technology
63- * a new file will be created under ` /data/technologies/TECHNOLOGY.js `
119+ - a new folder will be created under ` / docs/ ` with its name
120+ - the folder will have a few markdown files for you to complete
121+ - ` sidebars .js ` will be updated to include the new technology
122+ - a new file will be created under ` / data/ technologies/ TECHNOLOGY .js `
64123 for you to complete
65124
66125
@@ -175,9 +234,10 @@ and it will generate a table using the property names of the 1st
175234object as the column names, adding a new line per item in the Array:
176235
177236` ` ` markdown
178- | Version | Date |
179- | --- | --- |
180- | vX.Y.Z | 2021/10/01 |
237+ | Version | Date |
238+ | ------ - | ---------- |
239+ | vX .Y .Z | 2021 / 10 / 01 |
240+
181241...
182242` ` `
183243
@@ -191,10 +251,15 @@ and the output will be:
191251
192252` ` ` markdown
193253| Version |
194- | --- |
195- | vX.Y.Z |
254+ | ------ - |
255+ | vX .Y .Z |
256+
196257...
197258` ` `
198259
260+ <!-- Reference links -->
261+
262+ [Docusaurus tabs]: https://docusaurus.io/docs/markdown-features/tabs
199263[git]: https://git-scm.com/downloads
200- [ node.js ] : https://nodejs.org/en/download/
264+ [node.js]: https://nodejs.org/en/download/
265+ [transformers]: https://github.com/crossplatform-dev/crossplatform.dev/tree/main/src/transformers
0 commit comments