-
Notifications
You must be signed in to change notification settings - Fork 28
Editor
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 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.
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 static
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).
Hello there. Check out [the README]({BASE_URL: "readme.md"})!
<!-- Result after the functions were transformed: -->
Hello there. Check out [the README](https://blog.git/readme.md)!
<!-- Final result after the Markdown was transformed: -->
Hello there. Check out <a href="https://blog.git/readme.md">the README</a>!

<!-- Result after the functions were transformed: -->

<!-- Final result after the Markdown was transformed: -->
<img src="https://blog.git/static/image/content/kitten.jpg" alt="A cute kitten" title="Look at this!" />
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.
Hello there! Check out this post: {POST: 1}
<!-- Result after the functions were transformed: -->
Hello there! Check out this post: [»Hello World!«](https://blog.git/post/hello-world/ "Post »Hello World!«")
<!-- 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>
Hello there! Check out {POST: 1, "this post"}!
<!-- Result after the functions were transformed: -->
Hello there! Check out [this post](https://blog.git/post/hello-world/ "Post »Hello World!«")!
<!-- 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>!
Hello there! Check out {POST: 1, "this post", "Click to show post"}!
<!-- Result after the functions were transformed: -->
Hello there! Check out [this post](https://blog.git/post/hello-world/ "Click to show post")!
<!-- 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!