Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
monnaie-libre-fr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websites
monnaie-libre-fr
Commits
76142fda
Commit
76142fda
authored
3 years ago
by
Emmanuel Salomon
Browse files
Options
Downloads
Patches
Plain Diff
config: move hooks and icons to separate libs
parent
3af9c816
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libs/hooks.js
+77
-0
77 additions, 0 deletions
libs/hooks.js
libs/icons.js
+66
-0
66 additions, 0 deletions
libs/icons.js
nuxt.config.js
+9
-141
9 additions, 141 deletions
nuxt.config.js
with
152 additions
and
141 deletions
libs/hooks.js
0 → 100644
+
77
−
0
View file @
76142fda
export
default
{
'
content:file:beforeParse
'
:
(
file
)
=>
{
// Netlifycms cannot create array in json file at root level and nuxt-content need an array. So, ressources.json is parsed to fetch 'ressources' key.
if
(
file
.
extension
===
'
.json
'
&&
/.*ressources.json$/
.
test
(
file
.
path
))
{
file
.
data
=
JSON
.
stringify
(
JSON
.
parse
(
file
.
data
).
ressources
)
}
// Split md file with `---`. Used for flat plan.
if
(
file
.
extension
===
'
.md
'
&&
/^---.*layout:.*---/
s
.
test
(
file
.
data
))
{
let
t
=
0
const
data
=
file
.
data
.
replace
(
/---/g
,
(
match
)
=>
{
++
t
if
(
t
===
2
)
return
'
---
\n
<section>
'
if
(
t
>
2
)
return
'
</section>
\n
<section>
'
return
match
})
file
.
data
=
data
+
'
\n
</section>
'
}
},
async
'
content:file:beforeInsert
'
(
document
)
{
// Routes all /pages/_slug to /_slug
if
(
document
.
path
.
startsWith
(
'
/pages/
'
))
{
document
.
dir
=
'
/
'
document
.
path
=
document
.
path
.
replace
(
'
/pages/
'
,
'
/
'
)
}
if
(
document
.
extension
===
'
.md
'
)
{
/*
* Add reading time
*/
document
.
readingTime
=
require
(
'
reading-time
'
)(
document
.
text
)
/*
* Add lexique terms and check if terms exist
*/
// Search lexique terms
const
lexiqueTerms
=
[
...
document
.
text
.
matchAll
(
/<lexique
[
>
]([^
<
]
*
)
<
\/
|<lexique
\s
+title="
(
.*
)
"/g
),
].
map
((
match
)
=>
{
return
(
match
[
2
]
||
match
[
1
]).
toLowerCase
()
// Priority for term in title=""
})
if
(
lexiqueTerms
.
length
)
{
// Add terms to document
document
.
lexiqueTerms
=
[...
new
Set
(
lexiqueTerms
)]
// remove duplicate
const
{
$content
}
=
require
(
'
@nuxt/content
'
)
// Check if term exists
if
(
$content
)
{
for
(
let
i
=
0
;
i
<
document
.
lexiqueTerms
.
length
;
i
++
)
{
const
term
=
document
.
lexiqueTerms
[
i
]
const
lexique
=
await
$content
(
'
lexique
'
)
.
where
({
$or
:
[
{
title
:
{
$regex
:
[
`^
${
term
}
$`
,
'
i
'
]
}
},
// case insensitive
{
synonyms
:
{
$contains
:
term
}
},
// search in synonyms
],
})
.
limit
(
1
)
.
fetch
()
if
(
!
lexique
.
length
)
{
// eslint-disable-next-line no-console
console
.
warn
(
`Term "
${
term
}
" in file
${
document
.
path
+
document
.
extension
}
doesn't exist`
)
}
}
}
}
}
},
}
This diff is collapsed.
Click to expand it.
libs/icons.js
0 → 100644
+
66
−
0
View file @
76142fda
export
default
{
regular
:
[
'
faClock
'
],
solid
:
[
'
faHome
'
,
'
faSearch
'
,
'
faSkullCrossbones
'
,
'
faChevronLeft
'
,
'
faChevronRight
'
,
'
faArrowLeft
'
,
'
faArrowRight
'
,
'
faSun
'
,
'
faMoon
'
,
'
faHeart
'
,
'
faInfoCircle
'
,
'
faCheckCircle
'
,
'
faCheck
'
,
'
faExclamationCircle
'
,
'
faExclamationTriangle
'
,
'
faExternalLinkAlt
'
,
'
faBars
'
,
'
faUserCircle
'
,
'
faGlobe
'
,
'
faAngry
'
,
'
faCompressArrowsAlt
'
,
'
faExpandArrowsAlt
'
,
'
faFont
'
,
'
faWheelchair
'
,
'
faCaretDown
'
,
],
brands
:
[
'
faCreativeCommonsNcEu
'
,
'
faDiaspora
'
,
'
faDiscourse
'
,
'
faGithub
'
,
'
faGitlab
'
,
'
faYoutube
'
,
'
faRocketchat
'
,
'
faFacebook
'
,
'
faTwitter
'
,
'
faDiscord
'
,
'
faApple
'
,
'
faAndroid
'
,
'
faBitcoin
'
,
'
faChrome
'
,
'
faFirefox
'
,
'
faCodepen
'
,
'
faDev
'
,
'
faDocker
'
,
'
faDropbox
'
,
'
faMastodon
'
,
'
faMedium
'
,
'
faNpm
'
,
'
faReddit
'
,
'
faSlack
'
,
'
faSoundcloud
'
,
'
faSpotify
'
,
'
faSteam
'
,
'
faTeamspeak
'
,
'
faTelegram
'
,
'
faTrello
'
,
'
faVimeo
'
,
'
faWhatsapp
'
,
'
faWikipediaW
'
,
'
faWordpress
'
,
],
}
This diff is collapsed.
Click to expand it.
nuxt.config.js
+
9
−
141
View file @
76142fda
import
i18n
from
'
./plugins/i18n.js
'
import
i18n
from
'
./plugins/i18n.js
'
import
config
from
'
./static/settings/globals.json
'
import
config
from
'
./static/settings/globals.json
'
import
hooks
from
'
./libs/hooks.js
'
import
icons
from
'
./libs/icons.js
'
export
default
{
export
default
{
target
:
'
static
'
,
target
:
'
static
'
,
...
@@ -66,72 +68,7 @@ export default {
...
@@ -66,72 +68,7 @@ export default {
{
{
component
:
'
fa
'
,
// component name
component
:
'
fa
'
,
// component name
addCss
:
false
,
addCss
:
false
,
icons
:
{
icons
,
regular
:
[
'
faClock
'
],
solid
:
[
'
faHome
'
,
'
faSearch
'
,
'
faSkullCrossbones
'
,
'
faChevronLeft
'
,
'
faChevronRight
'
,
'
faArrowLeft
'
,
'
faArrowRight
'
,
'
faSun
'
,
'
faMoon
'
,
'
faHeart
'
,
'
faInfoCircle
'
,
'
faCheckCircle
'
,
'
faCheck
'
,
'
faExclamationCircle
'
,
'
faExclamationTriangle
'
,
'
faExternalLinkAlt
'
,
'
faBars
'
,
'
faUserCircle
'
,
'
faGlobe
'
,
'
faAngry
'
,
'
faCompressArrowsAlt
'
,
'
faExpandArrowsAlt
'
,
'
faFont
'
,
'
faWheelchair
'
,
'
faCaretDown
'
,
],
brands
:
[
'
faCreativeCommonsNcEu
'
,
'
faDiaspora
'
,
'
faDiscourse
'
,
'
faGithub
'
,
'
faGitlab
'
,
'
faYoutube
'
,
'
faRocketchat
'
,
'
faFacebook
'
,
'
faTwitter
'
,
'
faDiscord
'
,
'
faApple
'
,
'
faAndroid
'
,
'
faBitcoin
'
,
'
faChrome
'
,
'
faFirefox
'
,
'
faCodepen
'
,
'
faDev
'
,
'
faDocker
'
,
'
faDropbox
'
,
'
faMastodon
'
,
'
faMedium
'
,
'
faNpm
'
,
'
faReddit
'
,
'
faSlack
'
,
'
faSoundcloud
'
,
'
faSpotify
'
,
'
faSteam
'
,
'
faTeamspeak
'
,
'
faTelegram
'
,
'
faTrello
'
,
'
faVimeo
'
,
'
faWhatsapp
'
,
'
faWikipediaW
'
,
'
faWordpress
'
,
],
},
},
},
],
],
],
],
...
@@ -180,11 +117,6 @@ export default {
...
@@ -180,11 +117,6 @@ export default {
},
},
},
},
// https://github.com/Chantouch/nuxt-clipboard
clipboard
:
{
autoSetContainer
:
true
,
},
// https://content.nuxtjs.org/fr/configuration
// https://content.nuxtjs.org/fr/configuration
content
:
{
content
:
{
markdown
:
{
markdown
:
{
...
@@ -199,80 +131,16 @@ export default {
...
@@ -199,80 +131,16 @@ export default {
classSuffix
:
''
,
classSuffix
:
''
,
},
},
// https://github.com/Chantouch/nuxt-clipboard
clipboard
:
{
autoSetContainer
:
true
,
},
/**
/**
* Nuxt hooks
* Nuxt hooks
* https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-hooks
* https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-hooks
*/
*/
hooks
:
{
hooks
,
// Netlifycms cannot create array in json file at root level and nuxt-content need an array. So, ressources.json is parsed to fetch 'ressources' key.
'
content:file:beforeParse
'
:
(
file
)
=>
{
if
(
file
.
extension
===
'
.json
'
&&
/.*ressources.json$/
.
test
(
file
.
path
))
{
file
.
data
=
JSON
.
stringify
(
JSON
.
parse
(
file
.
data
).
ressources
)
}
else
if
(
file
.
extension
===
'
.md
'
)
{
if
(
/^---.*layout:.*---/
s
.
test
(
file
.
data
))
{
let
t
=
0
const
data
=
file
.
data
.
replace
(
/---/g
,
(
match
)
=>
{
++
t
if
(
t
===
2
)
return
'
---
\n
<section>
'
if
(
t
>
2
)
return
'
</section>
\n
<section>
'
return
match
})
file
.
data
=
data
+
'
\n
</section>
'
}
}
},
async
'
content:file:beforeInsert
'
(
document
)
{
if
(
document
.
extension
===
'
.md
'
)
{
/*
* Add reading time
*/
document
.
readingTime
=
require
(
'
reading-time
'
)(
document
.
text
)
/*
* Add lexique terms and check if terms exist
*/
// Search lexique terms
const
lexiqueTerms
=
[
...
document
.
text
.
matchAll
(
/<lexique
[
>
]([^
<
]
*
)
<
\/
|<lexique
\s
+title="
(
.*
)
"/g
),
].
map
((
match
)
=>
{
return
(
match
[
2
]
||
match
[
1
]).
toLowerCase
()
// Priority for term in title=""
})
if
(
lexiqueTerms
.
length
)
{
// Add terms to document
document
.
lexiqueTerms
=
[...
new
Set
(
lexiqueTerms
)]
// remove duplicate
const
{
$content
}
=
require
(
'
@nuxt/content
'
)
// Check if term exists
if
(
$content
)
{
for
(
let
i
=
0
;
i
<
document
.
lexiqueTerms
.
length
;
i
++
)
{
const
term
=
document
.
lexiqueTerms
[
i
]
const
lexique
=
await
$content
(
'
lexique
'
)
.
where
({
$or
:
[
{
title
:
{
$regex
:
[
`^
${
term
}
$`
,
'
i
'
]
}
},
// case insensitive
{
synonyms
:
{
$contains
:
term
}
},
// search in synonyms
],
})
.
limit
(
1
)
.
fetch
()
if
(
!
lexique
.
length
)
{
// eslint-disable-next-line no-console
console
.
warn
(
`Term "
${
term
}
" in file
${
document
.
path
+
document
.
extension
}
doesn't exist`
)
}
}
}
}
}
},
},
/**
/**
* Build configuration
* Build configuration
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment