Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): hash router option - browse site offline (experimental) #9859

Merged
merged 53 commits into from
May 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
27b1acf
attempt to use hash-based history and make it work offline
slorber Feb 16, 2024
da45fff
Merge branch 'main' into slorber/offline-mode-poc-2
slorber Feb 22, 2024
de0df2d
Add router type to config file
slorber Feb 22, 2024
0c5034b
fix tests
slorber Feb 22, 2024
45c1c9d
add link hack
slorber Feb 22, 2024
25a9004
disable redirect plugin with the hash router?
slorber Feb 22, 2024
904f730
add siteConfig DOCUSAURUS_ROUTER env variable
slorber Feb 22, 2024
a1b9ba6
logging message
slorber Feb 22, 2024
547d8ab
sitemap should support hash router?
slorber Feb 22, 2024
4c5a9de
Disable PWA/client-redirects plugins in Hash Router mode
slorber Feb 22, 2024
c22da5a
Fix heading/TOC/anchor links with hash router
slorber Feb 22, 2024
4a22ebb
urlUtils normalizeUrl should support hash router
slorber Feb 23, 2024
5a5d2f3
simplify feeds unit tests
slorber Feb 23, 2024
81dbd82
blog feed support for Hash Router
slorber Feb 23, 2024
6c072c3
remove comment
slorber Feb 23, 2024
bffb2f0
add unit test for sitemap with hash router
slorber Feb 23, 2024
030688a
Add router config type doc
slorber Feb 23, 2024
62aa2cb
Make it possible to switch router dynamically
slorber Feb 23, 2024
6582ea7
Rework full build workflow for hash router support
slorber Feb 23, 2024
2f33aad
refactor: apply lint autofix
slorber Feb 23, 2024
e902401
Merge branch 'main' into slorber/offline-mode-poc-2
slorber May 17, 2024
b82e8a5
add missing route codegen after merge
slorber May 17, 2024
abc3a31
Encapsulate router impl switch in docusaurus core to avoid pnpm / yar…
slorber May 17, 2024
62fc20e
rename siteConfig import
slorber May 17, 2024
b80d22c
disable sitemap plugin with hash router
slorber May 17, 2024
e8ef286
disable blog feeds for hash router
slorber May 17, 2024
6282cca
improve disabled plugin warning
slorber May 17, 2024
b7d2884
Fix router type
slorber May 17, 2024
2c323f1
Move router config to siteConfig.future.experimental_router + add con…
slorber May 17, 2024
520bc92
fix webpack client config
slorber May 17, 2024
61f453e
fix unit tests breaking due to missing siteConfig.future
slorber May 17, 2024
62a25c5
Fix Docusaurus website config
slorber May 17, 2024
0a24bb7
simpler router switch
slorber May 17, 2024
9bbb135
simpler router switch
slorber May 17, 2024
15cc555
fix dev server with hash router + baseUrl
slorber May 17, 2024
f12aeee
fix hash router build
slorber May 17, 2024
bbc94c7
do not emit Algolia opensearch file with hash router
slorber May 17, 2024
533e307
Extract StaticDirectoriesCopyPlugin + move it to the client webpack c…
slorber May 17, 2024
1dad032
Add some tests for useBaseUrl with hash router
slorber May 17, 2024
f8edab1
basic router type docs
slorber May 17, 2024
b1f2c8d
revert useless serverEntry hack
slorber May 17, 2024
0465e7e
simplify ssg params
slorber May 17, 2024
a36ab2e
Add CI workflow for build with hash router
slorber May 17, 2024
905e681
fix CI workflow?
slorber May 17, 2024
4b7a8c2
only apply hash router logic when the hash router is enabled for html…
slorber May 17, 2024
db860a8
Add hack comment
slorber May 17, 2024
d877806
deploy hash router to github pages
slorber May 19, 2024
2b5e458
deploy hash router to github pages
slorber May 19, 2024
19745dc
deploy hash router to github pages
slorber May 19, 2024
a732f95
deploy hash router to github pages
slorber May 19, 2024
3610306
deploy hash router to github pages
slorber May 19, 2024
2de9c18
deploy hash router to github pages
slorber May 19, 2024
7cf6500
deploy hash router to github pages
slorber May 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sitemap should support hash router?
  • Loading branch information
slorber committed Feb 22, 2024
commit 547d8abc68e39da3e49431ec798efe9af26f4fd9
18 changes: 13 additions & 5 deletions packages/docusaurus-plugin-sitemap/src/createSitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default async function createSitemap(
head: {[location: string]: HelmetServerState},
options: PluginOptions,
): Promise<string | null> {
const {url: hostname} = siteConfig;
const {url: hostname, router} = siteConfig;
if (!hostname) {
throw new Error('URL in docusaurus.config.js cannot be empty/undefined.');
}
Expand All @@ -77,12 +77,20 @@ export default async function createSitemap(

const sitemapStream = new SitemapStream({hostname});

includedRoutes.forEach((routePath) =>
sitemapStream.write({
url: applyTrailingSlash(routePath, {
const createSitemapUrl = (routePath: string): string => {
const routerPrefix = router === 'hash' ? '/#' : '';
return (
routerPrefix +
applyTrailingSlash(routePath, {
trailingSlash: siteConfig.trailingSlash,
baseUrl: siteConfig.baseUrl,
}),
})
);
};

includedRoutes.forEach((routePath) =>
sitemapStream.write({
url: createSitemapUrl(routePath),
changefreq,
priority,
}),
Expand Down