Gozer هو منشئ مواقع ثابتة سريع وبسيط مكتوب بلغة Golang.
نماذج من مواقع الويب باستخدام Gozer:
يمكنك تثبيت Gozer عن طريق تثبيت برنامج التحويل البرمجي Go أولاً ثم تشغيل:
go install git.sr.ht/~dvko/gozer@latest قم بتشغيل gozer new لإنشاء بنية دليل فارغة بسرعة.
├── config.toml # Configuration file
├── content # Posts and pages
│ └── index.md
├── public # Static files
└── templates # Template files
└── default.html ثم قم بتشغيل gozer build لإنشاء موقعك.
أي ملفات Markdown موضوعة في دليل content/ الخاص بك ستؤدي إلى ظهور صفحة HTML في دليل البناء الخاص بك بعد تشغيل gozer build .
على سبيل المثال:
content/index.md بإنشاء ملف build/index.html بحيث يمكن الوصول إليه عبر HTTP على /content/about.md ملفًا build/about/index.html بحيث يمكن الوصول إليه عبر HTTP على /about/ . قم بتشغيل gozer بدون أية وسائط لعرض نص المساعدة.
Gozer - a fast & simple static site generator
Usage: gozer [OPTIONS] <COMMAND>
Commands:
build Deletes the output directory if there is one and builds the site
serve Builds the site and starts an HTTP server on http://localhost:8080
new Creates a new site structure in the given directory
Options:
-r, --root <ROOT> Directory to use as root of project (default: .)
-c, --config <CONFIG> Path to configuration file (default: config.toml)
يجب أن ينتهي كل ملف في دليل content/ الخاص بك بـ .md وأن يحتوي على واجهة TOML تحدد عنوان الصفحة:
+++
title = " My page title "
+++
Page content here. القالب الافتراضي لكل صفحة هو default.html . يمكنك تجاوزه عن طريق تعيين متغير template في مسألتك الأمامية.
+++
title = " My page title "
template = " special-page.html "
+++
Page content here. يتم تشغيل القوالب بواسطة حزمة html/template القياسية الخاصة بـ Go، لذا يمكنك استخدام كافة الإجراءات الموضحة هنا.
يتلقى كل قالب مجموعة المتغيرات التالية:
Pages # Slice of all pages in the site
Posts # Slice of all posts in the site (any page with a date in the filename)
Site # Global site properties: Url, Title
Page # The current page: Title, Permalink, UrlPath, DatePublished, DateModified
Title # The current page title, shorthand for Page.Title
Content # The current page's HTML content.
متغير Page هو مثيل للكائن أدناه:
type Page struct {
// Title of this page
Title string
// Template this page uses for rendering. Defaults to "default.html".
Template string
// Time this page was published (parsed from file name).
DatePublished time.Time
// Time this page was last modified on the filesystem.
DateModified time.Time
// The full URL to this page, including the site URL.
Permalink string
// URL path for this page, relative to site URL
UrlPath string
// Path to source file for this page, relative to content root
Filepath string
}
لعرض قائمة بأحدث 5 منشورات:
{{ range (slice .Posts 0 5) }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <small>{{ .DatePublished.Format "Jan 02, 2006" }}</small><br />
{{ end }}
يحدث تطوير Gozer على Sourcehut. يتم قبول التصحيحات عبر البريد الإلكتروني.
Gozer مفتوح المصدر بموجب ترخيص MIT.