Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into versioned-search-page
Browse files Browse the repository at this point in the history
  • Loading branch information
weareoutman committed Jun 21, 2022
2 parents 68dc812 + 5ce699b commit f29ec2d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
14 changes: 9 additions & 5 deletions docusaurus-search-local/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.27.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.26.1...v0.27.0) (2022-05-29)
## [0.27.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.27.0...v0.27.1) (2022-06-13)

### Bug Fixes

- properly support no trailing slashes after fixing indexing top level pages ([999bd8b](https://github.com/easyops-cn/docusaurus-search-local/commit/999bd8bec8abe73f12abe20f58f8030be46c9ecd)), closes [#212](https://github.com/easyops-cn/docusaurus-search-local/issues/212)

## [0.27.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.26.1...v0.27.0) (2022-05-29)

### Features

* versioned search ([6865e7c](https://github.com/easyops-cn/docusaurus-search-local/commit/6865e7c3eee416e53648877359cdf206119be043)), closes [#66](https://github.com/easyops-cn/docusaurus-search-local/issues/66)
- versioned search ([6865e7c](https://github.com/easyops-cn/docusaurus-search-local/commit/6865e7c3eee416e53648877359cdf206119be043)), closes [#66](https://github.com/easyops-cn/docusaurus-search-local/issues/66)

### [0.26.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.26.0...v0.26.1) (2022-05-25)


### Bug Fixes

* fix i18n id of `theme.SearchPage.noResultsText` ([fe530f3](https://github.com/easyops-cn/docusaurus-search-local/commit/fe530f35da0b11c78c9d68cb6a7fea5871919e00))
- fix i18n id of `theme.SearchPage.noResultsText` ([fe530f3](https://github.com/easyops-cn/docusaurus-search-local/commit/fe530f35da0b11c78c9d68cb6a7fea5871919e00))

## [0.26.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.26.0...v0.26.0) (2022-05-24)

### Features

* add a clear button to the search bar [#170](https://github.com/easyops-cn/docusaurus-search-local/issues/170) ([f516123](https://github.com/easyops-cn/docusaurus-search-local/commit/f5161238cb7466fe7309e9166037d681e647f910))
- add a clear button to the search bar [#170](https://github.com/easyops-cn/docusaurus-search-local/issues/170) ([f516123](https://github.com/easyops-cn/docusaurus-search-local/commit/f5161238cb7466fe7309e9166037d681e647f910))

## [0.25.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.24.1...v0.25.0) (2022-05-19)

Expand Down
2 changes: 1 addition & 1 deletion docusaurus-search-local/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easyops-cn/docusaurus-search-local",
"version": "0.28.0-alpha.1",
"version": "0.27.1",
"description": "An offline/local search plugin for Docusaurus v2",
"repository": "https://github.com/easyops-cn/docusaurus-search-local",
"homepage": "https://github.com/easyops-cn/docusaurus-search-local",
Expand Down
32 changes: 22 additions & 10 deletions docusaurus-search-local/src/server/utils/processDocInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ProcessedPluginOptions,
PostBuildData,
} from "../../shared/interfaces";
import { LoadedContent, LoadedVersion } from "@docusaurus/plugin-content-docs"
import { LoadedContent, LoadedVersion } from "@docusaurus/plugin-content-docs";

export function processDocInfos(
{ routesPaths, outDir, baseUrl, siteConfig, plugins }: PostBuildData,
Expand All @@ -22,28 +22,35 @@ export function processDocInfos(
const emptySet = new Set();
let versionData: any = [{ versionOutDir: outDir, docs: emptySet }];
if (plugins) {
const docsPluginData = plugins.find(element => element.name === "docusaurus-plugin-content-docs");
const docsPluginData = plugins.find(
(element) => element.name === "docusaurus-plugin-content-docs"
);
if (docsPluginData) {
versionData = [];
const loadedVersions:LoadedVersion[] = (docsPluginData.content as LoadedContent).loadedVersions;
const loadedVersions: LoadedVersion[] = (
docsPluginData.content as LoadedContent
).loadedVersions;
for (const loadedVersion of loadedVersions) {
let docs = new Set();
const docs = new Set();
for (const doc of loadedVersion.docs) {
docs.add(doc.permalink);
}
const route = loadedVersion.path.substr(baseUrl.length);
let versionOutDir = outDir;
// The last versions search-index should always be placed in the root since it is the one used from non-docs pages
if (!loadedVersion.isLast) {
versionOutDir = path.join(outDir, ...route.split("/").filter((i: string) => i));
versionOutDir = path.join(
outDir,
...route.split("/").filter((i: string) => i)
);
}
versionData.push({ versionOutDir, docs });
}
}
}

// Create a list of files to index per document version. This will always include all pages and blogs.
let result = [];
const result = [];
for (const { versionOutDir, docs } of versionData) {
const versionPaths = routesPaths
.map<DocInfoWithRoute | undefined>((url: string) => {
Expand All @@ -57,7 +64,8 @@ export function processDocInfos(

// Do not index homepage, error page and search page.
if (
((!docsRouteBasePath || docsRouteBasePath[0] !== "") && route === "") ||
((!docsRouteBasePath || docsRouteBasePath[0] !== "") &&
route === "") ||
route === "404.html" ||
route === "search"
) {
Expand All @@ -78,7 +86,9 @@ export function processDocInfos(

if (
indexBlog &&
blogRouteBasePath.some((basePath) => isSameOrSubRoute(route, basePath))
blogRouteBasePath.some((basePath) =>
isSameOrSubRoute(route, basePath)
)
) {
if (
blogRouteBasePath.some(
Expand All @@ -94,7 +104,9 @@ export function processDocInfos(
}
if (
indexDocs &&
docsRouteBasePath.some((basePath) => isSameOrSubRoute(route, basePath))
docsRouteBasePath.some((basePath) =>
isSameOrSubRoute(route, basePath)
)
) {
if (docs.size === 0 || docs.has(url)) {
return { route, url, type: "docs" };
Expand All @@ -110,7 +122,7 @@ export function processDocInfos(
.map<DocInfoWithFilePath>(({ route, url, type }) => ({
filePath: path.join(
outDir,
siteConfig.trailingSlash === false
siteConfig.trailingSlash === false && route != ""
? `${route}.html`
: `${route}/index.html`
),
Expand Down

0 comments on commit f29ec2d

Please sign in to comment.