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 all commits
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
28 changes: 28 additions & 0 deletions src/libraries/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Verifies whether the url starts with http:https:// or https://
* @function
* @param {string} url - The url of the portfolio site
* @returns {boolean}
*/
const isValidUrl = (url) => {
return url.indexOf("https://") === 0 || url.indexOf("http:https://") === 0
}

/**
* 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 (isValidUrl(trimmedUrl)) {
return trimmedUrl;
}
return https + trimmedUrl;
};
14 changes: 13 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,21 @@ query
</page-query>

<script>
import {validUrl} from "../libraries/utils";
export default {
metaInfo: {
title: "About us",
},
methods: {
validUrl
}
// methods: {
// validUrl
// },
// computed: {
// portfolioUrl() {
// // return this.validUrl(member.node.contact_links.portfolio_url)
// }
// }
Comment on lines +97 to +104
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Remove these unused methods.

};
</script>
13 changes: 11 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="portfolioUrl"
class="font-bold underline"
>Portfolio</a
>
Expand Down Expand Up @@ -63,12 +63,21 @@
</template>

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

Expand Down