@@ -48,6 +48,76 @@ title: Markdown Flavour
48
48
---
49
49
```
50
50
51
+ ## Linking
52
+
53
+ ``` md
54
+ [Heading](#linking)
55
+ [External](https://example.com)
56
+ [Relative Example 1](relative)
57
+ [Relative Example 2](to/folder/page-1)
58
+ [Relative Example 3](../back/page-3)
59
+ ```
60
+
61
+ It is highly recommended to use relative links for internal linking and avoid using absolute links.
62
+ This is because contented pipelines are designed to be portable and can be deployed to different sites or domains.
63
+ By using absolute links, you're assuming that the content will always be deployed to the same domain or the same path.
64
+ When using relative links, contented will automatically resolve the links to the correct destination.
65
+
66
+ For example:
67
+
68
+ ``` js
69
+ /** @type {import('@contentedjs/contented').ContentedConfig} */
70
+ const config = {
71
+ preview: {
72
+ url: ' https://preview.contented.dev' ,
73
+ name: ' Preview Contented' ,
74
+ },
75
+ processor: {
76
+ rootDir: ' ../docs' ,
77
+ pipelines: [
78
+ {
79
+ type: ' ExampleType' ,
80
+ pattern: ' example-docs/**/*md' ,
81
+ processor: ' md' ,
82
+ transform : (file ) => {
83
+ // Notice that the path example-docs/ is removed. There is no way to know how you path is structured.
84
+ // You need therefore use relative links that works universally across all sites.
85
+ // This is intentional to make contented pipelines portable.
86
+ file .path = file .path .replaceAll (/ ^ \/ example-docs\/ ? / g , ' /' );
87
+ file .sections = file .sections .slice (1 );
88
+ return file;
89
+ },
90
+ },
91
+ ],
92
+ },
93
+ };
94
+
95
+ export default config ;
96
+ ```
97
+
98
+ ``` txt
99
+ Pipeline Processed: -> /[path] (note docs/example-docs/ is removed)
100
+ /docs/example-docs/page-1 -> /page-1
101
+ /docs/example-docs/page-2 -> /page-2
102
+ /docs/example-docs/folder/page-3 -> /folder/page-3
103
+
104
+ Preview: -> https://preview.contented.dev/[type]/[path]
105
+ /page-1 -> https://preview.contented.dev/example/page-1
106
+ /page-2 -> https://preview.contented.dev/example/page-2
107
+ /folder/page-3 -> https://preview.contented.dev/example/folder/page-3
108
+
109
+ Another Site: -> https://developer-docs.com/product-example/docs/[path]
110
+ /page-1 -> https://developer-docs.com/product-example/docs/page-1
111
+ /page-2 -> https://developer-docs.com/product-example/docs/page-2
112
+ /folder/page-3 -> https://developer-docs.com/product-example/docs/folder/page-3
113
+ ```
114
+
115
+ Note how "Another Site" consumed the same contented pipeline but deployed to a different domain and path with its own
116
+ custom prefix. If you used absolute links, the links would be broken.
117
+
118
+ It is also highly advised against linking to another ` "Type" ` as you're assuming that the other site will be
119
+ structured the same way as your site with the same prefix or even publishing that ` "Type" ` at all.
120
+
51
121
## Admonitions
52
122
53
123
Admonitions with ` remark-directive ` and ` remark-directive-rehype ` .
@@ -122,8 +192,8 @@ graph LR
122
192
123
193
``` mermaid
124
194
graph TD;
125
- A -->B;
126
- A -->C;
127
- B -->D;
128
- C -->D;
195
+ A --> B;
196
+ A --> C;
197
+ B --> D;
198
+ C --> D;
129
199
```
0 commit comments