feat: published recipes

This commit is contained in:
Leyla Becker 2026-02-20 13:03:17 -06:00
parent 0507d5c52f
commit e84f6f9899
64 changed files with 119 additions and 69 deletions

View file

@ -3,6 +3,44 @@ const path = require("path");
const { execSync } = require("child_process");
const { DateTime } = require("luxon");
const extractDietTags = (filePath) => {
try {
const content = fs.readFileSync(filePath, 'utf-8');
const dietTagRegex = /#diet\/(omnivore|vegetarian|plant-based)(?:\/optional)?/g;
const matches = content.match(dietTagRegex) || [];
return matches.map(tag => {
const match = tag.match(/#diet\/(omnivore|vegetarian|plant-based)/);
return match ? match[1] : null;
}).filter(Boolean);
} catch (e) {
return [];
}
}
const getPlantBased = (filePath) => {
const dietTags = extractDietTags(filePath);
if (dietTags.length === 0) {
return null;
}
const hasOmnivore = dietTags.includes('omnivore');
const hasVegetarian = dietTags.includes('vegetarian');
const hasPlantBased = dietTags.includes('plant-based');
if (hasPlantBased) {
return true;
}
// If has omnivore OR vegetarian without plant-based, it's not plant-based
if (hasOmnivore || hasVegetarian) {
return false;
}
// No recognized diet tags
return null;
}
const getSlugFromPath = (filePath) => {
// Normalize the path - remove leading ./ if present
const normalizedPath = filePath.startsWith('./') ? filePath.slice(2) : filePath;
@ -161,6 +199,9 @@ module.exports = {
isDraft: (data) => {
return data.draft === true;
},
plantBased: (data) => {
return getPlantBased(data.page.inputPath);
},
createdAt: (data) => {
return getFileCreatedDateTime(data.page.inputPath);
},