-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #530 from diggsweden/DIGG-483
DIGG-483: Uppdating url structure for concepts, terminologies and specifications
- Loading branch information
Showing
29 changed files
with
349 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
import { useRouter } from "next/router"; | ||
import { useContext } from "react"; | ||
import { GetServerSidePropsContext } from "next/types"; | ||
|
||
import { ConceptPage } from "@/features/entryscape/concept-page"; | ||
import { EntrystoreProvider } from "@/providers/entrystore-provider"; | ||
import { SettingsContext } from "@/providers/settings-provider"; | ||
import { handleEntryStoreRedirect } from "@/utilities/entryscape/entrystore-redirect"; | ||
|
||
export default function Concept() { | ||
const { env } = useContext(SettingsContext); | ||
const { query } = useRouter() || {}; | ||
const { concept, param } = query || {}; | ||
const curi = `${concept}/${param}`; | ||
let entryUri = ""; | ||
|
||
if (env.ENTRYSCAPE_TERMS_PATH.includes("sandbox")) | ||
entryUri = `https://www-sandbox.dataportal.se/concepts/${curi}`; | ||
else entryUri = `https://dataportal.se/concepts/${curi}`; | ||
|
||
return ( | ||
<EntrystoreProvider | ||
env={env} | ||
entryUri={entryUri} | ||
entrystoreUrl={env.ENTRYSCAPE_TERMS_PATH} | ||
pageType="concept" | ||
> | ||
<ConceptPage curi={curi} /> | ||
</EntrystoreProvider> | ||
); | ||
return null; | ||
} | ||
|
||
export const getServerSideProps = async ( | ||
context: GetServerSidePropsContext, | ||
) => { | ||
return handleEntryStoreRedirect(context, { | ||
pathPrefix: "/concepts", | ||
redirectPath: "/concepts", | ||
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH", | ||
paramName: "concept", | ||
secondParamName: "param", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
import { useRouter } from "next/router"; | ||
import { GetServerSidePropsContext } from "next/types"; | ||
import { useContext } from "react"; | ||
|
||
import { ConceptPage } from "@/features/entryscape/concept-page"; | ||
import { EntrystoreProvider } from "@/providers/entrystore-provider"; | ||
import { SettingsContext } from "@/providers/settings-provider"; | ||
import { handleEntryStoreRedirect } from "@/utilities/entryscape/entrystore-redirect"; | ||
|
||
export default function Concept() { | ||
const { env } = useContext(SettingsContext); | ||
const { query } = useRouter() || {}; | ||
const { concept } = query || {}; | ||
const curi = concept; | ||
let entryUri = ""; | ||
|
||
if (env.ENTRYSCAPE_TERMS_PATH.includes("sandbox")) | ||
entryUri = `https://www-sandbox.dataportal.se/concepts/${curi}`; | ||
else entryUri = `https://dataportal.se/concepts/${curi}`; | ||
const ids = (typeof concept === "string" && concept.split("_")) || []; | ||
const eid = ids.pop() || ""; | ||
const cid = ids.join("_"); | ||
|
||
return ( | ||
<EntrystoreProvider | ||
env={env} | ||
entryUri={entryUri} | ||
cid={cid} | ||
eid={eid} | ||
entrystoreUrl={env.ENTRYSCAPE_TERMS_PATH} | ||
pageType="concept" | ||
> | ||
<ConceptPage {...(typeof curi === "string" ? { curi } : {})} /> | ||
<ConceptPage /> | ||
</EntrystoreProvider> | ||
); | ||
} | ||
|
||
export const getServerSideProps = async ( | ||
context: GetServerSidePropsContext, | ||
) => { | ||
return handleEntryStoreRedirect(context, { | ||
pathPrefix: "/concepts", | ||
redirectPath: "/concepts", | ||
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH", | ||
paramName: "concept", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
import { GetServerSideProps } from "next/types"; | ||
import { GetServerSidePropsContext } from "next/types"; | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ params }) => { | ||
const concept = (params?.concept as string[]) || []; | ||
const scheme = concept[0]; | ||
|
||
if (scheme != "http" && scheme != "https") { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
// Reconstruct the original URI and redirect to the new format | ||
const curi = concept.slice(1).join("/"); | ||
const uri = `${scheme}://${curi}`; | ||
|
||
return { | ||
redirect: { | ||
destination: `/externalconcept?resource=${encodeURIComponent(uri)}`, | ||
permanent: true, | ||
}, | ||
}; | ||
}; | ||
import { handleEntryStoreRedirect } from "@/utilities/entryscape/entrystore-redirect"; | ||
|
||
export default function Concept() { | ||
return null; | ||
} | ||
|
||
export const getServerSideProps = async ( | ||
context: GetServerSidePropsContext, | ||
) => { | ||
return handleEntryStoreRedirect(context, { | ||
pathPrefix: "/concepts", | ||
redirectPath: "/concepts", | ||
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH", | ||
paramName: "concept", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
import { useRouter } from "next/router"; | ||
import { GetServerSideProps } from "next/types"; | ||
import { useContext } from "react"; | ||
import { GetServerSidePropsContext } from "next/types"; | ||
|
||
import { ConceptPage } from "@/features/entryscape/concept-page"; | ||
import { EntrystoreProvider } from "@/providers/entrystore-provider"; | ||
import { SettingsContext } from "@/providers/settings-provider"; | ||
import { handleEntryStoreRedirect } from "@/utilities/entryscape/entrystore-redirect"; | ||
|
||
export default function Concept() { | ||
const { env } = useContext(SettingsContext); | ||
const { resource } = useRouter().query; | ||
|
||
if (!resource) return null; | ||
|
||
return ( | ||
<EntrystoreProvider | ||
env={env} | ||
entryUri={decodeURIComponent(resource as string)} | ||
entrystoreUrl={env.ENTRYSCAPE_TERMS_PATH} | ||
pageType="concept" | ||
> | ||
<ConceptPage uri={resource as string} /> | ||
</EntrystoreProvider> | ||
); | ||
return null; | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ | ||
query: { resource }, | ||
}) => ({ | ||
notFound: !resource, | ||
props: {}, | ||
}); | ||
export const getServerSideProps = async ( | ||
context: GetServerSidePropsContext, | ||
) => { | ||
return handleEntryStoreRedirect( | ||
context, | ||
{ | ||
pathPrefix: "/concepts", | ||
redirectPath: "/concepts", | ||
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH", | ||
}, | ||
context.query.resource as string, | ||
); | ||
}; |
Oops, something went wrong.