mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +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]);
|
}, [selectedSearchOption, contentResults, communityResults]);
|
||||||
|
|
||||||
const handleContentSelect = (content) => {
|
const handleContentSelect = (content) => {
|
||||||
|
if (content?.type === 'course') {
|
||||||
|
router.push(`/course/${content.id}`);
|
||||||
|
} else {
|
||||||
router.push(`/details/${content.id}`);
|
router.push(`/details/${content.id}`);
|
||||||
|
}
|
||||||
setSearchTerm('');
|
setSearchTerm('');
|
||||||
searchContent('');
|
searchContent('');
|
||||||
op.current.hide();
|
op.current.hide();
|
||||||
|
@ -25,13 +25,19 @@ const useCourseData = (ndk, fetchAuthor, router) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (router.isReady) {
|
if (router.isReady) {
|
||||||
const { slug } = router.query;
|
const { slug } = router.query;
|
||||||
|
let id;
|
||||||
|
if (slug.includes("naddr")) {
|
||||||
const { data } = nip19.decode(slug);
|
const { data } = nip19.decode(slug);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
showToast('error', 'Error', 'Course not found');
|
showToast('error', 'Error', 'Course not found');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const id = data?.identifier;
|
id = data?.identifier;
|
||||||
|
} else {
|
||||||
|
id = slug;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchCourse = async (id) => {
|
const fetchCourse = async (id) => {
|
||||||
try {
|
try {
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
@ -70,10 +70,14 @@ export default function Details() {
|
|||||||
if (router.isReady) {
|
if (router.isReady) {
|
||||||
const { slug } = router.query;
|
const { slug } = router.query;
|
||||||
|
|
||||||
|
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let id;
|
||||||
|
|
||||||
|
if (slug.includes("naddr")) {
|
||||||
const { data } = nip19.decode(slug)
|
const { data } = nip19.decode(slug)
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@ -81,7 +85,10 @@ export default function Details() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = data?.identifier;
|
id = data?.identifier;
|
||||||
|
} else {
|
||||||
|
id = slug;
|
||||||
|
}
|
||||||
|
|
||||||
const fetchEvent = async (id, retryCount = 0) => {
|
const fetchEvent = async (id, retryCount = 0) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user