diff --git a/src/cmd/default_theme/.gitignore b/src/cmd/default_theme/.gitignore new file mode 100644 index 000000000..0c376eaec --- /dev/null +++ b/src/cmd/default_theme/.gitignore @@ -0,0 +1,2 @@ +public/ +.DS_Store diff --git a/src/cmd/default_theme/README.md b/src/cmd/default_theme/README.md new file mode 100644 index 000000000..5a42eaa3a --- /dev/null +++ b/src/cmd/default_theme/README.md @@ -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. diff --git a/src/cmd/default_theme/content/_index.md b/src/cmd/default_theme/content/_index.md new file mode 100644 index 000000000..4477221b7 --- /dev/null +++ b/src/cmd/default_theme/content/_index.md @@ -0,0 +1,5 @@ ++++ +title = "Home" ++++ + +Welcome to your new Zola site! diff --git a/src/cmd/default_theme/static/style.css b/src/cmd/default_theme/static/style.css new file mode 100644 index 000000000..f31ac5e8a --- /dev/null +++ b/src/cmd/default_theme/static/style.css @@ -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; +} diff --git a/src/cmd/default_theme/templates/base.html b/src/cmd/default_theme/templates/base.html new file mode 100644 index 000000000..a79491e7b --- /dev/null +++ b/src/cmd/default_theme/templates/base.html @@ -0,0 +1,22 @@ + + + + + + {% block title %}{{ config.title }}{% endblock %} + + + +
+ +
+
+ {% block content %}{% endblock %} +
+ + + diff --git a/src/cmd/default_theme/templates/index.html b/src/cmd/default_theme/templates/index.html new file mode 100644 index 000000000..75c1ee1a6 --- /dev/null +++ b/src/cmd/default_theme/templates/index.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block content %} +

{{ section.title }}

+{{ section.content | safe }} +{% endblock %} diff --git a/src/cmd/default_theme/templates/page.html b/src/cmd/default_theme/templates/page.html new file mode 100644 index 000000000..d73bcbbe9 --- /dev/null +++ b/src/cmd/default_theme/templates/page.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block title %}{{ page.title }} | {{ config.title }}{% endblock %} + +{% block content %} +
+

{{ page.title }}

+ {{ page.content | safe }} +
+{% endblock %} diff --git a/src/cmd/default_theme/templates/section.html b/src/cmd/default_theme/templates/section.html new file mode 100644 index 000000000..010ed5d4a --- /dev/null +++ b/src/cmd/default_theme/templates/section.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% block title %}{{ section.title }} | {{ config.title }}{% endblock %} + +{% block content %} +

{{ section.title }}

+{{ section.content | safe }} + +{% if section.pages %} + +{% endif %} +{% endblock %} diff --git a/src/cmd/init.rs b/src/cmd/init.rs index b137bdab0..4283ea0b9 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -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"); + // 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): @@ -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"))?; } @@ -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()); @@ -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());