Update toggleStarred.ts

This commit is contained in:
nbats 2025-01-21 22:37:15 -08:00 committed by GitHub
parent 2003db4584
commit b866a618a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import type { MarkdownRenderer } from 'vitepress' import type { MarkdownRenderer } from 'vitepress'
const excluded = ['Beginners Guide'] const excluded = ['Beginners Guide']
@ -25,12 +24,17 @@ export function toggleStarredPlugin(md: MarkdownRenderer) {
!excluded.includes(env.frontmatter.title) && !excluded.includes(env.frontmatter.title) &&
contentToken && contentToken &&
( (
contentToken.content.includes(':star:') || // Check if it contains ⭐ contentToken.content.includes(':star:') ||
contentToken.content.includes(':star2:') // Check if it contains 🌟 contentToken.content.includes(':star2:')
) )
) { ) {
return `<li class="starred">` // Replace the placeholders with HTML
contentToken.content = contentToken.content
.replace(':star:', '<span class="star">⭐</span>') // Use HTML for star
.replace(':star2:', '<span class="star2">🌟</span>'); // Use HTML for star2
return `<li class="starred">`;
} }
return self.renderToken(tokens, index, options) return self.renderToken(tokens, index, options);
} };
} }