summaryrefslogtreecommitdiffstats
path: root/Editor.md
blob: dd53b4b4c1fdaecf842080db9a8cda250ff4eefb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
If you want to reference another item (e.g. a post or a category) in your content, please do not put the URL to it hard coded into the editor. Consider what happens if you change your blog's address (or just the base directory) in the future. You would need to change all the hard coded URLs in your content which is inflexible and not cool. Therefore, you can use the following so-called [*content functions*](Content_Functions) to link an item or a resource of your installation dynamically within your Markdown content.

**Note:** You can combine these functions with Markdown syntax since they are processed and transformed before the Markdown parser finally transforms the content to HTML. There is even the possibility [to add your own custom functions](Content_Functions#how-to-add-custom-functions).

## Relative URLs
You can link any resource (e.g. a file) which is located anywhere within your document root dynamically, either relative to your base directory (the installation directory) or relative to the `rsrc` directory where you store your files, images and other stuff. The `BASE_URL` and `FILE_URL` functions will return the pure plain text URL (extended by the first argument).

### Example #1
~~~markdown
Hello there. Check out [the README]({BASE_URL: "readme.md"})!
~~~
~~~markdown
<!-- Result after the functions were transformed: -->
Hello there. Check out [the README](https://blog.git/readme.md)!
~~~
~~~html
<!-- Final result after the Markdown was transformed: -->
Hello there. Check out <a href="https://blog.git/readme.md">the README</a>!
~~~

### Example #2
~~~markdown
![A cute kitten]({FILE_URL: "image/content/kitten.jpg"} "Look at this!")
~~~
~~~markdown
<!-- Result after the functions were transformed: -->
![A cute kitten](https://blog.git/rsrc/image/content/kitten.jpg "Look at this!")
~~~
~~~html
<!-- Final result after the Markdown was transformed: -->
<img src="https://blog.git/rsrc/image/content/kitten.jpg" alt="A cute kitten" title="Look at this!" />
~~~

## Linking items in your content (categories, pages, posts and users)
The following examples show you how to link a post in the content editor from any other item.

Instead of returing just the pure URL like the `BASE_URL` or `FILE_URL` functions do, the item functions returning the complete Markdown formatted hyperlink syntax (including the text for the `title` attribute).

The first argument is expected to be the unique ID of the item (which you can find in the administration area). If the second argument is present, it will be used as the hyperlink text; if it is omitted, the post title will be used as the hyperlink text. The third and last argument, if present, is used to customize the text for the `title` attribute of the final HTML's `<a>` tag.

### Example #1
~~~markdown
Hello there! Check out this post: {POST: 1}
~~~
~~~markdown
<!-- Result after the functions were transformed: -->
Hello there! Check out this post: [»Hello World!«](https://blog.git/post/hello-world/ "Post »Hello World!«")
~~~
~~~html
<!-- Final result after the Markdown was transformed: -->
Hello there! Check out this post: <a href="https://blog.git/post/hello-world/" title="Post »Hello World!«">»Hello World!«</a>
~~~

### Example #2
~~~markdown
Hello there! Check out {POST: 1, "this post"}!
~~~
~~~markdown
<!-- Result after the functions were transformed: -->
Hello there! Check out [this post](https://blog.git/post/hello-world/ "Post »Hello World!«")!
~~~
~~~html
<!-- Final result after the Markdown was transformed: -->
Hello there! Check out <a href="https://blog.git/post/hello-world/" title="Post »Hello World!«">this post</a>!
~~~

### Example #3
~~~markdown
Hello there! Check out {POST: 1, "this post", "Click to show post"}!
~~~
~~~markdown
<!-- Result after the functions were transformed: -->
Hello there! Check out [this post](https://blog.git/post/hello-world/ "Click to show post")!
~~~
~~~html
<!-- Final result after the Markdown was transformed: -->
Hello there! Check out <a href="https://blog.git/post/hello-world/" title="Click to show post">this post</a>!
~~~

**Note:** The same syntax can also be used for the `CATEGORY`, `PAGE` and `USER` functions!