Skip to content

Commit 9022382

Browse files
committed
add series navigator
- move blog content into _content director, refactor how mdsvex page components are loaded - add dynamic import plugin - add series navigator component - add [slug].svelte, series/[slug].svelte, series/[slug].json pages - uncomment series component on homepage - tests - random small bug fixes
1 parent e939c36 commit 9022382

26 files changed

+269
-36
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
describe('<SeriesNavigator /> component', () => {
2+
context('when it should not exist', () => {
3+
beforeEach(() => {
4+
cy.visit('/blog/fighting-with-git-lfs')
5+
})
6+
7+
it('does not render', () => {
8+
cy.get('.series-navigator__title').should('not.exist')
9+
cy.get('.series-navigator__buttons').should('not.exist')
10+
})
11+
})
12+
13+
context('when it should exist', () => {
14+
beforeEach(() => {
15+
cy.visit('/blog/series')
16+
// navigate to the first post
17+
cy.get('.post-preview-list').find('a').eq(0).click()
18+
cy.injectAxe()
19+
})
20+
21+
it('renders correctly', () => {
22+
cy.get('.series-navigator__title').contains('This is post 1 of')
23+
cy.get('.series-navigator__buttons').within(() => {
24+
cy.get('.series-navigator__previous').should('not.exist')
25+
cy.get('.series-navigator__next').should('exist')
26+
})
27+
// cy.checkA11y('.series-navigator__title')
28+
// cy.checkA11y('.series-navigator__buttons')
29+
})
30+
31+
it('navigates forward and backwards', () => {
32+
cy.get('.series-navigator__buttons').within(() => {
33+
cy.get('.series-navigator__next').click()
34+
})
35+
cy.reload() // why???
36+
cy.get('.series-navigator__title').contains('This is post 2 of')
37+
cy.get('.series-navigator__buttons').within(() => {
38+
cy.get('.series-navigator__previous').should('exist')
39+
cy.get('.series-navigator__previous').click()
40+
})
41+
cy.reload() // why???
42+
cy.get('.series-navigator__title').contains('This is post 1 of')
43+
})
44+
})
45+
})

cypress/integration/routes/blog-series-json.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('/blog/series.json route', () => {
2121
if (index > 0) {
2222
date = new Date(date).getTime()
2323
const previousDate = new Date(dates[index - 1]).getTime()
24-
expect(date < previousDate).to.be.true
24+
expect(date > previousDate).to.be.true
2525
}
2626
})
2727
})

cypress/integration/routes/generate-image.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('/generate-image route', () => {
44

55
const params = objectToParams({
66
title: 'test title',
7-
excerpt: 'short expcert',
7+
excerpt: 'short excerpt',
88
categories: ['one fish', 'two fish'],
99
tags: ['red fish', 'blue fish'],
1010
imageSrc: '/images/site-assets/_placeholder.jpg',

cypress/integration/routes/rss.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ describe('/blog/rss.xml', () => {
3838
]
3939
cy.request('/blog/rss.xml')
4040
.then(({body}) => {
41+
console.log('body', body)
4142
const items = body.match(/<item>(.|\n)*?<\/item>/g)
43+
console.log('items', items)
4244
expect(items).to.have.length.of.at.most(12)
4345
items.map(item => {
4446
itemTags.map(tag => {
Binary file not shown.

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"devDependencies": {
3535
"@cypress/snapshot": "^2.1.7",
3636
"@rollup/plugin-commonjs": "^12.0.0",
37+
"@rollup/plugin-dynamic-import-vars": "^1.1.1",
3738
"@rollup/plugin-node-resolve": "^8.0.0",
3839
"@rollup/plugin-replace": "^2.2.0",
3940
"color-contrast-table-svelte": "^3.0.8",

rollup.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { terser } from 'rollup-plugin-terser'
66
import config from 'sapper/config/rollup.js'
77
import pkg from './package.json'
88
import { mdsvex } from 'mdsvex'
9+
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'
910
import svelteSVG from 'rollup-plugin-svelte-svg'
1011
import { globalStyle, scss } from 'svelte-preprocess'
1112
import copy from 'rollup-plugin-copy'
@@ -43,6 +44,10 @@ const envVars = {
4344
exclude: 'src/routes/**/*.md'
4445
}
4546

47+
const dynamicImportVarsOptions = {
48+
include: `src/routes/**/*.svelte`
49+
}
50+
4651
const preprocess = [
4752
mdsvex({
4853
extension: '.md',
@@ -104,6 +109,7 @@ export default {
104109
dedupe: ['svelte']
105110
}),
106111
commonjs(),
112+
dynamicImportVars(dynamicImportVarsOptions),
107113
svelteSVG({ dev }),
108114
copy({
109115
targets: [
@@ -139,6 +145,7 @@ export default {
139145
dedupe: ['svelte']
140146
}),
141147
commonjs(),
148+
dynamicImportVars(dynamicImportVarsOptions),
142149
svelteSVG({ generate: 'ssr', dev }),
143150
copy({
144151
targets: [

snapshots.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)