Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Portfolio site leads to 404 #149

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add jsdoc and import and use validUrl function in About and Biopost
  • Loading branch information
TishG committed Jan 4, 2022
commit f11297d543437b34f809495c7b2522a9ab2b58b7
19 changes: 13 additions & 6 deletions src/libraries/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// Our CMS does not validate urls,
// urls are entered in manually by the author,
// so this is to ensure a valid url to navigate to
const validPortfolioUrl = (url = "") => {
/**
* Our CMS does not validate urls,
* urls are entered in manually by the author,
* so this is to ensure a valid url to navigate to
Comment on lines +12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compliment: I like your explanation here, it gives great context.

* @function
* @param {string} url - The url of the portfolio site
* @returns {string} url - The passed in url or a new url
* with https appended to it
*/
export const validUrl = (url = "") => {
const https = "https://";
const trimmedUrl = url.trim();

if (url.includes(https) || url.includes("http:https://")) {
if (trimmedUrl.includes(https) || trimmedUrl.includes("http:https://")) {
return url;
}
return https + url;
return https + trimmedUrl;
};
7 changes: 6 additions & 1 deletion src/pages/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<a
class="ml-auto text-xl font-extrabold"
v-if="member.node.contact_links.portfolio_url"
:href="member.node.contact_links.portfolio_url"
:href="validUrl(member.node.contact_links.portfolio_url)"
>site</a
>
</article>
Expand Down Expand Up @@ -86,9 +86,14 @@ query
</page-query>

<script>
import {validUrl} from "../libraries/utils";
export default {
metaInfo: {
title: "About us",
},
methods: {
validUrl
}

};
</script>
8 changes: 6 additions & 2 deletions src/templates/Biopost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
/>
<a
v-if="$page.biopost.contact_links.email"
:href="`mailto:${$page.biopost.contact_links.email}`"
href="`mailto:${$page.biopost.contact_links.email}`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we still want the email to be dynamic, so keep the : on the href.

class="font-bold underline"
>Email</a
>
<a
v-if="$page.biopost.contact_links.portfolio_url"
:href="$page.biopost.contact_links.portfolio_url"
:href="validUrl($page.biopost.contact_links.portfolio_url)"
class="font-bold underline"
>Portfolio</a
>
Expand Down Expand Up @@ -63,12 +63,16 @@
</template>

<script>
import {validUrl} from "../libraries/utils";
export default {
metaInfo() {
return {
title: this.$page.biopost.title,
};
},
methods: {
validUrl
}
};
</script>

Expand Down