Closed ghost closed 6 years ago
Hi @rabas007
Which theme is it? In ./themes/_____/layout
you should be able to find how those tags render and customize it.
If you check can you let me know if that is the spot?
@tcrowe - Hi Tony,
I am trying to highlight specific tags within all tags for each individual blogpost.
I use REGEX code for that. It does work in tagcloud.js
, see here... (https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/tagcloud.js)
I added following lines right before line-224:
if(tag.name.match(/[a-zA-Z0-9]+\s*\([a-zA-Z0-9]+\)/)) {
result.push(
'<a class="unique-color-for-specific-tag" href="' + self.url_for(tag.path) + '" style="' + style + '">' +
(transform ? transform(tag.name) : tag.name) +" ("+tag.length+")"+
'</a>'
);
This does what I need in tagcloud
, but I want to apply the same code to the tags
under each blogpost in the posts-overview
and blogpost-page
pages. I just cannot find where they are rendered in which plugin?
Oh that's why I was asking the theme name so we can look for the tag code.
tagcloud
usage is here https://hexo.io/docs/helpers.html#tagcloud
OK, thanks. But how to fit in my REGEX code in there so it renders only the specific tags I want?
My REGEX code... (/[a-zA-Z0-9]+\s*\([a-zA-Z0-9]+\)/))
.
So I do NOT want ALL tags to show in tagcloud, just the ones that match the REGEX rule above.
You never answered my question which theme so I guessed this one:
https://github.com/stkevintan/hexo/blob/master/themes/material-flow/layout/_partial/post.ejs#L24
@tcrowe - yes, this theme. Sorry, I thought it did not matter because my issue is with node_modules
and the hexo
folder > lib > plugins > helper > ???
The code you're looking for is in your theme, not inside node_modules
@tcrowe - I tested it in tagcloud.js for tagcloud
and it works (so it is 100% in node_modules
). I just cannot find where the tags are rendered for the posts
, because I need to do the same for posts
what I did for tagcloud
.
Whenever helpers are not what I need I goto the theme code. I would still argue that's the best place to go. If not maybe someone else can chime in who better understands.
I also create custom helpers sometimes: https://hexo.io/docs/helpers.html
They go in the project root then ➡️./source
Here's an example of one we recently discussed https://github.com/hexojs/hexo/issues/3173#issuecomment-395931673
There are tags under each individual blogpost in the post-overview page / article page.
See image here...
I need to make some javascript changes to those tags, but I cannot find the corresponding file.
(I tried ... node_modules > hexo > lib > plugins > helper > tagcloud).
But that is the wrong one... that one is for the sidebar tagcloud.
I need the tags per individual blogpost in post-page / article-page. Thanks.