📜  Grav-模块化页面

📅  最后修改于: 2020-10-25 05:20:29             🧑  作者: Mango


模块化页面一开始很难理解,但是一旦您了解它,它就会非常容易使用。它允许从其子页面创建单个页面。它具有从模块化内容页面构建复杂的一页布局的能力。

模块化页面被设置为不可路由,因为无法通过URL直接访问它们。它们在文件夹名称之前用_(下划线)标识。它是页面的集合,每个页面上方显示一个页面。例如, user / pages / home / _header。

资料夹结构

如果是一页框架,则可以在01.home文件夹中找到此页面。在此,您将获得一个模块化的.md文件,该文件告诉您必须包括哪些页面以及要显示的页面顺序。可以在您当前的主题文件夹中找到modular.html.twig。

在下图中,您可以看到为模块化页面创建的文件夹结构。

Grav模块化页面

每个子文件夹必须包含描述减价文件的.md文件。

首先,您必须在/users/pages/01.home文件夹中创建子文件夹。接下来,每个文件夹必须包含一个.md文件和一个module.md文件。

创建子文件夹时,图像和文件都必须位于同一文件夹中。

如何创建模块化页面

要创建模块化页面,您必须遵循给定的步骤。

步骤1-/user/pages/01.home/中创建一些页面。夹。在下面的图像中,您可以看到我们已经创建了两个文件夹以及module.md文件。

Grav模块化页面

步骤2-要创建模块化页面,必须在每个文件夹中创建一个文件,并将其命名为text.md。

Grav模块化页面

步骤3-接下来,将您的代码添加到text.md文件中,保存并运行相同的代码。

将所有四个页面另存为.md文件。在这里,我们创建了4个页面,并分别命名为text.md,text1.md,text2.md和text3.md。

---
title: Bio-diversity
---

## Bio-diversity

Biodiversity refers to the variety of life. It is seen in the number of species in an 
[ecosystem](https://simple.wikipedia.org/wiki/Ecosystem) or on the entire [Earth]
(https://simple.wikipedia.org/wiki/Earth). Biodiversity gets used as a measure of the
health of biological systems, and to see if there is a danger that too many species
become[extinct](https://simple.wikipedia.org/wiki/Extinct).

现在,创建4页,如下所示将它们添加到\ templates \ modular文件夹中。

Grav模块化页面

接下来,转到主页并刷新,您可以看到更改。

Grav模块化页面

在新的导航栏中,您可以看到四个文件链接。