cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
438 stars 67 forks source link

Update parse.ts to consider new docusaurus tag. #103

Closed Danielku15 closed 2 years ago

Danielku15 commented 2 years ago

Fixes #102

As indicated in the issue, the meta tag naming was changed a few days ago. Changed the related selector from equals to ends-with

Danielku15 commented 2 years ago

Failing CI doesn't seem to directly relate to my changes but generally some things happening on canary. Found https://github.com/facebook/docusaurus/issues/6262 as related issue. Maybe some cleanup of dependencies is needed in general to reach compat with canary but it feels out of scope for my PR.

afoxman commented 2 years ago

Failing CI doesn't seem to directly relate to my changes but generally some things happening on canary. Found facebook/docusaurus#6262 as related issue. Maybe some cleanup of dependencies is needed in general to reach compat with canary but it feels out of scope for my PR.

Can confirm that this fixes static-crawl on 2.0.0-beta.16.

Danielku15 commented 2 years ago

I temporarily went with the workaround to swizzle SearchMetadata with:

// TODO: remove this swizzled file once https://github.com/cmfcmf/docusaurus-search-local/pull/103 is resolved

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
import React from 'react';
import Head from '@docusaurus/Head';
// Note: we bias toward using Algolia metadata on purpose
// Not doing so leads to confusion in the community,
// as it requires to first crawl the site with the Algolia plugin enabled first
// - https://github.com/facebook/docusaurus/issues/6693
// - https://github.com/facebook/docusaurus/issues/4555
export default function SearchMetadata({locale, version, tag}) {
  // Seems safe to consider here the locale is the language, as the existing
  // docsearch:language filter is afaik a regular string-based filter
  const language = locale;
  return (
    <Head>
      {language && <meta name="docsearch:language" content={language} />}
      {version && <meta name="docsearch:version" content={version} />}
      {tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
      {tag && <meta name="docusaurus_tag" content={tag} />}
    </Head>
  );
}
andysm1th commented 2 years ago

Hi @Danielku15, what do you mean by swizzle? I need to implement this workaround

andysm1th commented 2 years ago

Sorry, I should've searched harder! Here's the docs: https://docusaurus.io/docs/swizzling

Southgarden116 commented 2 years ago

This fix is not necessary anymore since this https://github.com/facebook/docusaurus/pull/6827 got released in docusaurus 2.0.0-beta.17.

cmfcmf commented 2 years ago

Thank you @Danielku15 for your work! I'll close this PR though, because Docusaurus reverted their meta tag names like @Southgarden116 mentions.