liquidRenderer = $liquidRenderer; } public function index() { //模板支持多级目录,需要目录符号 $output = LiquidRenderer::render('collection_list.liquid', [ ]); return response($output); } public function detail($slug) { // Check if the $slug is numeric (ID), if so, fetch by ID if (is_numeric($slug)) { $tag = SitePageTag::find($slug); // Find by ID } else { // Otherwise, find by slug $tag = SitePageTag::where('slug', $slug)->first(); } if (!$tag) { return response()->json(['message' => '标签未找到'], 404); } // 获取关联的 pages $pages = $tag->pages()->get(); //模板支持多级目录,需要目录符号 $output = LiquidRenderer::render('collection_list.liquid', [ 'tag' => $tag, 'pages' => $pages, ]); return response($output); } }