Skip to content

Commit c752121

Browse files
committed
fix canonical URLs
improve HTML semantics change button to anchor
1 parent 79fd422 commit c752121

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

docs/config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"component": "examples",
161161
"hideNavigation": true,
162162
"hideInNavigation": true,
163-
"canonical": "https://mokapi.io/docs/resources",
163+
"canonical": "https://mokapi.io/docs/resources/tutorials",
164164
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
165165
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
166166
},
@@ -182,7 +182,7 @@
182182
"component": "examples",
183183
"hideNavigation": true,
184184
"hideInNavigation": true,
185-
"canonical": "https://mokapi.io/docs/resources",
185+
"canonical": "https://mokapi.io/docs/resources/examples",
186186
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
187187
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
188188
},
@@ -196,7 +196,7 @@
196196
"component": "examples",
197197
"hideNavigation": true,
198198
"hideInNavigation": true,
199-
"canonical": "https://mokapi.io/docs/resources",
199+
"canonical": "https://mokapi.io/docs/resources/blogs",
200200
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
201201
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
202202
},

webui/src/components/docs/Examples.vue

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function formatParam(label: any): string {
6969
return label.toString().toLowerCase().split(' ').join('-').split('/').join('-')
7070
}
7171
72-
const state = computed(() => {
72+
const state = computed<{ [name: string]: boolean }>(() => {
7373
return {
7474
tutorial: isTypeAvailable('tutorial'),
7575
example: isTypeAvailable('example'),
@@ -83,6 +83,15 @@ const state = computed(() => {
8383
}
8484
})
8585
86+
const typeLinks = computed(() => {
87+
return [
88+
{ text: 'All', url: getTypeUrl('all'), disabled: false, isActive: type.value === 'all' },
89+
{ text: 'Tutorials', url: getTypeUrl('tutorial'), disabled: !state.value.tutorial, isActive: type.value === 'tutorial' },
90+
{ text: 'Examples', url: getTypeUrl('example'), disabled: !state.value.example, isActive: type.value === 'example' },
91+
{ text: 'Blogs', url: getTypeUrl('blog'), disabled: !state.value.blog, isActive: type.value === 'blog' }
92+
]
93+
})
94+
8695
function isTechAvailable(s: string) {
8796
if (type.value === 'all') {
8897
return true
@@ -111,6 +120,19 @@ function isTypeAvailable(type: string) {
111120
}
112121
return false
113122
}
123+
function getTypeUrl(s: string) {
124+
if (s !== 'all' && !state.value[s]) {
125+
return undefined
126+
}
127+
if (!isTechAvailable(tech.value)) {
128+
tech.value = 'all'
129+
}
130+
if (s === 'all') {
131+
return router.resolve({ params: { level2: '' } }).href
132+
} else {
133+
return router.resolve({ params: { level2: s + 's' } }).href
134+
}
135+
}
114136
function setType(s: string) {
115137
type.value = s
116138
if (!isTechAvailable(tech.value)) {
@@ -138,10 +160,11 @@ function setType(s: string) {
138160
<!-- Filter Control -->
139161
<div class="filter-controls">
140162
<div class="d-none d-md-flex">
141-
<button class="btn btn-outline-primary filter-button" :class="type === 'all' ? 'active' : ''" @click="setType('all')">All</button>
142-
<button class="btn btn-outline-primary filter-button" :class="type === 'tutorial' ? 'active' : ''" @click="setType('tutorial')" :disabled="!state.tutorial">Tutorials</button>
143-
<button class="btn btn-outline-primary filter-button" :class="type === 'example' ? 'active' : ''" @click="setType('example')" :disabled="!state.example">Examples</button>
144-
<button class="btn btn-outline-primary filter-button" :class="type === 'blog' ? 'active' : ''" @click="setType('blog')" :disabled="!state.blog">Blogs</button>
163+
<a v-for="link of typeLinks" class="btn btn-outline-primary filter-button" :class="{ active: link.isActive, disabled: link.disabled }"
164+
:href="link.url" :aria-disabled="link.disabled"
165+
>
166+
{{ link.text }}
167+
</a>
145168
</div>
146169
<div class="d-none d-md-flex">
147170
<button class="btn btn-outline-primary filter-button" :class="tech === 'all' ? 'active' : ''" @click="tech = 'all'">All</button>

0 commit comments

Comments
 (0)