Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cmd/default_theme/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/
.DS_Store
17 changes: 17 additions & 0 deletions src/cmd/default_theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# My Zola Site

This site is built with [Zola](https://www.getzola.org/).

## Getting Started

```bash
# Serve the site locally
zola serve

# Build for production
zola build
```

## Documentation

Visit [https://www.getzola.org/documentation](https://www.getzola.org/documentation) for full documentation.
5 changes: 5 additions & 0 deletions src/cmd/default_theme/content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
title = "Home"
+++

Welcome to your new Zola site!
101 changes: 101 additions & 0 deletions src/cmd/default_theme/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* Reset and base styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: #333;
background: #fff;
max-width: 720px;
margin: 0 auto;
padding: 1.5rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
margin-top: 1.5rem;
margin-bottom: 0.75rem;
line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
margin-bottom: 1rem;
}

/* Links */
a {
color: #0066cc;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

/* Header */
header {
margin-bottom: 3rem;
padding-bottom: 1rem;
border-bottom: 1px solid #ddd;
}

nav a {
margin-right: 1rem;
}

/* Main content */
main {
min-height: 60vh;
}

article {
margin-bottom: 2rem;
}

/* Lists */
ul, ol {
margin-left: 1.5rem;
margin-bottom: 1rem;
}

li {
margin-bottom: 0.25rem;
}

/* Footer */
footer {
margin-top: 3rem;
padding-top: 1.5rem;
border-top: 1px solid #ddd;
color: #666;
font-size: 0.9rem;
}

/* Code */
code {
background: #f4f4f4;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-size: 0.9em;
}

pre {
background: #f4f4f4;
padding: 1rem;
border-radius: 3px;
overflow-x: auto;
margin-bottom: 1rem;
}

pre code {
background: none;
padding: 0;
}
22 changes: 22 additions & 0 deletions src/cmd/default_theme/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{{ config.title }}{% endblock %}</title>
<link rel="stylesheet" href="{{ get_url(path="style.css") }}">
</head>
<body>
<header>
<nav>
<a href="{{ get_url(path="/") }}">Home</a>
</nav>
</header>
<main>
{% block content %}{% endblock %}
</main>
<footer>
<p>Powered by <a href="https://www.getzola.org/">Zola</a></p>
</footer>
</body>
</html>
6 changes: 6 additions & 0 deletions src/cmd/default_theme/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "base.html" %}

{% block content %}
<h1>{{ section.title }}</h1>
{{ section.content | safe }}
{% endblock %}
10 changes: 10 additions & 0 deletions src/cmd/default_theme/templates/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "base.html" %}

{% block title %}{{ page.title }} | {{ config.title }}{% endblock %}

{% block content %}
<article>
<h1>{{ page.title }}</h1>
{{ page.content | safe }}
</article>
{% endblock %}
16 changes: 16 additions & 0 deletions src/cmd/default_theme/templates/section.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "base.html" %}

{% block title %}{{ section.title }} | {{ config.title }}{% endblock %}

{% block content %}
<h1>{{ section.title }}</h1>
{{ section.content | safe }}

{% if section.pages %}
<ul>
{% for page in section.pages %}
<li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
39 changes: 39 additions & 0 deletions src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ theme = "catppuccin-mocha"
# Put all your custom variables here
"#;

const GITIGNORE: &str = include_str!("default_theme/.gitignore");
const README: &str = include_str!("default_theme/README.md");
const INDEX_CONTENT: &str = include_str!("default_theme/content/_index.md");
const BASE_TEMPLATE: &str = include_str!("default_theme/templates/base.html");
const INDEX_TEMPLATE: &str = include_str!("default_theme/templates/index.html");
const PAGE_TEMPLATE: &str = include_str!("default_theme/templates/page.html");
const SECTION_TEMPLATE: &str = include_str!("default_theme/templates/section.html");
const STYLE_CSS: &str = include_str!("default_theme/static/style.css");

Comment thread
nooscraft marked this conversation as resolved.
// canonicalize(path) function on windows system returns a path with UNC.
// Example: \\?\C:\Users\VssAdministrator\AppData\Local\Temp\new_project
// More details on Universal Naming Convention (UNC):
Expand Down Expand Up @@ -112,11 +121,25 @@ fn populate(path: &Path, compile_sass: bool, config: &str) -> Result<()> {
if !path.exists() {
fs::create_dir(path)?;
}

create_file(&path.join("zola.toml"), config)?;
create_file(&path.join(".gitignore"), GITIGNORE)?;
create_file(&path.join("README.md"), README)?;

fs::create_dir(path.join("content"))?;
create_file(&path.join("content/_index.md"), INDEX_CONTENT)?;

fs::create_dir(path.join("templates"))?;
create_file(&path.join("templates/base.html"), BASE_TEMPLATE)?;
create_file(&path.join("templates/index.html"), INDEX_TEMPLATE)?;
create_file(&path.join("templates/page.html"), PAGE_TEMPLATE)?;
create_file(&path.join("templates/section.html"), SECTION_TEMPLATE)?;

fs::create_dir(path.join("static"))?;
create_file(&path.join("static/style.css"), STYLE_CSS)?;

fs::create_dir(path.join("themes"))?;

if compile_sass {
fs::create_dir(path.join("sass"))?;
}
Expand Down Expand Up @@ -192,9 +215,17 @@ mod tests {
populate(&dir, true, "").expect("Could not populate zola directories");

assert!(dir.join("zola.toml").exists());
assert!(dir.join(".gitignore").exists());
assert!(dir.join("README.md").exists());
assert!(dir.join("content").exists());
assert!(dir.join("content/_index.md").exists());
assert!(dir.join("templates").exists());
assert!(dir.join("templates/base.html").exists());
assert!(dir.join("templates/index.html").exists());
assert!(dir.join("templates/page.html").exists());
assert!(dir.join("templates/section.html").exists());
assert!(dir.join("static").exists());
assert!(dir.join("static/style.css").exists());
assert!(dir.join("themes").exists());
assert!(dir.join("sass").exists());

Expand All @@ -212,9 +243,17 @@ mod tests {

assert!(dir.exists());
assert!(dir.join("zola.toml").exists());
assert!(dir.join(".gitignore").exists());
assert!(dir.join("README.md").exists());
assert!(dir.join("content").exists());
assert!(dir.join("content/_index.md").exists());
assert!(dir.join("templates").exists());
assert!(dir.join("templates/base.html").exists());
assert!(dir.join("templates/index.html").exists());
assert!(dir.join("templates/page.html").exists());
assert!(dir.join("templates/section.html").exists());
assert!(dir.join("static").exists());
assert!(dir.join("static/style.css").exists());
assert!(dir.join("themes").exists());
assert!(dir.join("sass").exists());

Expand Down