Skip to content

Commit 504a1b3

Browse files
Zé Bateiraolizillaterichadbourne
authored
Fix: more seo updates (#521)
* fix: add trailing slash to sitemap optimize build chunks for each route * feat: allow to override page title in the title template * feat: add more properties to the sitemap * fix: remove duplicate h1 and remove wrong h2 and h3 * fix: add missing alt attributes to images * fix: tests need an update because of the headdings changes * fix: remove errors on 404 pages * fix: suggestions from code review Co-authored-by: Oli Evans <[email protected]> * fix: remove sitemap from version control * fix: wrong condition * fix: test lesson content is correct * fix incorrect merge Co-authored-by: Oli Evans <[email protected]> Co-authored-by: terichadbourne <[email protected]>
1 parent 4597576 commit 504a1b3

27 files changed

+140
-146
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
/dist
4+
/public/sitemap.xml
45

56
# local env files
67
.env*

cypress/integration/tutorials.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function advanceThroughLessons (tutorialId) {
253253

254254
it(`finds ${tutorialTitle} landing page with links to correct ${lessonCount} lessons plus resources`, function () {
255255
cy.visit(`/${tutorialName}/`)
256-
cy.contains('h2', tutorialTitle)
256+
cy.contains('h1', tutorialTitle)
257257
cy.get(`[data-cy=lesson-link-standard]`).should('have.length', lessonCount)
258258
cy.get(`[data-cy=lesson-link-resources]`).should('have.length', 1)
259259
// show that correct links are in correct order, but don't click through to test them
@@ -269,13 +269,11 @@ function advanceThroughLessons (tutorialId) {
269269
.and('have.attr', 'href', `/${tutorialName}/resources`)
270270
})
271271

272-
// const hasResources = tutorials[tutorialId].hasOwnProperty('resources')
273272
it(`uses lesson links and nav links btw landing page and 1st lesson`, function () {
274273
cy.visit(`/${tutorialName}/`)
275274
cy.get(`[href="/${tutorialName}/01"]`).click()
276275
cy.url().should('include', `/${tutorialName}/01`)
277276
cy.get(`[data-cy=tutorial-landing-link]`).click() // test nav link back to tutorial landing page
278-
cy.contains('h2', tutorialTitle)
279277
cy.get(`[href="/${tutorialName}/01"]`).click()
280278
cy.contains('h1', lessons[0].title)
281279
})
@@ -300,6 +298,10 @@ function advanceThroughLessons (tutorialId) {
300298

301299
let nextLessonNr = lessons[index + 1].formattedId
302300

301+
it('should show the lesson text', () => {
302+
cy.get('[data-cy-text]').should('have.attr', 'data-cy-text', lesson.html)
303+
})
304+
303305
// TEXT LESSONS ONLY
304306
if (lessonType === 'text') {
305307
it(`shows enabled next button`, function () {

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
command = "npm run scripts:build:data -- --dry-run=false && npm run test:jest && npm run build"
2+
command = "npm run sitemap && npm run scripts:build:data -- --dry-run=false && npm run test:jest && npm run build"
33
publish = "dist"
44

55
[build.environment]

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"scripts:build:data": "node scripts/commands/build-data",
1818
"scripts:googleapis-generate-token": "node scripts/commands/googleapis-generate-token",
1919
"scripts:wizard": "node scripts/commands/wizard/index.js",
20-
"sitemap": "rm public/sitemap.xml && vue-cli-service sitemap",
20+
"sitemap": "rm -f public/sitemap.xml && vue-cli-service sitemap",
2121
"start": "npm run serve",
2222
"test": "start-server-and-test serve http://localhost:3000 cy:run",
2323
"test:jest": "jest --maxWorkers=1 --verbose"

public/sitemap.xml

-1
This file was deleted.

src/components/Header.vue

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<img src="../static/images/ps_symbol_color.svg" alt="ProtoSchool" class="w3" />
88
</a>
99
<div class="header-text ml3">
10-
<h1 class="ma0 fw4">
10+
<div class=" header-title ma0 fw4">
1111
<span class="montserrat fw4">Proto</span>
1212
<span class="montserrat fw2">School</span>
13-
</h1>
14-
<h2 class="ma0 montserrat fw3">
13+
</div>
14+
<div class="header-slogan ma0 montserrat fw3">
1515
Interactive tutorials on decentralized web protocols
16-
</h2>
16+
</div>
1717
</div>
1818
</div>
1919
</section>
@@ -37,27 +37,27 @@ export default {
3737
</script>
3838

3939
<style scoped>
40-
.header-text h1 {
40+
.header-title {
4141
font-size: 32px;
4242
}
43-
.header-text h2 {
43+
.header-slogan {
4444
font-size: 16px;
4545
}
4646
4747
@media screen and (min-width: 620px) {
48-
.header-text h1 {
48+
.header-title {
4949
font-size: 40px;
5050
}
51-
.header-text h2 {
51+
.header-slogan {
5252
font-size: 20px;
5353
}
5454
}
5555
5656
@media screen and (max-width: 498px) {
57-
.header-text h1 {
57+
.header-title {
5858
font-size: 24px;
5959
}
60-
.header-text h2 {
60+
.header-slogan {
6161
font-size: 12px;
6262
}
6363
}

src/components/Lesson.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@
2323
<h1>{{isResources ? 'Resources' : lesson.title}}</h1>
2424
<Concepts v-if="concepts" :concepts="concepts" />
2525
<Resources v-if="isResources" :data="resources" />
26-
<div v-else class="lesson-text lh-copy" v-html="text"></div>
26+
<!--
27+
only add the text on data-cy-text when not in production
28+
otherwise the html document will be bigger than it needs to in production
29+
-->
30+
<div
31+
v-else class="lesson-text lh-copy"
32+
v-html="text"
33+
:data-cy-text="!isProduction && text"
34+
>
35+
</div>
2736
</section>
2837
<section v-if="challenge || isMultipleChoiceLesson" :class="{expand: expandChallenge}" class="challenge center pa3 ph4-l flex flex-column">
2938
<div class="flex-none">
@@ -247,7 +256,8 @@ export default {
247256
uploadedFiles: window.uploadedFiles || false,
248257
choice: localStorage[self.cacheKey] || '',
249258
cachedChoice: !!localStorage['cached' + routePath],
250-
output: self.output
259+
output: self.output,
260+
isProduction
251261
}
252262
},
253263
computed: {

src/components/Navigation.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<!-- standard nav -->
3232
<div v-else class="flex-auto link fw6 f5 db bb border-aqua">{{currentPage}}</div>
3333
<button @click="toggleHamburger" class="menu-toggle button-reset bg-transparent b--transparent">
34-
<img v-if="isHamburgerClosed" src="../static/images/burger.svg"/>
35-
<img v-else src="../static/images/close.svg"/>
34+
<img v-if="isHamburgerClosed" src="../static/images/burger.svg" alt="open navigation menu" />
35+
<img v-else src="../static/images/close.svg" alt="close navigation menu" />
3636
</button>
3737
</div>
3838
<!-- hamburger displayed when requested -->

src/components/Tutorial.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
:alt="tutorial.project.name"
1515
style="height: 23px"
1616
/>
17-
<h1 class="f6 mv0 fw2">{{tutorial.project.name}}</h1>
17+
<h2 class="f6 mv0 fw2">{{tutorial.project.name}}</h2>
1818
</div>
1919
<div class="flex justify-between flex-row items-start mb1">
2020
<div class="flex flex-row items-center mt1">
21-
<h2 class="ma0 f3 fw5">
21+
<h1 class="ma0 f3 fw5">
2222
<template v-if="isLanding !== true">
2323
<router-link :to="landingLink" data-cy="tutorial-title">{{tutorial.title}}</router-link>
2424
</template>
2525
<template v-else>
2626
{{tutorial.title}}
2727
</template>
28-
</h2>
28+
</h1>
2929
<span v-if="isTutorialPassed(tutorial)" class="ml2 f3">🏆</span>
3030
</div>
3131
<TypeIcon

src/components/cards/EventCard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<p class="f7 fw5 ma0 pt0 lh-copy ttu teal mb3">
55
{{displayTimeZone}}
66
</p>
7-
<h3 class="ma0 mb1 f3 fw9 ttu">{{ isVirtual ? "Virtual" : city }}</h3>
7+
<div class="ma0 mb1 f3 fw9 ttu">{{ isVirtual ? "Virtual" : city }}</div>
88
<p v-if="!isVirtual" class="f5 fw5 ma0 pt0">
99
<span v-if="country" class="fw7">{{country}}</span>
1010
<span v-if="region"> - {{region}}</span>

src/components/cards/TutorialCard.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<img
1111
class="mr2"
1212
:src="tutorial.project.logo"
13-
:alt="tutorial.project.name"
13+
:alt="`${tutorial.project.name} project logo`"
1414
style="height: 23px"
1515
/>
16-
<h4 class="f6 mv0 fw5 charcoal-muted">{{tutorial.project.name}}</h4>
16+
<div class="f6 mv0 fw5 charcoal-muted">{{tutorial.project.name}}</div>
1717
</div>
1818
<span v-if="state" class="tutorial-state f7 mv0 fw7 white br3">{{state.title}}</span>
1919
</div>
2020
<div class="flex flex-row justify-between items-start navy">
21-
<h3 class="ma0 f3 fw7" data-cy="tutorial-card-title">{{tutorial.title}}</h3>
21+
<div class="ma0 f3 fw7" data-cy="tutorial-card-title">{{tutorial.title}}</div>
2222
<TypeIcon
2323
:tutorialId="tutorial.tutorialId"
2424
class="h2 ml3 type-icon"

src/components/forms/feedback-survey/Form.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
v-on:click="onDismiss"
6666
aria-label="Dismiss survey"
6767
>
68-
<img src="../../../static/images/close.svg" />
68+
<img src="../../../static/images/close.svg" alt="dismiss or hide the tutorial feedback survey" />
6969
</button>
7070
</div>
7171
</transition>

src/components/forms/feedback-survey/Question.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
v-on:change="onSelect(index + 1)"
2525
v-model="selected"
2626
/>
27-
<img :src="icon" />
27+
<img :src="icon" :alt="`answer ${index + 1} out of 5 to the question`" />
2828
</label>
2929
</div>
3030
<br />

src/components/forms/feedback-survey/option-b/Form.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
v-on:click="onDismiss"
6767
aria-label="Dismiss survey"
6868
>
69-
<img src="../../../../static/images/close.svg" />
69+
<img src="../../../../static/images/close.svg" alt="dismiss or hide the tutorial feedback survey" />
7070
</button>
7171
</div>
7272
</transition>

src/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import VueTooltip from 'v-tooltip'
88
import VueHighlightJS from 'vue-highlight.js'
99
import VueSelect from 'vue-select'
1010
import 'vue-select/dist/vue-select.css'
11+
import 'highlight.js/styles/github.css'
1112

1213
import App from './App.vue'
1314
import router from './router'

src/pages/Home.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<TutorialsGrid
1818
:tutorials="featuredTutorials"
1919
/>
20-
<h1>Local Events</h1>
20+
<h2>Local Events</h2>
2121
<p class="f4 fw5 lh-copy ma0 pv3 ">
2222
Groups and individuals around the world host in-person events using our tutorials
2323
as curriculum, with mentors available to help you work through the challenges.

src/pages/Landing.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import head from '../utils/head'
1010
import Header from '../components/Header.vue'
1111
import Tutorial from '../components/Tutorial.vue'
1212
import { getTutorialByUrl } from '../utils/tutorials'
13-
import router from '../router'
1413
1514
export default {
1615
components: {
@@ -26,15 +25,16 @@ export default {
2625
2726
// If no tutorial was found, redirect to 404 page
2827
if (!tutorial) {
29-
router.replace({ name: '404' })
30-
return
28+
this.$router.replace({ name: '404' })
29+
30+
return null
3131
}
3232
3333
return tutorial
3434
}
3535
},
3636
head () {
37-
return head.dynamic.tutorials({ context: this })
37+
return this.tutorial && head.dynamic.tutorials({ context: this })
3838
}
3939
}
4040
</script>

0 commit comments

Comments
 (0)