fix: add some pages that "sapper export" missed (#1000)

Unfortunately it looks like `sapper export` works by crawling the
non-logged-in site, which means that any pages that are inaccessible
when you're not logged in don't get generated, including "pinned,"
"muted," "blocked," "requests," and "share."

Normally this isn't a problem, but it is in browsers that don't
have Service Worker; you get a 404 when you try to refresh those pages.

My fix is to just add a hidden div that links to these pages. It's not
pretty, but it works.
This commit is contained in:
Nolan Lawson 2019-02-16 00:48:45 -08:00 committed by GitHub
parent 839e8e35c4
commit 2debddaaf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 14 deletions

View File

@ -1,5 +1,7 @@
<DynamicPageBanner title="Blocked users" icon="#fa-ban" /> <DynamicPageBanner title="Blocked users" icon="#fa-ban" />
<AccountsListPage {accountsFetcher} {accountActions} /> {#if $isUserLoggedIn }
<AccountsListPage {accountsFetcher} {accountActions} />
{/if}
<script> <script>
import AccountsListPage from '../_components/AccountsListPage.html' import AccountsListPage from '../_components/AccountsListPage.html'
import { store } from '../_store/store' import { store } from '../_store/store'

View File

@ -1,5 +1,7 @@
<DynamicPageBanner title="Muted users" icon="#fa-volume-off" /> <DynamicPageBanner title="Muted users" icon="#fa-volume-off" />
<AccountsListPage {accountsFetcher} {accountActions} /> {#if $isUserLoggedIn }
<AccountsListPage {accountsFetcher} {accountActions} />
{/if}
<script> <script>
import AccountsListPage from '../_components/AccountsListPage.html' import AccountsListPage from '../_components/AccountsListPage.html'
import { store } from '../_store/store' import { store } from '../_store/store'

View File

@ -1,15 +1,17 @@
<DynamicPageBanner title="Pinned toots" icon="#fa-thumb-tack" /> <DynamicPageBanner title="Pinned toots" icon="#fa-thumb-tack" />
<div class="pinned-toots-page"> {#if $isUserLoggedIn }
{#if loading} <div class="pinned-toots-page">
<LoadingPage /> {#if loading}
{:elseif statuses && statuses.length} <LoadingPage />
<ul class="pinned-toots-results"> {:elseif statuses && statuses.length}
{#each statuses as status, index} <ul class="pinned-toots-results">
<StatusSearchResult {status} {index} length={statuses.length} /> {#each statuses as status, index}
{/each} <StatusSearchResult {status} {index} length={statuses.length} />
</ul> {/each}
{/if} </ul>
</div> {/if}
</div>
{/if}
<style> <style>
.pinned-toots-page { .pinned-toots-page {
padding: 20px 20px; padding: 20px 20px;

View File

@ -1,5 +1,7 @@
<DynamicPageBanner title="Follow requests" icon="#fa-user-plus" /> <DynamicPageBanner title="Follow requests" icon="#fa-user-plus" />
<AccountsListPage {accountsFetcher} {accountActions} /> {#if $isUserLoggedIn }
<AccountsListPage {accountsFetcher} {accountActions} />
{/if}
<script> <script>
import AccountsListPage from '../_components/AccountsListPage.html' import AccountsListPage from '../_components/AccountsListPage.html'
import { store } from '../_store/store' import { store } from '../_store/store'

View File

@ -12,6 +12,15 @@
<p>Icons provided by <ExternalLink href="http://fontawesome.io/">Font Awesome</ExternalLink>.</p> <p>Icons provided by <ExternalLink href="http://fontawesome.io/">Font Awesome</ExternalLink>.</p>
<p>Logo thanks to "sailboat" by Gregor Cresnar from <ExternalLink href="https://thenounproject.com/">the Noun Project</ExternalLink>.</p> <p>Logo thanks to "sailboat" by Gregor Cresnar from <ExternalLink href="https://thenounproject.com/">the Noun Project</ExternalLink>.</p>
<div style="display: none">
<!-- TODO: this is just a hack so that `sapper export` knows to crawl these files -->
<a href="/muted">Muted</a>
<a href="/blocked">Blocked</a>
<a href="/pinned">Pinned</a>
<a href="/requests">Requests</a>
<a href="/share">Share</a>
</div>
</SettingsLayout> </SettingsLayout>
<script> <script>
import SettingsLayout from '../../_components/settings/SettingsLayout.html' import SettingsLayout from '../../_components/settings/SettingsLayout.html'