Skip to content

Commit 0825b62

Browse files
fixed generate
1 parent 1c58bad commit 0825b62

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

projects/example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>✍️ MiniTemplate - Simple Template Engine</title>
6+
<title>My Default Title</title>
77

88
<!-- DaisyUI with Tailwind CDN -->
99
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.12/dist/full.min.css" rel="stylesheet" />
1010
<script src="https://cdn.tailwindcss.com"></script>
1111
</head>
12-
<body class="flex flex-col min-h-screen" data-theme="aqua">
12+
<body class="flex flex-col min-h-screen" data-theme="cyberpunk">
1313

1414
<div>
1515
<div id="sidebar_default" data-state="closed" class="bg-neutral w-64 h-full fixed top-0 left-0 flex flex-col justify-between transform -translate-x-full md:translate-x-0 transition-transform duration-300 ease-in-out z-10">

projects/example/template_default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.12/dist/full.min.css" rel="stylesheet" />
1010
<script src="https://cdn.tailwindcss.com"></script>
1111
</head>
12-
<body class="flex flex-col min-h-screen" data-theme="aqua">
12+
<body class="flex flex-col min-h-screen" data-theme="cyberpunk">
1313

1414
<div>
1515
{{sidebar_default}}

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>✍️ MiniTemplate - Simple Template Engine</title>
6+
<title>My Default Title</title>
77

88
<!-- DaisyUI with Tailwind CDN -->
99
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.12/dist/full.min.css" rel="stylesheet" />
1010
<script src="https://cdn.tailwindcss.com"></script>
1111
</head>
12-
<body class="flex flex-col min-h-screen" data-theme="aqua">
12+
<body class="flex flex-col min-h-screen" data-theme="cyberpunk">
1313

1414
<div>
1515
<div id="sidebar_default" data-state="closed" class="bg-neutral w-64 h-full fixed top-0 left-0 flex flex-col justify-between transform -translate-x-full md:translate-x-0 transition-transform duration-300 ease-in-out z-10">

scripts/generate_site.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ OUTPUT_FILE="$PROJECT_DIR/index.html" # Output file set to index.html
1616

1717
# Default theme if not provided (optional)
1818
THEME_NAME=""
19+
# Default title
20+
DEFAULT_TITLE="My Default Title"
1921

2022
# Check if a theme name was passed as an argument
2123
if [[ ! -z "$2" ]]; then
@@ -25,17 +27,21 @@ else
2527
echo "No theme provided, proceeding without data-theme attribute."
2628
fi
2729

30+
# Check if a custom title was provided as the third argument
31+
if [[ ! -z "$3" ]]; then
32+
PAGE_TITLE="$3"
33+
echo "Using custom title: $PAGE_TITLE"
34+
else
35+
PAGE_TITLE="$DEFAULT_TITLE"
36+
echo "No custom title provided, using default title: $PAGE_TITLE"
37+
fi
38+
2839
# Check if the template file exists in the project directory
2940
if [[ ! -f "$TEMPLATE_FILE" ]]; then
3041
echo "Error: Template file '$TEMPLATE_FILE' not found in project directory."
3142
exit 1
3243
fi
3344

34-
# Prompt for the page title if a theme is provided
35-
if [[ ! -z "$THEME_NAME" ]]; then
36-
read -p "Enter the title for your page (leave empty to use default): " PAGE_TITLE
37-
fi
38-
3945
# Function to ensure required components exist in the project directory
4046
ensure_components() {
4147
local missing=()
@@ -67,9 +73,9 @@ missing_components=()
6773

6874
# Read the template file line by line
6975
while IFS= read -r line || [[ -n "$line" ]]; do
70-
# Replace the <title> tag with the user-provided title, if provided
71-
if [[ "$line" =~ \<title\>(.*)\<\/title\> ]] && [[ ! -z "$PAGE_TITLE" ]]; then
72-
echo "Replacing <title> tag with user-provided title."
76+
# Replace the <title> tag with the user-provided or default title
77+
if [[ "$line" =~ \<title\>(.*)\<\/title\> ]]; then
78+
echo "Replacing <title> tag with provided title."
7379
line="<title>${PAGE_TITLE}</title>"
7480
fi
7581

0 commit comments

Comments
 (0)