Fix asset copying to merge with existing directories#869
Open
jpurnell wants to merge 7 commits intotwostraws:mainfrom
Open
Fix asset copying to merge with existing directories#869jpurnell wants to merge 7 commits intotwostraws:mainfrom
jpurnell wants to merge 7 commits intotwostraws:mainfrom
Conversation
Previously, copyAssets() and copyFonts() used FileManager.copyItem() which fails if the destination already exists. This caused crashes when users had folders in Assets/ with the same names as Ignite-generated folders (e.g., css/, fonts/, or any page name like constitution/). This was particularly problematic because: 1. Ignite generates css/ and fonts/ folders during content generation 2. Users often want to add custom CSS/fonts alongside Ignite's files 3. clearBuildFolder() uses try? and silently fails with file locks The fix adds a recursive mergeContents() helper that: - For files: removes existing and copies (allowing overwrites) - For directories: creates if needed, then recursively merges contents This allows users to have Assets/css/custom.css alongside Ignite's bootstrap.min.css in the final build output.
The theme-switching JavaScript reads these attributes to determine which CSS theme selectors to activate. Without them, custom themes fall back to "light"/"dark" which don't match custom theme CSS selectors like [data-bs-theme="my-theme-light"], breaking dark mode for custom themes.
Allow sites to specify which content types appear in the RSS feed (e.g. contentTypes: ["letters"]). When nil, all types are included.
Escape &, <, >, ", ' in title, site name, and site description fields that are not wrapped in CDATA sections. Unescaped & in titles like "Donations & Sponsorships" produced invalid XML that feed readers rejected.
The auto-synthesized init for EmptyTagPage was internal, making it impossible for consuming packages to use EmptyTagPage() to disable tag page generation.
GitHub Pages serves directory-style URLs with a trailing slash, but the sitemap was emitting them without one, causing 301 redirects for every page in the sitemap.
5b06a64 to
ff2890a
Compare
Static hosts serve directory-style pages (path/index.html) at path/, so links without a trailing slash cause unnecessary 301 redirects. This adds a linkPath(for:) method that appends trailing slashes to local page URLs (skipping external URLs and file paths with extensions) and uses it in Link and LinkGroup rendering.
746c2a1 to
89c0a9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a crash that occurs when users have folders in
Assets/with the same names as Ignite-generated folders (e.g.,css/,fonts/, or any page name).The problem:
copyAssets()andcopyFonts()useFileManager.copyItem()which throws if the destination already existscss/andfonts/folders during content generation (for bootstrap, ignite-core, etc.)Assets/css/custom.css, the copy fails becausedocs/css/already existsclearBuildFolder()usestry?and can silently fail with file locks (especially on Dropbox)The fix:
mergeContents(from:to:)helper that:copyAssets(),copyFonts(), andcopy(resource:)to use this helperResult:
Users can now have
Assets/css/custom.cssand it will appear alongside Ignite'sbootstrap.min.cssin the finaldocs/css/folder.Test plan
Assets/css/,Assets/fonts/, andAssets/constitution/folders