I have a posts section in my site, with an index page with posts ordered by date, and a section with a more structured page structure containing information on a D&D setting. I want to be able to put a post both in the content collection used by the posts (so it shows up in the post list), and in the page structure (eg at specific path foo/setting/places/bar), without copypasting the files.
My initial idea was adding a 'ref' field to the post's frontmatter with the path to the static page written in it, which if set would make the renderer ignore the post's content and instead load the content of the page at foo/setting/places/bar via glob to use it, but I get
Invalid glob import syntax: Could only use literals
when doing so:
export async function renderTypedPost<T extends DefaultFrontmatter>(post: CollectionEntry<keyof AnyEntryMap>) {
const { Content, remarkPluginFrontmatter } = await render(post);
const data = remarkPluginFrontmatter as T;
if (data.ref) {
const refPath = `@/pages/${data.ref}.*`.replace("//", "/");
const [refFile] = Object.values(import.meta.glob(refPath, { eager: true }));
console.log(refFile);
}
return { post, data, Content };
}
any other way to accomplish this?