Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-wt
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
8fe5527a
authored
2024-11-11 15:47:39 -0600
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add some global functions to remote-content for clearing out cached
remote content.
1 parent
769b1bb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
lib/remote-content.ts
lib/remote-content.ts
View file @
8fe5527
...
...
@@ -36,7 +36,7 @@ const siteBaseQuery = async (args, api, options) => {
export
const
sitePageSlice
=
createApi
({
reducerPath
:
'pages'
,
tagTypes
:
[
'Page'
],
tagTypes
:
[
'
Site'
,
'
Page'
],
keepUnusedDataFor
:
60
,
refetchOnReconnect
:
true
,
refetchOnMountOrArgChange
:
true
,
...
...
@@ -54,7 +54,10 @@ export const sitePageSlice = createApi({
},
providesTags
:
(
result
,
err
,
args
)
=>
{
const
{
site
,
page
}
=
args
return
[
{
type
:
'Page'
,
id
:
{
site
,
page
}
}
]
return
[
{
type
:
'Site'
,
id
:
site
},
{
type
:
'Page'
,
id
:
`
${
site
}
:
${
page
}
`
},
]
},
}),
}),
...
...
@@ -83,5 +86,23 @@ export const getSiteBaseUrl = (name: string): string => {
return
configSlice
.
selectors
.
getSiteBaseUrl
(
store
.
getState
(),
name
)
}
export
const
clearAll
=
()
=>
{
return
store
.
dispatch
(
sitePageSlice
.
util
.
invalidateTags
([
'Page'
]))
}
export
const
clearSite
=
(
site
:
string
)
=>
{
return
store
.
dispatch
(
sitePageSlice
.
util
.
invalidateTags
([
{
type
:
'Site'
,
id
:
site
}
]))
}
export
const
clearPages
=
(
site
:
string
,
...
pages
:
string
)
=>
{
return
store
.
dispatch
(
sitePageSlice
.
util
.
invalidateTags
(
pages
.
map
(
page
=>
({
type
:
'Page'
,
id
:
`
${
site
}
/
${
page
}
`
})
)))
}
export
const
prefetch
=
(
site
:
string
,
...
pages
:
string
)
=>
{
return
Promise
.
all
(
pages
.
map
(
page
=>
{
return
store
.
dispatch
(
sitePageSlice
.
util
.
prefetch
(
'getPage'
,
{
site
,
page
},
{
force
:
true
}))
}))
}
setSiteConfig
({
name
:
'direct'
})
...
...
Please
register
or
sign in
to post a comment