Skip to content

Commit

Permalink
Добавляет RSS-фид (#1227)
Browse files Browse the repository at this point in the history
* Добавляет плагин для генерации RSS

* Добавляет плагин в конфигурацию

* Добавляет новые материалы из  CHANGELOG.md в RSS

* Убложает ESLint
  • Loading branch information
igsekor authored Dec 28, 2023
1 parent c0acff8 commit 7818579
Show file tree
Hide file tree
Showing 49 changed files with 373 additions and 255 deletions.
58 changes: 58 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const imagePlaceTransform = require('./src/transforms/image-place-transform')
const detailsTransform = require('./src/transforms/details-transform')
const calloutTransform = require('./src/transforms/callout-transform')

const pluginRss = require('@11ty/eleventy-plugin-rss')

function getAllDocs(collectionAPI) {
const dokas = collectionAPI.getFilteredByTag('doka')
const articles = collectionAPI.getFilteredByTag('article')
Expand Down Expand Up @@ -90,6 +92,56 @@ module.exports = function (config) {
}, {})
})

config.addCollection('posts', async (collectionApi) => {
const changeLog = await (
await fetch('https://raw.githubusercontent.com/doka-guide/content/main/CHANGELOG.md')
).text()
const months = [
'января',
'февраля',
'марта',
'апреля',
'мая',
'июня',
'июля',
'августа',
'сентября',
'октября',
'ноября',
'декабря',
]

let currentYear = 0
const posts = changeLog
.split('\n')
.filter((s) => s.match(/^(-|##) /))
.map((s) => {
if (s.match(/## .+ [0-9]{4}/)) {
currentYear = Number(s.replace(/## .+ /, ''))
return s
} else {
const stringParts = s.replace(/^- /, '').split(', [')
const date = stringParts[0].split(' ')
const currentDay = Number(date[0])
const currentMonth = months.indexOf(date[1])

const post = {}
const titledLink = stringParts[1].split('](')
post['date'] = new Date(Date.parse(`${currentYear}-${currentMonth + 1}-${currentDay}`))
post['title'] = titledLink[0].replace(/^\[/, '')
post['url'] = titledLink[1].replace(/\), [А-ЯЁа-яё ,]*/, '')
post['summary'] = collectionApi
.getFilteredByGlob(`src${post['url'].replace('https://doka.guide', '')}*.md`)[0]
?.template.inputContent.split('\n')
.filter((s) => s.match(/^description: /))[0]
.replace(/^description: /, '')

return post
}
})
return posts.filter((s) => typeof s === 'object')
})

config.addCollection('people', (collectionApi) => {
return collectionApi.getFilteredByGlob('src/people/*/index.md')
})
Expand Down Expand Up @@ -382,6 +434,12 @@ module.exports = function (config) {
})
}

config.addPlugin(pluginRss, {
posthtmlRenderOptions: {
closingSingleTag: 'default',
},
})

config.addPassthroughCopy('src/favicon.ico')
config.addPassthroughCopy('src/manifest.json')
config.addPassthroughCopy('src/robots.txt')
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/scripts/core/base-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class BaseComponent extends EventTarget {
this.dispatchEvent(
new CustomEvent(eventType, {
detail,
}),
})
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/libs/__tests__/toc-text-crop-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const dom = new JSDOM(
<a class="toc__link">${headersTemplate[1]}</a>
<a class="toc__link">${headersTemplate[2]}</a>
<a class="toc__link">${headersTemplate[3]}</a>
`,
`
)

test('обрезка длины заголовка секции в боковой навигации', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/cookie-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function init() {
banner.hidden = true
localStorage.setItem(storageKey, true)
},
{ once: true },
{ once: true }
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/modules/feedback-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function init() {
reasonFieldset.inert = true
})
},
{ once: true },
{ once: true }
)

voteButtonGroup.on(ButtonGroup.EVENTS.CORRECTION, () => {
Expand All @@ -186,7 +186,7 @@ function init() {
textControl.hidden = true
})
},
{ once: true },
{ once: true }
)

reasonsButtonGroup.on(ButtonGroup.EVENTS.CORRECTION, () => {
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/modules/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Header extends BaseComponent {
;['openOnKeyUp', 'closeOnKeyUp', 'closeOnClickOutSide', 'openMenu', 'closeMenu', 'fixHeader', 'checkFixed'].forEach(
(method) => {
this[method] = this[method].bind(this)
},
}
)

const resizeCallback = () => {
Expand Down Expand Up @@ -97,7 +97,7 @@ class Header extends BaseComponent {
const header = this.refs.rootElement

return [!header.classList.contains('header--static'), !header.classList.contains('search-page__header')].every(
Boolean,
Boolean
)
}

Expand Down Expand Up @@ -178,7 +178,7 @@ class Header extends BaseComponent {
}
header.classList.remove(...classes)
},
{ once: true },
{ once: true }
)

this.fixHeader(true)
Expand All @@ -199,7 +199,7 @@ class Header extends BaseComponent {
this.fixHeader(false)
header.classList.remove(...classes)
},
{ once: true },
{ once: true }
)

header.classList.add(...classes)
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Logo {
this._isAnimation = false
this.refs.image.classList.remove(Logo.constants.animationStateClass)
},
{ once: true },
{ once: true }
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/question-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function init() {
textControl.hidden = true
})
},
{ once: true },
{ once: true }
)

questionsButtonGroup.on(ButtonGroup.EVENTS.CORRECTION, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/quick-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class QuickSearch extends BaseComponent {
.map((hitObject) => {
const title = hitObject.originalTitle.replace(
/`(.*?)`/g,
'<code class="suggestion-list__code font-theme font-theme--code">$1</code>',
'<code class="suggestion-list__code font-theme font-theme--code">$1</code>'
)
return `
<li class="suggestion-list__item" style="--accent-color: var(--color-${hitObject.category});">
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SearchResultOutput extends BaseComponent {
const editIcon = SearchResultOutput.isPlaceholder(hitObject) ? SearchResultOutput.templates.placeholderIcon : ''
const title = SearchResultOutput.replaceBackticks(
hitObject.title.replaceAll('<mark>', '<mark class="search-hit__marked">'),
SearchResultOutput.templates.titleCode,
SearchResultOutput.templates.titleCode
)
const summary = hitObject.summary
.slice(0, SearchResultOutput.matchedItems)
Expand Down Expand Up @@ -157,7 +157,7 @@ class SearchResultOutput extends BaseComponent {
<li class="search-result-list__item">
${SearchResultOutput.templates.hit(hitObject)}
</li>
`,
`
)
.join('')}
</ol>
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/subscribe-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ async function init() {
window.addEventListener('online', async () => {
sendFromDb(
dbSubscribeStoreName,
getPreparedSaveToServerFunction(email, hash ? 'PUT' : 'POST', hash ? inflation.profile.id : ''),
getPreparedSaveToServerFunction(email, hash ? 'PUT' : 'POST', hash ? inflation.profile.id : '')
)
closeAndDeleteDb(dbSubscribeStoreName)
})
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function init() {

event.preventDefault()
saveLink(link, button)
}),
})
)

function headingsScaler() {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/modules/triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function init() {
updatePageInfo(sessionObject.visited, currentPage, 'duration', updatingPeriod, (from, to) => from + to)
updatePageInfo(sessionObject.visited, currentPage, 'loaded', currentTime, (from, to) => to)
updatePageInfo(sessionObject.visited, currentPage, 'scrollDeepness', scrollDeepness, (from, to) =>
to > from ? to : from,
to > from ? to : from
)
} else {
sessionObject['visited'][currentPage] = {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/article-image.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

.article-image__picture::before {
content: '';
content: "";
display: block;
padding-top: calc(100% / (var(--aspect-ratio)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/article-nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}

.article-nav__button::before {
content: '';
content: "";
position: absolute;
bottom: 0;
left: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}

.article__placeholder::before {
content: '';
content: "";
opacity: var(--placeholder-bg-opacity);
position: absolute;
z-index: -1;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/articles-group.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}

.articles-group__placeholder-icon::before {
content: '✎';
content: "✎";
font-family: var(--font-family);
font-size: var(--font-size-m);
letter-spacing: 0.2em;
Expand Down
30 changes: 15 additions & 15 deletions src/styles/blocks/baseline.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
background-size: cover;
}

.wdi-browser-compat__icon[data-browser='chrome'] {
background-image: url('/images/baseline/chrome.svg');
.wdi-browser-compat__icon[data-browser="chrome"] {
background-image: url("/images/baseline/chrome.svg");
}

.wdi-browser-compat__icon[data-browser='firefox'] {
background-image: url('/images/baseline/firefox.svg');
.wdi-browser-compat__icon[data-browser="firefox"] {
background-image: url("/images/baseline/firefox.svg");
}

.wdi-browser-compat__icon[data-browser='edge'] {
background-image: url('/images/baseline/edge.svg');
.wdi-browser-compat__icon[data-browser="edge"] {
background-image: url("/images/baseline/edge.svg");
}

.wdi-browser-compat__icon[data-browser='safari'] {
background-image: url('/images/baseline/safari.svg');
.wdi-browser-compat__icon[data-browser="safari"] {
background-image: url("/images/baseline/safari.svg");
}

.wdi-browser-compat__version {
Expand All @@ -63,26 +63,26 @@
padding-inline: 0.5ch;
}

.wdi-browser-compat__version[data-compat='yes'] {
.wdi-browser-compat__version[data-compat="yes"] {
background: var(--wdi-success-bg-color, #e9f6ed);
color: var(--wdi-success-color, #0d652d);
}

.wdi-browser-compat__version[data-compat='flag'] {
.wdi-browser-compat__version[data-compat="flag"] {
background-color: var(--wdi-warn-bg-color, #fff5e3);
background-image: url('/images/baseline/flag.svg');
background-image: url("/images/baseline/flag.svg");
color: var(--wdi-warn-color, #c34900);
}

.wdi-browser-compat__version[data-compat='no'] {
.wdi-browser-compat__version[data-compat="no"] {
background-color: var(--wdi-error-bg-color, #fce8e8);
background-image: url('/images/baseline/no.svg');
background-image: url("/images/baseline/no.svg");
color: var(--wdi-error-color, #a50e0e);
}

.wdi-browser-compat__version[data-compat='preview'] {
.wdi-browser-compat__version[data-compat="preview"] {
background-color: var(--wdi-warn-bg-color, #fff5e3);
background-image: url('/images/baseline/preview.svg');
background-image: url("/images/baseline/preview.svg");
color: var(--wdi-warn-color, #c34900);
}

Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/block-code.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
align-items: start;
align-content: start;
grid-template-columns: auto minmax(0, 1fr);
grid-template-areas: 'lines code';
grid-template-areas: "lines code";
overflow: auto;
overscroll-behavior-x: contain;
font-size: 1em;
Expand Down
6 changes: 3 additions & 3 deletions src/styles/blocks/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}

.content > blockquote::before {
content: '';
content: "";
opacity:
calc(
0.1 * var(--is-light-theme-on) +
Expand All @@ -62,7 +62,7 @@
}

.content > blockquote::after {
content: '';
content: "";
position: absolute;
top: 0;
bottom: 0;
Expand All @@ -78,7 +78,7 @@
.content > p > kbd,
.content > ul > li > kbd,
.content > ol > li > kbd {
font-family: 'Spot Mono', monospace;
font-family: "Spot Mono", monospace;
}

.content > img,
Expand Down
Loading

0 comments on commit 7818579

Please sign in to comment.