load titles from metadata in examples page

This commit is contained in:
Roipoussiere 2023-06-05 20:42:41 +02:00
parent f9ad5f0d01
commit 52641db590
3 changed files with 20 additions and 17 deletions

View file

@ -1,19 +1,4 @@
export function getMetadata(raw_code) {
// https://stackoverflow.com/a/15123777
const comment_regexp = /\/\*([\s\S]*?)\*\/|([^\\:]|^)\/\/(.*)$/gm;
const tag_regexp = /@([a-z]*):? (.*)/gm
const tags = {};
for (const match of raw_code.matchAll(comment_regexp)) {
const comment = match[1] ? match[1] : '' + match[3] ? match[3] : '';
for (const tag_match of comment.trim().matchAll(tag_regexp)) {
tags[tag_match[1]] = tag_match[2].trim()
}
}
return tags;
}
import { getMetadata } from '../metadata_parser';
export function getMyPatterns() {
const my = import.meta.glob('../../../../my-patterns/**', { as: 'raw', eager: true });