mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-19 19:01:19 +00:00
Allow details and course pages to be accessed with naddr or note id
This commit is contained in:
parent
58f2a6635a
commit
34e116e9cc
@ -66,7 +66,11 @@ const SearchBar = () => {
|
||||
}, [selectedSearchOption, contentResults, communityResults]);
|
||||
|
||||
const handleContentSelect = (content) => {
|
||||
router.push(`/details/${content.id}`);
|
||||
if (content?.type === 'course') {
|
||||
router.push(`/course/${content.id}`);
|
||||
} else {
|
||||
router.push(`/details/${content.id}`);
|
||||
}
|
||||
setSearchTerm('');
|
||||
searchContent('');
|
||||
op.current.hide();
|
||||
|
@ -25,13 +25,19 @@ const useCourseData = (ndk, fetchAuthor, router) => {
|
||||
useEffect(() => {
|
||||
if (router.isReady) {
|
||||
const { slug } = router.query;
|
||||
const { data } = nip19.decode(slug);
|
||||
if (!data) {
|
||||
showToast('error', 'Error', 'Course not found');
|
||||
setLoading(false);
|
||||
return;
|
||||
let id;
|
||||
if (slug.includes("naddr")) {
|
||||
const { data } = nip19.decode(slug);
|
||||
if (!data) {
|
||||
showToast('error', 'Error', 'Course not found');
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
id = data?.identifier;
|
||||
} else {
|
||||
id = slug;
|
||||
}
|
||||
const id = data?.identifier;
|
||||
|
||||
const fetchCourse = async (id) => {
|
||||
try {
|
||||
await ndk.connect();
|
||||
|
@ -70,19 +70,26 @@ export default function Details() {
|
||||
if (router.isReady) {
|
||||
const { slug } = router.query;
|
||||
|
||||
|
||||
if (!slug) {
|
||||
return;
|
||||
}
|
||||
|
||||
let id;
|
||||
|
||||
const { data } = nip19.decode(slug)
|
||||
if (slug.includes("naddr")) {
|
||||
const { data } = nip19.decode(slug)
|
||||
|
||||
if (!data) {
|
||||
showToast('error', 'Error', 'Resource not found');
|
||||
return;
|
||||
if (!data) {
|
||||
showToast('error', 'Error', 'Resource not found');
|
||||
return;
|
||||
}
|
||||
|
||||
id = data?.identifier;
|
||||
} else {
|
||||
id = slug;
|
||||
}
|
||||
|
||||
const id = data?.identifier;
|
||||
|
||||
const fetchEvent = async (id, retryCount = 0) => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user