Auto-Linkify Words

Likely because folks don’t know, I got referred to this post looking for solution to link search words to topics and my default reaction was to install this component. I didn’t even realize that watched words existed. It’s so cool how much I learn about discourse every time I try to optimize it.

If you’re okay I’m going to edit the first post to let folks know that watched words exist and may be an out of box fit. Also this theme is marked as official so if it’s a duplicate of watched words maybe consider depreciating it or indicating it on the first post.

1개의 좋아요

I have a feature request. It would be wonderful if we could have this only apply to body text and not headings, it looks silly when one word in a heading is linked:

Sometimes, there are too many same linkify words in long content.
I think it be better to display in only first one in content. The others could be bold, instead of links.

2개의 좋아요

Seems like you should be able to do that by adding h1 h2 and others to the " excluded tags" setting in the extension, no?

Thanks Matt, I think you mean excluded classes, which I somehow didn’t notice before, but unfortunately these are not working so I guess this is a bug report rather than a feature request.

The screenshot I posted earlier is an h2 with class of anchor.

No, I meant tags. Those are HTML tags, not discourse topic tags, as I understand it.

Indeed, you are correct! Thank you Matt. I was too fixated on tags being discourse tags. I appreciate your help.

1개의 좋아요

Can you tell me if it is possible to import multiple linkify words at the same time or use the API to connect to a management file on Google Sheets? I have an idea about using this TC in managing and creating multiple glossaries

I find this theme component interesting and useful, but it links keywords too many times, attaching it correctly is only attaching the first word to reduce spam.

I sent an attached image and it repeats 3 times for 1 keyword. I hope this part will be fixed in the next update.

3개의 좋아요

안녕하세요! 멋진 플러그인 감사합니다!

간단한 질문 하나만 드리고 싶은데요. 단어 앞에 공백이 없거나 뒤에 공백이 없는 경우에도 매칭이 가능한가요? 예전에는 단어 주변에 공백이 없어도 매칭이 되던 것 같은데.

2개의 좋아요

안녕하세요, 링크를 target=“_self"로 설정할 방법이 있을까요? 기본적으로 모든 링크가 새 탭(target=”_blank")에서 열리는데, 이 설정을 변경할 옵션을 찾을 수 없었습니다.

많은 도움 부탁드립니다.

https://meta.discourse.org/my/preferences/interface

에서 모든 외부 링크를 새 탭에서 열기를 검색하세요. 이는 모범 사례(Best Practice)이기 때문에 기본적으로 꺼져 있습니다. /admin/site_settings/category/all_results?filter=external%20links를 사용하여 모든 사용자의 기본값을 변경할 수 있습니다.

1개의 좋아요

이 설정은 게시물 내의 일반 링크에는 적용되지만, 저의 경우 이 컴포넌트가 생성한 링크는 항상 새 탭에서 열립니다. 이 설정이 여러분에게도 이 컴포넌트가 생성한 링크의 동작 방식을 변경하나요? 제가 놓치고 있는 것이 무엇인지 궁금합니다.

1개의 좋아요

아, 죄송합니다. 그 부분을 놓치고 있었습니다. 말씀이 맞습니다. blank로 하드코딩되어 있네요:

합리적인 기능 요청이라고 생각합니다.

잠깐. 정말로 주의를 기울이지 않고 있었습니다. 사용자 설정을 무시하고 하드코딩된 옵션이 있다면, 같은 창에서 열리도록 해야 합니다. 그것이 모범 사례입니다. 그리고 링크화된 링크가 외부가 아니라 Discourse 내부로 가는데 새 탭에서 열린다면, 그건 훨씬 더 의도치 않은 동작입니다.

3개의 좋아요

JavaScript(아래 코드 참조)로 이 문제를 해결하려고 해 봤는데, 간헐적으로만 작동합니다. Ember.js가 충돌을 일으키고 있는 것 같습니다. 그래서 이상적이지 않아요

<script>
	window.addEventListener("load", function() {
		document.querySelectorAll("a.linkify-word.no-track-link").forEach(function(link) {
			link.removeAttribute("target");
		});
	});
</script>

더 나은 해결책은 테마 컴포넌트를 포크하거나 PR을 제출하는 것입니다.

1개의 좋아요

얼마나 가치가 있는지는 모르겠지만, target=“_self"와 target=”_blank" 사이를 전환할 수 있는 백엔드 체크박스를 추가하는 방법에 대해 ChatGPT에게 물어보았습니다. 아래는 ChatGPT가 제안한 내용입니다:

settings.yaml 코드:

self_target:
  type: bool
  default: false
  client: true

initialize-discourse-linkify.js 코드:

  let createLink = function (text, url) {
	let link = document.createElement("a");
	link.innerHTML = text;
	link.href = url;
	link.rel = "nofollow";
	link.target = settings.self_target ? "_self" : "_blank"; // 관리자 설정을 여기서 사용
	link.className = "linkify-word no-track-link";
	return link;
  };

이게 작동할까요?