Skip to content

Commit db87ac1

Browse files
committed
Fix code includes
1 parent 5b14fa3 commit db87ac1

File tree

8 files changed

+32
-52
lines changed

8 files changed

+32
-52
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"vitepress": "^1.0.0-alpha.1"
1313
},
1414
"dependencies": {
15+
"@vueuse/core": "^8.6.0",
1516
"vue": "^3.2.36"
1617
}
1718
}

pnpm-lock.yaml

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

src/components/DateTime.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
<script>
2-
export default {
3-
data () {
4-
return {
5-
now: new Date()
6-
}
7-
}
8-
}
1+
<script setup>
2+
import { useNow } from '@vueuse/core'
3+
4+
const now = useNow()
95
</script>
106

7+
// #region snippet
118
<template>
129
<p class="demo">
1310
{{ $t('default', { now }) }}<br>
@@ -19,5 +16,6 @@ export default {
1916
<fluent locale="en">
2017
default = Now is {{ $now }}
2118
today = Today is {{ DATETIME($now, day: "numeric", month: "long", year: "numeric") }}
22-
now = It is {{ DATETIME($now, hour: "numeric", minute: "numeric") }}
19+
now = It is {{ DATETIME($now, hour: "numeric", minute: "numeric", second: "numeric") }}
2320
</fluent>
21+
// #endregion snippet

src/components/DateTimeCustom.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
<script>
2-
export default {
3-
data () {
4-
return {
5-
now: new Date()
6-
}
7-
}
8-
}
1+
<script setup>
2+
import { useNow } from '@vueuse/core'
3+
4+
const now = useNow()
95
</script>
106

7+
// #region snippet
118
<template>
129
<p class="demo">
1310
{{ $t('default', { now }) }}<br>
@@ -19,5 +16,6 @@ export default {
1916
<fluent locale="en">
2017
default = Now is {{ $now }}
2118
today = Today is {{ DATEFNS($now, "PP") }}
22-
now = It is {{ DATEFNS($now, "p") }}
19+
now = It is {{ DATEFNS($now, "pp") }}
2320
</fluent>
21+
// #endregion snippet

src/components/Simple.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}
99
</script>
1010

11+
#region snippet
1112
<template>
1213
<div>
1314
<div>{{ $t('hello-user', { userName }) }}</div>
@@ -30,3 +31,4 @@ shared-photos =
3031
*[other] their stream
3132
}.
3233
</fluent>
34+
#endregion snippet

src/components/SimpleSource.vue

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/howto/date-time.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
description: 'fluent-vue has built-in date and time formatting using native js methods. But it allows custom implementation using any library you want: dayjs, date-fns, moment, etc.'
33
---
44

5+
<script setup>
6+
import DateTimeComponent from '../components/DateTime.vue'
7+
import DateTimeCustom from '../components/DateTimeCustom.vue'
8+
</script>
9+
510
# Localizing date and time
611

712
Fluent has build-in function for formatting date and time: `DATETIME`. It uses [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) under the hood.
@@ -27,9 +32,11 @@ See the [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaS
2732

2833
### Example component
2934

30-
@[code{11-33}](../components/DateTime.vue)
35+
<<< @/components/DateTime.vue#snippet
3136

32-
<date-time />
37+
::: info Output
38+
<date-time-component />
39+
:::
3340

3441
## Using custom library for date formatting
3542

@@ -58,10 +65,8 @@ const fluent = createFluentVue({
5865

5966
### Use it
6067

61-
@[code{11-33}](../components/DateTimeCustom.vue)
62-
63-
<script setup>
64-
import DateTimeCustom from '../components/DateTimeCustom.vue'
65-
</script>
68+
<<< @/components/DateTimeCustom.vue#snippet
6669

70+
::: info Output
6771
<date-time-custom />
72+
:::

src/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Fluent keeps simple things simple and makes complex things possible. The syntax
88

99
## Example
1010

11-
<<< @/components/SimpleSource.vue
11+
<<< @/components/Simple.vue#snippet
1212

1313
<script setup>
1414
import SimpleInput from './components/SimpleInput.vue'

0 commit comments

Comments
 (0)