diff --git a/website/public/manifest.json b/website/public/manifest.json index d0dffcb..f3ab047 100644 --- a/website/public/manifest.json +++ b/website/public/manifest.json @@ -36,5 +36,12 @@ "display": "standalone", "theme_color": "#333333", "background_color": "#f9f9f9", - "start_url": "." + "start_url": ".", + "share_target": { + "action": "/share-target", + "method": "GET", + "params": { + "text": "text" + } + } } diff --git a/website/src/App.tsx b/website/src/App.tsx index 6e3cfe6..c033dd3 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -86,7 +86,7 @@ if (prod) { } const possibleLandingPages = [ - "/", "/about", "/settings", "/word", "/account", "/new-entries", + "/", "/about", "/settings", "/word", "/account", "/new-entries", "/share-target", ]; const editorOnlyPages = [ "/edit", "/review-tasks", @@ -168,6 +168,15 @@ class App extends Component { this.props.history.replace("/"); } } + if (this.props.location.pathname === "/share-target") { + if (this.state.options.language === "English") { + this.handleOptionsUpdate({ type: "toggleLanguage" }); + } + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const searchString = urlParams.get("text") || ""; + this.handleSearchValueChange(searchString); + } if (this.props.location.pathname === "/new-entries") { this.setState({ results: dictionary.getNewWordsThisMonth(),