Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): add last time edit date #349

Open
wants to merge 16 commits into
base: stable
Choose a base branch
from

Conversation

Lullabyq
Copy link
Contributor

@Lullabyq Lullabyq commented Dec 9, 2024

fibery

Часть 1 - вывод тега с датой последнего обновления статьи

по умолчанию дата выводится в правом нижнем углу статьи

image

мы решили выводить ее в начале каждой статьи в виде тега

image




Часть 2 - выводим 5 последних статей на отдельной странице

сделано с референсом

для того чтобы добавить контента на страницу с выводом последних статей нужны дополнительные сведения о статье, которые будут заполнять редакторы при ее создании

---
recent_article:
  // Была ли статья добавлена впервые
  new?: true
  
  // массив тезисов с изменениями в статье
  theses?: 
    - Исправили ошибку
    - Добавили ссылку
    - Уточнили пункт сценария
    
   // если выставлено в true то статья:
   // 1) не будет показана среди недавно обновленных 
   // 2) внутри статьи не будет отрисован тэг с датой ее обновления
  ignore?: true 
  
---

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for sendsay-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 533f653
🔍 Latest deploy log https://app.netlify.com/sites/sendsay-docs/deploys/679cf5441906960008197232
😎 Deploy Preview https://deploy-preview-349--sendsay-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -45,6 +45,7 @@ const config: Config = {
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
showLastUpdateTime: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это новое поле, остальное это линтер отрефакторил

@Lullabyq Lullabyq force-pushed the feat/last-edit-date branch from 72ef415 to 2cd6d64 Compare December 9, 2024 12:21
@Lullabyq Lullabyq force-pushed the feat/last-edit-date branch 2 times, most recently from 7c11115 to 76f7497 Compare December 11, 2024 08:31
@Lullabyq Lullabyq force-pushed the feat/last-edit-date branch 4 times, most recently from 7030052 to d0e2af4 Compare January 22, 2025 14:07
Comment on lines +24 to +31
actions.addRoute({
path: RECENT_ARTICLES_TEMP_URL,
exact: true,
component: '@site/src/components/RecentlyUpdatedArticles/RecentlyUpdatedArticles.js',
modules: {
recentArticles,
},
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на моменте обработки данных мы добавляем роут и рендерим в нем компонент, данная статья недоступна пользователям, не должна показываться в поиске и не индексируется

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это компонент который мы рендерим на этой странице - его можно посмотреть по прямой ссылке
https://deploy-preview-349--sendsay-docs.netlify.app/updates/BC1ADF523

Comment on lines 40 to 53
<iframe
ref={iframeRef}
src={RECENT_ARTICLES_TEMP_URL}
name="latest-articles"
className="w-full"
style={{
border: 'none',
outline: 'none',
}}
onLoad={resizeIframe}
scrolling="no"
seamless="seamless"
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

следом нам нужен iframe который будет отображать статью в нужном нам месте (самое простое решение для того чтобы в статье был сайдбар и тайтл)

Comment on lines 9 to 11
import { RecentlyUpdatedArticlesIframe } from '@site/src/components/RecentlyUpdatedArticles';

<RecentlyUpdatedArticlesIframe />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дальше мы добавляем статью в которой данный iframe рендерится с нужным нам лейаутом

image

Comment on lines +32 to +33
iframeRef.current?.contentWindow.document.addEventListener('redirect', handleRedirectInIframe);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот кастомный слушатель нужен для того чтобы при клике по ссылке внутри айфрейма мы с помощью реакта осуществили редирект внутри приложения,

если сделать history.push внутри айфрейма то мы откроем страницу в маленьком окошке iframa оставшись на странице с обновлениями документации

всякие window.parent.location.href приводили к перезагрузке страницы и терялась одностраничность приложения

@Lullabyq Lullabyq force-pushed the feat/last-edit-date branch 2 times, most recently from 8e7dfaf to 053acaf Compare January 22, 2025 14:57
@Lullabyq Lullabyq force-pushed the feat/last-edit-date branch from 053acaf to a3f3b84 Compare January 22, 2025 16:06
Comment on lines +4 to +8
recent_article:
theses:
- Пример
- Изменения
- 24 правки текста
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалить перед релизом

Comment on lines +4 to +5
recent_article:
new: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалить перед релизом

@Matveev89
Copy link
Contributor

Тут наверное какая-то высота задана фиксированная? Если контента накинуть - не вмещается уже последняя карточка

Снимок экрана 2025-01-28 в 16 54 49

@Lullabyq
Copy link
Contributor Author

Lullabyq commented Jan 28, 2025

это приколы с iframe он на моменте загрузки вычисляет высоту и выставляет по размеру, нужно добавить перерасчет для ресайза, спасибо

src/theme/DocItem/Layout/index.tsx Outdated Show resolved Hide resolved
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.4.1"
"tailwindcss": "^3.4.1",
"html-entities": "2.5.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил новый пакет чтобы конвертить html entities в unicode для корректного вывода в тегах html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants