Compare commits

2 커밋

작성자 SHA1 메시지 날짜
aa944e8894 Add test/example page 2025-05-26 10:23:43 +04:00
f04773a3a9 Find links without content type, prefer typed 2025-05-26 10:23:10 +04:00
2개의 변경된 파일32개의 추가작업 그리고 4개의 파일을 삭제

파일 보기

@@ -1,8 +1,11 @@
document.addEventListener('DOMContentLoaded', function() {
const linkRels = ['alternate', 'me', 'author'];
const selector = linkRels.map(rel => `link[rel="${rel}"][type="application/nostr+json"]`).join(',');
const links = document.querySelectorAll(selector);
const linkMap = new Map();
const linkRels = ['alternate', 'me', 'author'];
const selectorUntyped = linkRels.map(rel => `link[rel="${rel}"][href^="nostr:"]`).join(',');
const selectorTyped = linkRels.map(rel => `link[rel="${rel}"][type="application/nostr+json"]`).join(',');
const untypedLinks = document.querySelectorAll(selectorUntyped);
const typedLinks = document.querySelectorAll(selectorTyped);
const links = [...untypedLinks, ...typedLinks]
const linkMap = new Map();
if (links.length > 0) {
links.forEach(link => {

25
test/example.html Normal file
파일 보기

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example page</title>
<link rel="me" href="nostr:npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees" title="Ru Cao">
<link rel="me" type="application/nostr+json" href="nostr:npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees" title="Râu Cao">
<link rel="alternate" type="application/nostr+json" href="nostr:naddr1qvzqqqr4gupzqplp3zsllp7wzuw4z7uw62ah5vd36dzn5rdnk9fhnmq8kujdyvhnqyfhwue69uhkcmmrv9kxsmmnwsarwdehxuqq6vfhxgunvwp4x5unwve3xcmz28za" title="Testing my new blog">
<link rel="author" type="text/html" href="https://nostr.kosmos.org/@jimmy" title="Jimmy">
<link rel="author" type="application/nostr+json" href="nostr:nprofile1qyfhwue69uhkcmmrv9kxsmmnwsarwdehxuqzqplp3zsllp7wzuw4z7uw62ah5vd36dzn5rdnk9fhnmq8kujdyvhnmg53sl" title="Jimmy">
</head>
<body>
<h1>Nostr Links Examples</h1>
<p>(Inspect link tags in source)</p>
<article>
<h2>Testing my new blog</h2>
<div class="meta"><p>By Jimmy, published on October 23, 2024</p></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <a href="https://njump.me/nprofile1qyt8wumn8ghj7mn0wd68yetvd96x2uewdaexwtcpz4mhxue69uhhyetvv9ujuat50phjummwv5hsqgqmcu9qzj9n7vtd5vl78jyly037wxkyl7vcqflvwy4eqhxjfa4yzyzh27uu" rel="noopener noreferrer">Excepteur</a> sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, <a href="https://en.wikipedia.org/wiki/Lorem_ipsum" rel="noopener noreferrer">consectetur</a> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo <a href="https://njump.me/naddr1qvzqqqr4gupzpwcpwjhzrfk2cxs2nj9543htlkjkeegkqhp3tvvzf9ctcf6lwgu6qqgrjvmyv93nwcmxvvukgdmxxfjn2eqwafx" rel="noopener noreferrer">consequat</a>.</p>
<h3>A sub heading goes a long way</h3>
<p>Lorem ipsum dolor sit amet, <a href="https://en.wikipedia.org/wiki/Lorem_ipsum" rel="noopener noreferrer">consectetur</a> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut <a href="npub1qlsc3g0lsl8pw8230w8d9wm6xxcax3f6pkemz5measrmwfxjxteslf2hac" rel="noopener noreferrer">aliquip ex</a> ea commodo <a href="nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qgkwaehxw309aex2mrp0yhx6mmnw3ezuur4vghsqgq8uxy2rlu8ect365tm3mftk733k8f52wsdkwc4x70vq7mjf53j7v7hknv0" rel="noopener noreferrer">consequat</a>.</p>
</article>
</body>
</html>