packages/sphido-hashtags/lib/hashtags.js
/**
 * Replace hashtags in markdown with links
 * @param {Object} page
 */
Replace hashtags in markdown with links
@param {Object} page
Replace hashtags in markdown with links @param { Object } page
function hashtags(page) {
	const tags = page.content
		.replace(/`{1,3}[^`]*`{1,3}/gim, '') 
		.match(/(?<=^|\s)#([\w-]{2,})/gim); 
	page.tags = new Set(tags?.map(tag => tag.slice(1))); 
	if (tags) {
		const anchor = new RegExp('(' + tags.join('|') + ')', 'gmi');
		page.content = page.content.replace(anchor, (match, capture) => `[${match}](/tag/${slugify(capture)})`);
	}
}
function hashtags ( page ) { const tags = page . content . replace ( / `{1,3}[^`]*`{1,3} / gim , '' ) . match ( / (?<=^|\s)#([\w-]{2,}) / gim ) ; page . tags = new Set ( tags ?. map ( tag => tag . slice ( 1 ) ) ) ; if ( tags ) { const anchor = new RegExp ( '(' + tags . join ( '|' ) + ')' , 'gmi' ) ; page . content = page . content . replace ( anchor , ( match , capture ) => ` ${ match } ${ slugify ( capture ) } ` ) ; } }
Replace hashtags in markdown with links
 @param {Object} page
Replace hashtags in markdown with links @param { Object } page
// Skip code // Match all tags // Create unique tags list