diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx
index 257128766..039d81e2c 100644
--- a/client/homebrew/homebrew.jsx
+++ b/client/homebrew/homebrew.jsx
@@ -76,6 +76,7 @@ const Homebrew = createClass({
} />
} />
}/>
+ }/>
} />
} />
} />
diff --git a/client/homebrew/pages/archivePage/archivePage.jsx b/client/homebrew/pages/archivePage/archivePage.jsx
index b413056b5..e79b8bf34 100644
--- a/client/homebrew/pages/archivePage/archivePage.jsx
+++ b/client/homebrew/pages/archivePage/archivePage.jsx
@@ -27,6 +27,20 @@ const ArchivePage = createClass({
error : null,
};
},
+ componentDidMount: function () {
+ const url = new URL(window.location.href);
+ const pathSegments = url.pathname.split('/');
+
+ // Check if there's a path parameter after /archive/
+ if (pathSegments.length > 2 && pathSegments[1] === 'archive') {
+ const pathQuery = pathSegments[2];
+ console.log(pathQuery);
+ this.setState({ query: pathQuery }, () => {
+ this.lookup();
+ });
+ }
+ },
+
handleChange(e) {
this.setState({ query: e.target.value });
},
@@ -39,13 +53,28 @@ const ArchivePage = createClass({
.catch((err) => this.setState({ error: err }))
.finally(() => this.setState({ searching: false }));
},
+ updateUrl: function(query) {
+ const url = new URL(window.location.href);
+ const urlParams = new URLSearchParams(url.search);
+ // Clear existing parameters
+ urlParams.delete('sort');
+ urlParams.delete('dir');
+ urlParams.delete('filter');
+
+ // Set the pathname to '/archive/query'
+ url.pathname = `/archive/${this.state.query}`;
+
+ url.search = urlParams;
+ window.history.replaceState(null, null, url);
+},
renderFoundBrews() {
const brews = this.state.brewCollection;
if (!brews || brews.length === 0) {
return No brews found.
;
}
-
+ console.table(brews);
+ this.updateUrl();
return ;
},
@@ -76,7 +105,7 @@ const ArchivePage = createClass({
);
},
- renderResults: function () {},
+
renderNavItems: function () {
return (
diff --git a/server/archive.api.js b/server/archive.api.js
index e4c6b704b..6302e3041 100644
--- a/server/archive.api.js
+++ b/server/archive.api.js
@@ -17,7 +17,6 @@ const archive = {
// No published documents found with the given title
return res.status(404).json({ error: 'Published documents not found' });
}
-
return res.json(brews);
} catch (error) {
console.error(error);
@@ -28,4 +27,4 @@ const archive = {
router.get('/archive/:query', asyncHandler(archive.findBrews));
-module.exports = archive;
\ No newline at end of file
+module.exports = router;
\ No newline at end of file