Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippet to regenerate table of content #210

Open
trungdq88 opened this issue Nov 23, 2022 · 0 comments
Open

Snippet to regenerate table of content #210

trungdq88 opened this issue Nov 23, 2022 · 0 comments

Comments

@trungdq88
Copy link
Owner

trungdq88 commented Nov 23, 2022

Go to https://github.com/trungdq88/Awesome-Black-Friday-Cyber-Monday/blob/main/README.md

Open dev tool and run this:

let total = 0
let toc = $$('.markdown-body h2, .markdown-body h3, .markdown-body h4').map(heading => {
    const text = heading.innerText
    const hash = heading.nextSibling.getAttribute('href');
    const level = Number(heading.tagName.replace('H', '')) - 2;
    const length = heading.parentElement.nextElementSibling.querySelectorAll('tbody tr').length
    total += length
    const lengthText = length > 0 ? `(${length})` : ''
    return `${new Array(level).fill('	').join('')}- [${text} ${lengthText}](${hash})`;
}).join('\n')
console.log(toc)
console.log('total = %s', total)
copy(`Total deals: ${total}\n\n${toc}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant