@@ -16,6 +16,8 @@ OUTPUT_FILE="$PROJECT_DIR/index.html" # Output file set to index.html
1616
1717# Default theme if not provided (optional)
1818THEME_NAME=" "
19+ # Default title
20+ DEFAULT_TITLE=" My Default Title"
1921
2022# Check if a theme name was passed as an argument
2123if [[ ! -z " $2 " ]]; then
2527 echo " No theme provided, proceeding without data-theme attribute."
2628fi
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
2940if [[ ! -f " $TEMPLATE_FILE " ]]; then
3041 echo " Error: Template file '$TEMPLATE_FILE ' not found in project directory."
3142 exit 1
3243fi
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
4046ensure_components () {
4147 local missing=()
@@ -67,9 +73,9 @@ missing_components=()
6773
6874# Read the template file line by line
6975while 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