Skip to content

Commit

Permalink
Fix website build
Browse files Browse the repository at this point in the history
  • Loading branch information
hendricius committed Jan 12, 2025
1 parent 8ea8256 commit 3792dcc
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions website/modify_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def fix_double_slashes(text)
def validate_file(text)
doc = build_doc(text)
stylesheets = doc.css("link[rel='stylesheet']").map{|attr| attr["href"] }
has_all_styles = %w(book.css style.css).all? { |required_stylesheet| stylesheets.include?(required_stylesheet) }
raise InvalidWebsiteFormat.new("No style tag style.css found in the website") unless has_all_styles
has_all_styles = %w(book_sans_serif.css style.css).all? { |required_stylesheet| stylesheets.include?(required_stylesheet) }
raise InvalidWebsiteFormat.new("No style tag style.css or book_sans_serif.css found in the website") unless has_all_styles
true
end

Expand Down Expand Up @@ -456,7 +456,7 @@ def add_meta_tags(text, filename)
doc.to_html
end

# Takes a name like "static_website_html/book.html" and returns "book.html"
# Takes a name like "static_website_html/book_sans_serif.html" and returns "book_sans_serif.html"
def extract_file_from_path(filename)
result = filename.split("/")
return filename if result.length == 1
Expand All @@ -483,6 +483,7 @@ def custom_titles_per_filename(filename)
index_text = "The Sourdough Framework goes beyond just recipes and provides a solid knowledge foundation, covering the science of sourdough, the basics of bread making, and advanced techniques for achieving the perfect sourdough bread at home."
data = {
"book.html" => index_text,
"book_sans_serif.html" => index_text,
"index.html" => index_text
}
data[filename]
Expand Down Expand Up @@ -526,12 +527,6 @@ def mark_menu_as_selected_if_on_page(text, filename)
el["href"] == ""
end

# Special case for index page
#if ["index.html", "book.html"].include?(filename)
# doc.css(".menu-items .chapterToc.home-link")[0].add_class("selected")
# return doc.to_html
#end

# Special case for the flowcharts page which is added by us to the menu.
# This needs to be done for future manually added pages too
if "listoflocname.html" == filename
Expand Down Expand Up @@ -561,7 +556,7 @@ def mark_menu_as_selected_if_on_page(text, filename)
def add_canonical_for_duplicates(text, filename)
# Only applies to book.html which is a duplicate for index.html. The file
# is still needed though for proper display.
canonical_pages = ["book.html", "index.html"]
canonical_pages = ["book_sans_serif.html", "index.html"]
return text unless canonical_pages.include?(filename)
doc = build_doc(text)
head = doc.css("head")[0]
Expand Down

0 comments on commit 3792dcc

Please sign in to comment.