mirror of
https://github.com/xvvvyz/tilde.git
synced 2026-03-11 14:44:24 +00:00
amde some fixes to assure that the older suggestion method also works
This commit is contained in:
parent
e9a3596007
commit
80b5797765
1 changed files with 13 additions and 12 deletions
25
index.html
25
index.html
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
// prettier-ignore
|
||||
const COMMANDS = new Map([
|
||||
['t', { name: 'test', suggestions: [{name: 'Claude', url: 'https://claude.ai/new'}], url: 'https://chatgpt.com' }],
|
||||
['a', { name: 'Chat', suggestions: ['a/claude', 'a/gemini'], url: 'https://chatgpt.com' }],
|
||||
['a/claude', { url: 'https://claude.ai/new' }],
|
||||
['a/gemini', { url: 'https://gemini.google.com/app' }],
|
||||
|
|
@ -78,6 +79,8 @@
|
|||
],
|
||||
},
|
||||
],
|
||||
|
||||
// Add more command entries as needed
|
||||
]); */
|
||||
</script>
|
||||
|
||||
|
|
@ -169,17 +172,15 @@
|
|||
const commands = clone.querySelector('.commands');
|
||||
const commandTemplate = document.getElementById('command-template');
|
||||
|
||||
for (const [key, { suggestions }] of COMMANDS.entries()) {
|
||||
if (!suggestions) continue;
|
||||
for (const { name, url } of suggestions) {
|
||||
const clone = commandTemplate.content.cloneNode(true);
|
||||
const command = clone.querySelector('.command');
|
||||
command.href = url;
|
||||
if (CONFIG.openLinksInNewTab) command.target = '_blank';
|
||||
clone.querySelector('.key').innerText = key;
|
||||
clone.querySelector('.name').innerText = name;
|
||||
commands.append(clone);
|
||||
}
|
||||
for (const [key, { name, url }] of COMMANDS.entries()) {
|
||||
if (!name || !url) continue;
|
||||
const clone = commandTemplate.content.cloneNode(true);
|
||||
const command = clone.querySelector('.command');
|
||||
command.href = url;
|
||||
if (CONFIG.openLinksInNewTab) command.target = '_blank';
|
||||
clone.querySelector('.key').innerText = key;
|
||||
clone.querySelector('.name').innerText = name ? name : url;
|
||||
commands.append(clone);
|
||||
}
|
||||
|
||||
this.shadowRoot.append(clone);
|
||||
|
|
@ -522,7 +523,7 @@
|
|||
const ref = clone.querySelector('.suggestion');
|
||||
ref.dataset.index = index;
|
||||
ref.dataset.url = suggestion.url;
|
||||
ref.innerText = suggestion.name;
|
||||
ref.innerText = suggestion.name ? suggestion.name : suggestion;
|
||||
this.#suggestions.append(clone);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue