-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
121 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const target = require('@vuepress/core/lib/app/prepare/preparePagesRoutes'); | ||
const shared = require("@vuepress/shared"); | ||
|
||
target.preparePagesRoutes = async (app) => { | ||
const content = `\ | ||
import { Vuepress } from '@vuepress/client/lib/components/Vuepress' | ||
const routeItems = [\ | ||
${app.pages | ||
.map(({ key, path, pathInferred, filePathRelative, routeMeta, frontmatter }) => { | ||
const redirects = []; | ||
const routeItem = [key, path, routeMeta, redirects]; | ||
// paths that should redirect to this page | ||
const redirectsSet = new Set(); | ||
// redirect from decoded path | ||
addPath(path); | ||
function addPath(path) { | ||
redirectsSet.add(decodeURI(path)); | ||
if (path.endsWith('/')) { | ||
// redirect from index path | ||
redirectsSet.add(path + 'index.html'); | ||
} | ||
else { | ||
// redirect from the path that does not end with `.html` | ||
redirectsSet.add(path.replace(/.html$/, '')); | ||
} | ||
} | ||
// redirect from inferred path | ||
if (pathInferred !== null) { | ||
redirectsSet.add(pathInferred); | ||
redirectsSet.add(encodeURI(pathInferred)); | ||
} | ||
// redirect from filename path | ||
if (filePathRelative !== null) { | ||
const filenamePath = shared.ensureLeadingSlash(filePathRelative); | ||
redirectsSet.add(filenamePath); | ||
redirectsSet.add(encodeURI(filenamePath)); | ||
} | ||
if (frontmatter.redirectFrom) { | ||
for (const path of frontmatter.redirectFrom) { | ||
addPath(path); | ||
} | ||
} | ||
// avoid redirect from the page path itself | ||
redirectsSet.delete(path); | ||
// add redirects to route item | ||
redirects.push(...redirectsSet); | ||
return `\n ${JSON.stringify(routeItem)},`; | ||
}) | ||
.join('')} | ||
] | ||
export const pagesRoutes = routeItems.reduce( | ||
(result, [name, path, meta, redirects]) => { | ||
result.push( | ||
{ | ||
name, | ||
path, | ||
component: Vuepress, | ||
meta, | ||
}, | ||
...redirects.map((item) => ({ | ||
path: item, | ||
redirect: path, | ||
})) | ||
) | ||
return result | ||
}, | ||
[ | ||
{ | ||
name: "404", | ||
path: "/:catchAll(.*)", | ||
component: Vuepress, | ||
} | ||
] | ||
) | ||
`; | ||
await app.writeTemp('internal/pagesRoutes.js', content); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require('./patchRedirect') | ||
|
||
module.exports = { | ||
extends: '@vuepress/theme-default', | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
4 changes: 4 additions & 0 deletions
4
docs/guide/introduction/development.md → docs/manual/development.md
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
sidebarDepth: 2 | ||
noOutboundLinks: true | ||
- /guide/introduction/ | ||
--- | ||
|
||
# 介绍 | ||
|
3 changes: 3 additions & 0 deletions
3
docs/guide/introduction/template.md → docs/manual/template.md
This file contains 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