Comments (8)
Is there a workaround?
No unfortunately, keywords are not available on the nunjucks side, because list of keywords are actually created based on nunjucks and markdown output, so it's just not possible.
from ng-doc.
Is there a workaround?
No unfortunately, keywords are not available on the nunjucks side, because list of keywords are actually created based on nunjucks and markdown output, so it's just not possible.
No problem, I was able to achieve it by leveraging the code tag and having an absolute position of the anchor tag occupying the complete width of the tile :)
from ng-doc.
No, this will not work that way.
To help you better understand what is happening, I'll describe the working principle:
- First, NgDoc renders your markdown file using Nunjucks, thus calling all macros, functions, etc., to obtain the final markdown file.
- Then the markdown file is transformed into HTML.
- After that, post-processing starts, during which all used keywords will be replaced with links. NgDoc checks for keywords in all inline codes and code blocks.
Therefore, you are getting NAN because *CustomAngularComponentPage
is not an available variable; it is simply a string value that will be replaced at the post-processing stage.
Solution:
As a solution to the problem, you can change your code as follows:
{% macro createBoxWithLink(title, description, keyword_link) %}
<div class="square">
<p>{{ title }}</p>
<p>{{ description }}</p>
`{{keyword_link}}`
</div>
{% endmacro %}
{{ createBoxWithLink('Ng Doc', 'NgDoc is a library for creating documentation for your Angular projects, it is injected into the build process of a regular Angular application and creates documentation that can be displayed in it.', '*CustomAngularComponentPage') }}
So you just need to provided keywords as a string, and render inside of inline code. This way, the string {{keyword_link}}
will be transformed into inline code and replaced with a link at the post-processing stage.
from ng-doc.
No, this will not work that way. To help you better understand what is happening, I'll describe the working principle:
- First, NgDoc renders your markdown file using Nunjucks, thus calling all macros, functions, etc., to obtain the final markdown file.
- Then the markdown file is transformed into HTML.
- After that, post-processing starts, during which all used keywords will be replaced with links. NgDoc checks for keywords in all inline codes and code blocks.
Therefore, you are getting NAN because
*CustomAngularComponentPage
is not an available variable; it is simply a string value that will be replaced at the post-processing stage.Solution:
As a solution to the problem, you can change your code as follows:
{% macro createBoxWithLink(title, description, keyword_link) %} <div class="square"> <p>{{ title }}</p> <p>{{ description }}</p> `{{keyword_link}}` </div> {% endmacro %} {{ createBoxWithLink('Ng Doc', 'NgDoc is a library for creating documentation for your Angular projects, it is injected into the build process of a regular Angular application and creates documentation that can be displayed in it.', '*CustomAngularComponentPage') }}
So you just need to provided keywords as a string, and render inside of inline code. This way, the string
{{keyword_link}}
will be transformed into inline code and replaced with a link at the post-processing stage.
Hi @skoropadas,
Thank you so much for your response. I did give it a try but no luck. Please find the screenshot below. I have also checked in my changes to my GitHub repo.
The above solution only would prove me an independent link. I also want to achieve that my whole tile clickable. Below is the Macro. I have also updated my example and added this macro as well.
{% macro createClicklableBoxTile(title, description, keyword_link) %}
<a href="`{{keyword_link}}`">
<div class="square">
<p>{{ title }}</p>
<p>{{ description }}</p>
</div>
</a>
{% endmacro %}
from ng-doc.
Ah, I see, it's happening because there is no space between div
and the used keyword, it is known behavior of the marked
library that is used under the hood, so if you add a space, then it should start working:
{% macro createBoxWithLink(title, description, keyword_link) %}
<div class="square">
<p>{{ title }}</p>
<p>{{ description }}</p>
</div>
`{{keyword_link}}`
{% endmacro %}
But then you'll have another problem, markdown syntax is not supported inside HTML nodes, so if you try to put your keyword into the div
you'll face the same issue. As a workaround, you can use the code
tag, which is the HTML definition of inline code.
{% macro createBoxWithLink(title, description, keyword_link) %}
<div class="square">
<p>{{ title }}</p>
<p>{{ description }}</p>
<code>{{ keyword_link }}</code>
</div>
{% endmacro %}
from ng-doc.
But the thing that you are trying to achieve using createClicklableBoxTile
is not supported atm.
from ng-doc.
But the thing that you are trying to achieve using
createClicklableBoxTile
is not supported atm.
Is there a workaround? Is it possible to access APIs which can provide the link path based on the keywords either in macros or from angular custom components? So I can use the API to set a variable in macros and pass the variable in the macro function. If not, I have to use hardcoded paths for the links and change them wherever used when the category changes for a page :(
Another option would be, so probably instead of using a macro template, I will use an angular component which renders tiles and use the macro demo API to render the component like this on the markdown page.
{{ NgDocActions.demo("ButtonDemoComponent", {container: false}) }}
from ng-doc.
Ah, I see, it's happening because there is no space between
div
and the used keyword, it is known behavior of themarked
library that is used under the hood, so if you add a space, then it should start working:{% macro createBoxWithLink(title, description, keyword_link) %} <div class="square"> <p>{{ title }}</p> <p>{{ description }}</p> </div> `{{keyword_link}}` {% endmacro %}
But then you'll have another problem, markdown syntax is not supported inside HTML nodes, so if you try to put your keyword into the
div
you'll face the same issue. As a workaround, you can use thecode
tag, which is the HTML definition of inline code.{% macro createBoxWithLink(title, description, keyword_link) %} <div class="square"> <p>{{ title }}</p> <p>{{ description }}</p> <code>{{ keyword_link }}</code> </div> {% endmacro %}
Thank you so much the suggested solution works :)
from ng-doc.
Related Issues (20)
- [Feature] Remove Google Fonts HOT 4
- [Bug] ng-doc.routing.ts incorrect generated import HOT 10
- [Bug] input aliasing decorator selector not rendered correctly HOT 4
- [Feature] Support template variables for inputs HOT 11
- [Bug] hidden: true in NgDocPage-Config does not avoid displaying a component in the navigation. HOT 7
- [Bug] Table of contents link does not work properly with basehref HOT 4
- [Feature] Unable to leverage Custom Angular Components in the Markdown file HOT 6
- Support for Mermaid HOT 7
- [Bug] Unable to build docs when Playground refers components from angular library HOT 3
- [Bug] Extra /docs is introduced in the home icon of the breadcrumb during configuration of NgDoc route prefix HOT 4
- [Bug] Unable to display demo details of the components from angular library HOT 3
- [Query] Is it possible to import macros from angular library? HOT 5
- [Bug]Unable to customize the title of the API page HOT 1
- [Bug] The id of the html header is not serialized HOT 2
- Support for native i18n / $localize + localized markdown HOT 6
- [Feature] Demo Pane viewport and theme support
- [Feature] Custom Tabs in Demo HOT 5
- [Feature] Display Component Properties in Component Tabs and on Page HOT 1
- [Bug] Configure Home icon route path of breadcrumb
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-doc.